Cobalt for what is safe (PEA) and for actions, ochre for the AI pot, green and red only for gains and losses. Bricolage Grotesque for amounts and titles, Atkinson Hyperlegible Next for text. Home opens on total wealth with a split bar (safe vs working pot); recipe cards with numbered steps; plain sentences instead of emoji and symbols; back links; AI tab with monthly deposits and reset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
469e46d306
commit
dba64728d6
@ -1,12 +1,12 @@
|
|||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import Link from "next/link";
|
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { and, desc, eq } from "drizzle-orm";
|
import { and, desc, eq } from "drizzle-orm";
|
||||||
import { PositionList } from "@/components/positions";
|
import { PositionList } from "@/components/positions";
|
||||||
import { StockChart } from "@/components/stock-chart";
|
import { StockChart } from "@/components/stock-chart";
|
||||||
import { TradePanel } from "@/components/trade-panel";
|
import { TradePanel } from "@/components/trade-panel";
|
||||||
import { Badge, Card, CardSkeleton, Empty, Page } from "@/components/ui";
|
import { Badge, Card, CardSkeleton, Delta, Empty, Page } from "@/components/ui";
|
||||||
|
import { BackLink } from "@/components/nav";
|
||||||
import { aiEnabled, getAiSpend } from "@/lib/ai";
|
import { aiEnabled, getAiSpend } from "@/lib/ai";
|
||||||
import { getDb, schema } from "@/lib/db";
|
import { getDb, schema } from "@/lib/db";
|
||||||
import { pct, price, timeAgo } from "@/lib/format";
|
import { pct, price, timeAgo } from "@/lib/format";
|
||||||
@ -52,26 +52,32 @@ async function StockContent({ params, searchParams }: Props) {
|
|||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title={stock?.name ?? quote.name}
|
title={stock?.name ?? quote.name}
|
||||||
subtitle={`${symbol}${stock ? ` · ${stock.market === "US" ? "Bourse américaine" : "Bourse européenne"}` : ""}`}
|
subtitle={`${symbol}${stock ? `, ${stock.market === "US" ? "Bourse américaine" : "Bourse européenne"}` : ""}`}
|
||||||
action={
|
action={<BackLink href="/actions" label="Actions" />}
|
||||||
<Link href="/actions" className="text-sm font-medium text-accent">
|
|
||||||
‹ Actions
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Card>
|
<Card>
|
||||||
<div className="flex items-end justify-between gap-3">
|
<div className="flex items-end justify-between gap-3">
|
||||||
<p className="num text-3xl font-semibold">{price(quote.price, quote.currency)}</p>
|
<div>
|
||||||
<div className="text-right text-sm">
|
<p className="amount text-[2.8rem] font-bold">{price(quote.price, quote.currency)}</p>
|
||||||
{quote.changePct !== null && <p className={`num font-semibold ${quote.changePct >= 0 ? "text-accent" : "text-danger"}`}>{pct(quote.changePct, 2)} auj.</p>}
|
{quote.currency === "USD" && fx && <p className="num mt-1.5 text-[14px] text-muted">soit {(quote.price * fx).toFixed(2).replace(".", ",")} € chez Trade Republic</p>}
|
||||||
{change3m !== null && <p className={`num text-xs ${change3m >= 0 ? "text-accent" : "text-danger"}`}>{pct(change3m)} sur 3 mois</p>}
|
</div>
|
||||||
|
<div className="pb-1 text-right text-[14px]">
|
||||||
|
{quote.changePct !== null && (
|
||||||
|
<p>
|
||||||
|
<Delta value={quote.changePct}>{pct(quote.changePct, 2)}</Delta> <span className="text-muted">aujourd'hui</span>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{change3m !== null && (
|
||||||
|
<p className="mt-0.5">
|
||||||
|
<Delta value={change3m}>{pct(change3m)}</Delta> <span className="text-muted">en 3 mois</span>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{quote.currency === "USD" && fx && <p className="num mt-1 text-xs text-muted">≈ {(quote.price * fx).toFixed(2)} € chez Trade Republic</p>}
|
<div className="mt-4">
|
||||||
<div className="mt-3">
|
|
||||||
<StockChart bars={bars} lastPrice={quote.price} stop={held[0]?.stopPrice} target={held[0]?.targetPrice} />
|
<StockChart bars={bars} lastPrice={quote.price} stop={held[0]?.stopPrice} target={held[0]?.targetPrice} />
|
||||||
</div>
|
</div>
|
||||||
{earnings && <p className="mt-2 text-xs text-muted">📅 Prochains résultats : {formatDateFr(earnings)}</p>}
|
{earnings && <p className="mt-3 text-[13px] text-muted">Prochains résultats le {formatDateFr(earnings)}. L'app n'achète jamais dans les 4 jours qui précèdent.</p>}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{held.length > 0 && (
|
{held.length > 0 && (
|
||||||
@ -81,13 +87,13 @@ async function StockContent({ params, searchParams }: Props) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{signal && (
|
{signal && (
|
||||||
<Card title={`Dernière analyse de l'IA · ${formatDateFr(signal.date)}`}>
|
<Card title="Ce qu'en pense l'IA" action={<span className="text-[13px] text-muted">{formatDateFr(signal.date)}</span>}>
|
||||||
<p className="mb-2">
|
<p className="mb-2 flex items-center gap-2">
|
||||||
<Badge tone={signal.decision === "buy" ? "accent" : "neutral"}>{signal.decision === "buy" ? "Achat" : "On passe"}</Badge>{" "}
|
<Badge tone={signal.decision === "buy" ? "gain" : "neutral"}>{signal.decision === "buy" ? "Achète" : "Passe son tour"}</Badge>
|
||||||
<span className="text-xs text-muted">confiance {signal.confidence} %</span>
|
<span className="text-[13px] text-muted">confiance {signal.confidence} %</span>
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm leading-relaxed">{signal.thesis}</p>
|
<p className="text-[15px] leading-relaxed">{signal.thesis}</p>
|
||||||
<p className="mt-1 text-sm leading-relaxed text-muted">⚠️ {signal.risks}</p>
|
<p className="mt-1.5 text-[14px] leading-relaxed text-muted">Risques : {signal.risks}</p>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -111,16 +117,22 @@ async function StockContent({ params, searchParams }: Props) {
|
|||||||
|
|
||||||
<Card title="Actus récentes">
|
<Card title="Actus récentes">
|
||||||
{!news.length && <Empty>Pas d'actu récente.</Empty>}
|
{!news.length && <Empty>Pas d'actu récente.</Empty>}
|
||||||
<ul className="divide-y divide-line">
|
<ul className="-my-1 divide-y divide-line">
|
||||||
{news.map((n) => (
|
{news.map((n) => (
|
||||||
<li key={n.id} className="py-2.5">
|
<li key={n.id} className="py-3">
|
||||||
<a href={n.url ?? "#"} target="_blank" rel="noreferrer" className="text-sm font-medium leading-snug">
|
<a href={n.url ?? "#"} target="_blank" rel="noreferrer" className="text-[15px] font-semibold leading-snug">
|
||||||
{n.title}
|
{n.title}
|
||||||
</a>
|
</a>
|
||||||
{n.triage?.reason && <p className="mt-1 text-xs leading-relaxed text-muted">{n.triage.reason}</p>}
|
{n.triage?.reason && <p className="mt-1 text-[14px] leading-relaxed text-muted">{n.triage.reason}</p>}
|
||||||
<p className="mt-1 text-xs text-muted">
|
<p className="mt-1 flex flex-wrap items-center gap-x-2 text-[13px] text-muted">
|
||||||
{n.publisher} · {timeAgo(n.publishedAt)}
|
<span>
|
||||||
{n.triage && ` · ${n.triage.direction === "positive" ? "▲" : n.triage.direction === "negative" ? "▼" : "•"} ${n.triage.relevance}/10`}
|
{n.publisher}, {timeAgo(n.publishedAt)}
|
||||||
|
</span>
|
||||||
|
{n.triage && (
|
||||||
|
<Badge tone={n.triage.direction === "positive" ? "gain" : n.triage.direction === "negative" ? "danger" : "neutral"}>
|
||||||
|
{n.triage.direction === "positive" ? "Bonne nouvelle" : n.triage.direction === "negative" ? "Mauvaise nouvelle" : "Neutre"}, {n.triage.relevance}/10
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@ -134,7 +146,7 @@ export default function StockPage(props: Props) {
|
|||||||
return (
|
return (
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={
|
fallback={
|
||||||
<Page title="Chargement…">
|
<Page title=" " action={<BackLink href="/actions" label="Actions" />}>
|
||||||
<CardSkeleton height="h-40" />
|
<CardSkeleton height="h-40" />
|
||||||
<CardSkeleton height="h-64" />
|
<CardSkeleton height="h-64" />
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Suspense } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { StockBrowser, type StockRow } from "@/components/stock-browser";
|
import { StockBrowser, type StockRow } from "@/components/stock-browser";
|
||||||
import { Card, CardSkeleton, Empty, Page } from "@/components/ui";
|
import { Badge, Card, CardSkeleton, Empty, Page } from "@/components/ui";
|
||||||
import { pct } from "@/lib/format";
|
import { pct } from "@/lib/format";
|
||||||
import { getIdeas } from "@/lib/ideas";
|
import { getIdeas } from "@/lib/ideas";
|
||||||
import { getQuotes } from "@/lib/market";
|
import { getQuotes } from "@/lib/market";
|
||||||
@ -15,17 +15,17 @@ async function Ideas() {
|
|||||||
const ideas = await getIdeas();
|
const ideas = await getIdeas();
|
||||||
const items = ideas?.items.slice(0, 4) ?? [];
|
const items = ideas?.items.slice(0, 4) ?? [];
|
||||||
return (
|
return (
|
||||||
<Card title="Idées du moment" action={<span className="text-xs text-muted">filtre sans IA</span>}>
|
<Card title="Idées du moment" action={<Badge>Sans IA</Badge>}>
|
||||||
{!items.length && <Empty>Les idées se calculent à l'ouverture de l'app : reviens dans une minute.</Empty>}
|
{!items.length && <Empty>Les idées se calculent à l'ouverture de l'app : reviens dans une minute.</Empty>}
|
||||||
<ul className="flex flex-col gap-2">
|
<ul className="-my-1 divide-y divide-line">
|
||||||
{items.map((i) => (
|
{items.map((i) => (
|
||||||
<li key={i.symbol}>
|
<li key={i.symbol}>
|
||||||
<Link href={`/actions/${encodeURIComponent(i.symbol)}`} className="block rounded-xl bg-surface-2 p-3">
|
<Link href={`/actions/${encodeURIComponent(i.symbol)}`} className="block py-3">
|
||||||
<span className="flex items-center justify-between gap-2">
|
<span className="flex items-center justify-between gap-2">
|
||||||
<span className="font-semibold">{i.name}</span>
|
<span className="font-semibold">{i.name}</span>
|
||||||
<span className="num text-sm text-danger">{pct(i.pullbackPct)} sur 5 j</span>
|
<span className="num shrink-0 text-[14px] font-semibold text-danger">{pct(i.pullbackPct)} en 5 jours</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="mt-1 block text-xs leading-relaxed text-muted">{i.reason}</span>
|
<span className="mt-1 block text-[13px] leading-relaxed text-muted">{i.reason}</span>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@ -57,10 +57,10 @@ export default function ActionsPage() {
|
|||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title="Actions"
|
title="Actions"
|
||||||
subtitle="Les grandes actions US et Europe suivies par l'app. Touche une action pour la voir et l'acheter dans ton bac à sable."
|
subtitle="Les grandes entreprises américaines et européennes suivies par l'app. Touche-en une pour la voir et l'essayer."
|
||||||
action={
|
action={
|
||||||
<Link href="/actus" className="text-sm font-medium text-accent">
|
<Link href="/actus" className="inline-flex h-10 items-center rounded-full bg-surface px-4 text-[14px] font-semibold text-ink dark:ring-1 dark:ring-line">
|
||||||
📰 Actus
|
Actus
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { PageSkeleton } from "@/components/page-skeleton";
|
import { PageSkeleton } from "@/components/page-skeleton";
|
||||||
|
import { BackLink } from "@/components/nav";
|
||||||
import { Badge, Card, Empty, Page } from "@/components/ui";
|
import { Badge, Card, Empty, Page } from "@/components/ui";
|
||||||
import { timeAgo } from "@/lib/format";
|
import { timeAgo } from "@/lib/format";
|
||||||
import { recentNews } from "@/lib/news";
|
import { recentNews } from "@/lib/news";
|
||||||
@ -33,23 +34,23 @@ async function NewsPageContent() {
|
|||||||
return (
|
return (
|
||||||
<li key={n.id} className="py-3">
|
<li key={n.id} className="py-3">
|
||||||
<div className="mb-1 flex flex-wrap items-center gap-1.5">
|
<div className="mb-1 flex flex-wrap items-center gap-1.5">
|
||||||
<span className="text-xs font-semibold">{findStock(n.symbol)?.name ?? n.symbol}</span>
|
<span className="text-[13px] font-semibold">{findStock(n.symbol)?.name ?? n.symbol}</span>
|
||||||
{t && (
|
{t && (
|
||||||
<>
|
<>
|
||||||
<Badge tone={t.direction === "positive" ? "accent" : t.direction === "negative" ? "danger" : "neutral"}>
|
<Badge tone={t.direction === "positive" ? "gain" : t.direction === "negative" ? "danger" : "neutral"}>
|
||||||
{t.direction === "positive" ? "▲ positif" : t.direction === "negative" ? "▼ négatif" : "neutre"}
|
{t.direction === "positive" ? "Bonne nouvelle" : t.direction === "negative" ? "Mauvaise nouvelle" : "Neutre"}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge>{EVENT_LABELS[t.eventType] ?? t.eventType}</Badge>
|
<Badge>{EVENT_LABELS[t.eventType] ?? t.eventType}</Badge>
|
||||||
<span className="num text-xs text-muted">{t.relevance}/10</span>
|
<span className="num text-[13px] text-muted">{t.relevance}/10</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!t && <Badge>pas encore triée</Badge>}
|
{!t && <Badge>pas encore triée</Badge>}
|
||||||
</div>
|
</div>
|
||||||
<a href={n.url ?? "#"} target="_blank" rel="noreferrer" className="text-sm font-medium leading-snug">
|
<a href={n.url ?? "#"} target="_blank" rel="noreferrer" className="text-[15px] font-semibold leading-snug">
|
||||||
{n.title}
|
{n.title}
|
||||||
</a>
|
</a>
|
||||||
{t?.reason && <p className="mt-1 text-xs leading-relaxed text-muted">{t.reason}</p>}
|
{t?.reason && <p className="mt-1 text-[13px] leading-relaxed text-muted">{t.reason}</p>}
|
||||||
<p className="mt-1 text-xs text-muted">
|
<p className="mt-1 text-[13px] text-muted">
|
||||||
{n.publisher} · {timeAgo(n.publishedAt)}
|
{n.publisher} · {timeAgo(n.publishedAt)}
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
@ -57,12 +58,12 @@ async function NewsPageContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title="Actus" subtitle="Les actus des 48 dernières heures, notées par l'IA de 0 à 10.">
|
<Page title="Actus" subtitle="Les actus des 48 dernières heures, notées par l'IA de 0 à 10." action={<BackLink href="/actions" label="Actions" />}>
|
||||||
<Card title="Importantes (7/10 et plus)">
|
<Card title="Ce qui compte" action={<Badge>7/10 et plus</Badge>}>
|
||||||
{important.length ? <ul className="divide-y divide-line">{important.map(item)}</ul> : <Empty>Rien de marquant pour l'instant.</Empty>}
|
{important.length ? <ul className="-my-1 divide-y divide-line">{important.map(item)}</ul> : <Empty>Rien de marquant pour l'instant.</Empty>}
|
||||||
</Card>
|
</Card>
|
||||||
<Card title="Les autres">
|
<Card title="Les autres">
|
||||||
{others.length ? <ul className="divide-y divide-line">{others.map(item)}</ul> : <Empty>Aucune actu collectée pour l'instant.</Empty>}
|
{others.length ? <ul className="-my-1 divide-y divide-line">{others.map(item)}</ul> : <Empty>Aucune actu collectée pour l'instant.</Empty>}
|
||||||
</Card>
|
</Card>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -17,21 +17,26 @@ async function SandboxContent() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card title="Ma cagnotte virtuelle">
|
<Card>
|
||||||
<div className="flex items-end justify-between">
|
<p className="text-[15px] text-muted">Mes 200 € virtuels valent</p>
|
||||||
<p className="num text-3xl font-semibold">{eur(state.equity)}</p>
|
<div className="mt-1 flex items-end justify-between gap-3">
|
||||||
<Delta value={perf}>{pct(perf)}</Delta>
|
<p className="amount text-[3rem] font-bold">{eur(state.equity)}</p>
|
||||||
|
<p className="amount pb-1 text-[1.4rem]">
|
||||||
|
<Delta value={perf}>{pct(perf)}</Delta>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 grid grid-cols-3 gap-2 text-sm">
|
<div className="mt-5 grid grid-cols-3 gap-3">
|
||||||
<Stat label="liquidités">{eur(state.cash, 0)}</Stat>
|
<Stat label="à investir">{eur(state.cash, 0)}</Stat>
|
||||||
<Stat label="gains encaissés">{signedEur(realized)}</Stat>
|
<Stat label="gains encaissés">{signedEur(realized)}</Stat>
|
||||||
<Stat label="trades gagnants">{closed.length ? `${wins}/${closed.length}` : "—"}</Stat>
|
<Stat label="trades gagnants">{closed.length ? `${wins} sur ${closed.length}` : "–"}</Stat>
|
||||||
</div>
|
</div>
|
||||||
<Link href="/actions" className={`${primaryBtn} mt-4 w-full`}>
|
<Link href="/actions" className={`${primaryBtn} mt-5 w-full`}>
|
||||||
+ Acheter une action
|
Choisir une action à acheter
|
||||||
</Link>
|
</Link>
|
||||||
{!isTradeRepublicOpen() && (
|
{!isTradeRepublicOpen() && (
|
||||||
<p className="mt-2 text-xs text-muted">Trade Republic est fermé (7h30-23h en semaine) : tes ordres s'exécuteront à la réouverture, comme en vrai.</p>
|
<p className="mt-3 text-[13px] leading-relaxed text-muted">
|
||||||
|
Trade Republic est fermé (de 7h30 à 23h en semaine) : tes ordres partiront à la réouverture, comme en vrai.
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@ -45,7 +50,7 @@ async function SandboxContent() {
|
|||||||
<PositionList positions={state.positions} sellable />
|
<PositionList positions={state.positions} sellable />
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Historique">
|
<Card title="Mes trades terminés">
|
||||||
<ClosedList positions={closed} />
|
<ClosedList positions={closed} />
|
||||||
</Card>
|
</Card>
|
||||||
<ResetSandbox />
|
<ResetSandbox />
|
||||||
@ -55,8 +60,8 @@ async function SandboxContent() {
|
|||||||
|
|
||||||
export default function SandboxPage() {
|
export default function SandboxPage() {
|
||||||
return (
|
return (
|
||||||
<Page title="Bac à sable" subtitle="Argent fictif, cours réels, frais Trade Republic (1 € par ordre). Entraîne-toi sans risque.">
|
<Page title="Bac à sable" subtitle="Argent fictif, vrais cours et vrais frais Trade Republic (1 € par ordre). Entraîne-toi sans risque.">
|
||||||
<Suspense fallback={<CardSkeleton title="Ma cagnotte virtuelle" height="h-40" />}>
|
<Suspense fallback={<CardSkeleton height="h-48" />}>
|
||||||
<SandboxContent />
|
<SandboxContent />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@ -1,89 +1,122 @@
|
|||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { PageSkeleton } from "@/components/page-skeleton";
|
|
||||||
import { desc } from "drizzle-orm";
|
import { desc } from "drizzle-orm";
|
||||||
import { ClosedList, PendingOrders, PositionList } from "@/components/positions";
|
import { ClosedList, PendingOrders, PositionList } from "@/components/positions";
|
||||||
import { Badge, Card, Empty, Page } from "@/components/ui";
|
import { ResetAi } from "@/components/reset-ai";
|
||||||
|
import { Badge, Card, CardSkeleton, Delta, Empty, Page, Stat } from "@/components/ui";
|
||||||
import { getDb, schema } from "@/lib/db";
|
import { getDb, schema } from "@/lib/db";
|
||||||
|
import { aiSimStuck, MIN_POSITION_EUR } from "@/lib/engine/risk";
|
||||||
import { eur, pct } from "@/lib/format";
|
import { eur, pct } from "@/lib/format";
|
||||||
|
|
||||||
import { getClosedPositions, getPortfolioState } from "@/lib/portfolio";
|
import { getClosedPositions, getPortfolioState } from "@/lib/portfolio";
|
||||||
|
import { getSettings } from "@/lib/settings";
|
||||||
|
import { aiDeposits, aiPerformance } from "@/lib/stats";
|
||||||
|
import { formatDateFr } from "@/lib/time";
|
||||||
|
|
||||||
|
async function Pot() {
|
||||||
async function AiPageContent() {
|
|
||||||
await connection();
|
await connection();
|
||||||
const db = await getDb();
|
const [state, closed, deposits, settings] = await Promise.all([getPortfolioState("ai_sim"), getClosedPositions("ai_sim", 100), aiDeposits(), getSettings()]);
|
||||||
const [state, closed, signals] = await Promise.all([
|
const perf = aiPerformance(state, deposits);
|
||||||
getPortfolioState("ai_sim"),
|
|
||||||
getClosedPositions("ai_sim", 100),
|
|
||||||
db.select().from(schema.signals).orderBy(desc(schema.signals.createdAt)).limit(20),
|
|
||||||
]);
|
|
||||||
const perf = (state.equity / state.initialCash - 1) * 100;
|
|
||||||
const wins = closed.filter((p) => (p.pnlEur ?? 0) > 0).length;
|
const wins = closed.filter((p) => (p.pnlEur ?? 0) > 0).length;
|
||||||
const fees = closed.reduce((s, p) => s + p.feesEur, 0);
|
const fees = closed.reduce((s, p) => s + p.feesEur, 0);
|
||||||
|
const stuck = aiSimStuck(state);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title="La cagnotte de l'IA" subtitle="200 € virtuels, gérés seuls par l'IA avec exactement les règles du réel.">
|
<>
|
||||||
<Card title="Résultat">
|
<Card tone="pot">
|
||||||
<div className="flex items-end justify-between">
|
<p className="text-[15px] text-muted">Sa cagnotte aujourd'hui</p>
|
||||||
<p className="num text-3xl font-semibold">{eur(state.equity)}</p>
|
<div className="mt-1 flex items-end justify-between gap-3">
|
||||||
<p className={`num text-lg font-semibold ${perf >= 0 ? "text-accent" : "text-danger"}`}>{pct(perf)}</p>
|
<p className="amount text-[3rem] font-bold">{eur(state.equity)}</p>
|
||||||
|
<p className="amount pb-1 text-[1.4rem]">
|
||||||
|
<Delta value={perf.pct}>{pct(perf.pct)}</Delta>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="num mt-3 grid grid-cols-3 gap-2 text-center text-sm">
|
<p className="mt-2 text-[14px] text-muted">
|
||||||
<div className="rounded-xl bg-surface-2 p-2">
|
Sur {eur(perf.contributed, 0)} reçus : 200 € au départ le {formatDateFr(settings.simStartDate)}
|
||||||
<p className="text-lg font-semibold">{closed.length}</p>
|
{deposits.length ? `, puis ${deposits.length} versement${deposits.length > 1 ? "s" : ""} de ${settings.realMonthlyDeposit} €` : ""}.
|
||||||
<p className="text-xs text-muted">trades</p>
|
</p>
|
||||||
</div>
|
<div className="mt-5 grid grid-cols-3 gap-3">
|
||||||
<div className="rounded-xl bg-surface-2 p-2">
|
<Stat label="trades finis">{closed.length}</Stat>
|
||||||
<p className="text-lg font-semibold">{closed.length ? Math.round((wins / closed.length) * 100) : 0} %</p>
|
<Stat label="gagnants">{closed.length ? `${Math.round((wins / closed.length) * 100)} %` : "–"}</Stat>
|
||||||
<p className="text-xs text-muted">gagnants</p>
|
<Stat label="frais payés">{eur(fees, 0)}</Stat>
|
||||||
</div>
|
|
||||||
<div className="rounded-xl bg-surface-2 p-2">
|
|
||||||
<p className="text-lg font-semibold">{eur(fees, 0)}</p>
|
|
||||||
<p className="text-xs text-muted">frais payés</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Position en cours">
|
{stuck && (
|
||||||
|
<Card tone="danger" title="L'IA ne peut plus acheter">
|
||||||
|
<p className="text-[15px] leading-relaxed">
|
||||||
|
Il lui reste {eur(state.cash)}, sous le minimum de {MIN_POSITION_EUR} € par position. Elle reprendra après le prochain versement de {settings.realMonthlyDeposit} €, le{" "}
|
||||||
|
{settings.realDepositDay} du mois. Si tu estimes qu'elle a échoué, remets-la à zéro.
|
||||||
|
</p>
|
||||||
|
<div className="mt-4">
|
||||||
|
<ResetAi stuck />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Card title="Ce qu'elle détient">
|
||||||
<PositionList positions={state.positions} />
|
<PositionList positions={state.positions} />
|
||||||
{state.pendingOrders.length > 0 && (
|
{state.pendingOrders.length > 0 && (
|
||||||
<div className="mt-3">
|
<div className="mt-4 border-t border-line pt-3">
|
||||||
|
<p className="mb-1 text-[14px] font-semibold text-muted">Ordres en attente</p>
|
||||||
<PendingOrders orders={state.pendingOrders} />
|
<PendingOrders orders={state.pendingOrders} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Dernières analyses">
|
<Card title="Ses trades terminés">
|
||||||
{!signals.length && <Empty>Aucune analyse pour l'instant. Elles arrivent chaque soir.</Empty>}
|
|
||||||
<ul className="flex flex-col gap-3">
|
|
||||||
{signals.map((s) => (
|
|
||||||
<li key={s.id} className="rounded-xl bg-surface-2 p-3 text-sm">
|
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
|
||||||
<span className="font-semibold">{s.name}</span>
|
|
||||||
<Badge tone={s.decision === "buy" ? "accent" : "neutral"}>{s.decision === "buy" ? "Achat" : "On passe"}</Badge>
|
|
||||||
<span className="text-xs text-muted">
|
|
||||||
{s.date} · confiance {s.confidence} %
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p className="mt-2 leading-relaxed">{s.thesis}</p>
|
|
||||||
<p className="mt-1 leading-relaxed text-muted">⚠️ {s.risks}</p>
|
|
||||||
{s.riskVerdict && s.riskVerdict !== "accepté" && <p className="mt-1 text-xs text-warn">Contrôle des risques : {s.riskVerdict}</p>}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card title="Trades terminés">
|
|
||||||
<ClosedList positions={closed} />
|
<ClosedList positions={closed} />
|
||||||
</Card>
|
</Card>
|
||||||
</Page>
|
|
||||||
|
{!stuck && (
|
||||||
|
<Card title="Repartir de zéro">
|
||||||
|
<p className="mb-4 text-[15px] leading-relaxed text-muted">
|
||||||
|
Chaque mois, l'IA reçoit le même versement que ton compte-titres ({settings.realMonthlyDeposit} €), comme en vrai. Tu peux aussi effacer sa simulation et lui redonner
|
||||||
|
200 €.
|
||||||
|
</p>
|
||||||
|
<ResetAi stuck={false} />
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function Signals() {
|
||||||
|
await connection();
|
||||||
|
const db = await getDb();
|
||||||
|
const signals = await db.select().from(schema.signals).orderBy(desc(schema.signals.createdAt)).limit(20);
|
||||||
|
return (
|
||||||
|
<Card title="Ses dernières analyses">
|
||||||
|
{!signals.length && <Empty>Aucune analyse pour l'instant. Elles arrivent chaque soir de semaine, 30 minutes avant ton rendez-vous.</Empty>}
|
||||||
|
<ul className="-my-1 divide-y divide-line">
|
||||||
|
{signals.map((s) => (
|
||||||
|
<li key={s.id} className="py-4">
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<span className="font-semibold">{s.name}</span>
|
||||||
|
<Badge tone={s.decision === "buy" ? "gain" : "neutral"}>{s.decision === "buy" ? "Achète" : "Passe son tour"}</Badge>
|
||||||
|
<span className="text-[13px] text-muted">
|
||||||
|
{formatDateFr(s.date)}, confiance {s.confidence} %
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="mt-2 text-[15px] leading-relaxed">{s.thesis}</p>
|
||||||
|
<p className="mt-1.5 text-[14px] leading-relaxed text-muted">Risques : {s.risks}</p>
|
||||||
|
{s.riskVerdict && s.riskVerdict !== "accepté" && <p className="mt-1.5 text-[13px] text-warn">Refusé par le contrôle des risques : {s.riskVerdict}</p>}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AiPage() {
|
export default function AiPage() {
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<PageSkeleton title={"La cagnotte de l'IA"} />}>
|
<Page title="La cagnotte de l'IA" subtitle="De l'argent virtuel que l'IA gère seule, avec exactement les règles du réel.">
|
||||||
<AiPageContent />
|
<Suspense fallback={<CardSkeleton height="h-44" />}>
|
||||||
</Suspense>
|
<Pot />
|
||||||
|
</Suspense>
|
||||||
|
<Suspense fallback={<CardSkeleton title="Ses dernières analyses" height="h-48" />}>
|
||||||
|
<Signals />
|
||||||
|
</Suspense>
|
||||||
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { connection } from "next/server";
|
|||||||
import { ActionCard } from "@/components/action-card";
|
import { ActionCard } from "@/components/action-card";
|
||||||
import { FindIdeas } from "@/components/find-ideas";
|
import { FindIdeas } from "@/components/find-ideas";
|
||||||
import { SettingsLink } from "@/components/nav";
|
import { SettingsLink } from "@/components/nav";
|
||||||
import { Badge, Card, CardSkeleton, Delta, Empty, Page, primaryBtn } from "@/components/ui";
|
import { Badge, Card, CardSkeleton, Delta, Empty, primaryBtn } from "@/components/ui";
|
||||||
import { aiEnabled, getAiSpend } from "@/lib/ai";
|
import { aiEnabled, getAiSpend } from "@/lib/ai";
|
||||||
import { getLatestRendezvous, getPendingAdhocCards } from "@/lib/cards";
|
import { getLatestRendezvous, getPendingAdhocCards } from "@/lib/cards";
|
||||||
import { eur, pct, signedEur } from "@/lib/format";
|
import { eur, pct, signedEur } from "@/lib/format";
|
||||||
@ -18,37 +18,120 @@ function hhmm(minutes: number) {
|
|||||||
return `${String(Math.floor(minutes / 60)).padStart(2, "0")}h${String(minutes % 60).padStart(2, "0")}`;
|
return `${String(Math.floor(minutes / 60)).padStart(2, "0")}h${String(minutes % 60).padStart(2, "0")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ce que tu as à faire : seulement la base de données, donc instantané. */
|
/** En-tête : la date du jour, connue sans attendre aucune donnée. */
|
||||||
|
async function Today() {
|
||||||
|
await connection();
|
||||||
|
const d = formatDateFr(parisDate());
|
||||||
|
return <p className="text-[15px] font-semibold text-muted">{d.charAt(0).toUpperCase() + d.slice(1)}</p>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Le patrimoine et sa répartition : à gauche ce qui est à l'abri (PEA), à droite la cagnotte
|
||||||
|
* que l'IA fait travailler (compte-titres). C'est toute l'idée de l'app en une barre.
|
||||||
|
*/
|
||||||
|
async function Wealth() {
|
||||||
|
await connection();
|
||||||
|
const settings = await getSettings();
|
||||||
|
const [real, pea] = await Promise.all([getPortfolioState("real"), getPea(settings)]);
|
||||||
|
const safe = pea?.value ?? 0;
|
||||||
|
const pot = real.equity;
|
||||||
|
const total = safe + pot;
|
||||||
|
const safeShare = total > 0 ? (safe / total) * 100 : 50;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section aria-label="Mon patrimoine" className="pb-2">
|
||||||
|
<p className="text-[15px] text-muted">Mon patrimoine</p>
|
||||||
|
<p className="amount mt-1 text-[3.4rem] font-bold">{eur(total)}</p>
|
||||||
|
|
||||||
|
<div className="mt-5 flex h-3.5 gap-1 overflow-hidden rounded-full" aria-hidden>
|
||||||
|
{total > 0 ? (
|
||||||
|
<>
|
||||||
|
<div className="bar-fill shrink-0 rounded-full bg-accent" style={{ width: `${safeShare}%` }} />
|
||||||
|
<div className="bar-fill flex-1 rounded-full bg-pot" style={{ animationDelay: "120ms" }} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="flex-1 rounded-full bg-surface-2" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-4 grid grid-cols-2 gap-4">
|
||||||
|
<Link href="/reel#pea" className="block">
|
||||||
|
<p className="flex items-center gap-2 text-[14px] font-semibold">
|
||||||
|
<span className="h-2.5 w-2.5 rounded-full bg-accent" aria-hidden />À l'abri
|
||||||
|
</p>
|
||||||
|
<p className="amount mt-1.5 text-[1.5rem] font-semibold">{eur(safe, 0)}</p>
|
||||||
|
<p className="mt-0.5 text-[13px] text-muted">
|
||||||
|
{pea && pea.invested > 0 ? (
|
||||||
|
<>
|
||||||
|
PEA S&P 500, <Delta value={pea.gain}>{signedEur(pea.gain)}</Delta>
|
||||||
|
</>
|
||||||
|
) : settings.peaPlan ? (
|
||||||
|
"PEA, premier achat à venir"
|
||||||
|
) : (
|
||||||
|
"PEA à configurer"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
<Link href="/reel" className="block">
|
||||||
|
<p className="flex items-center gap-2 text-[14px] font-semibold">
|
||||||
|
<span className="h-2.5 w-2.5 rounded-full bg-pot" aria-hidden />
|
||||||
|
Cagnotte qui travaille
|
||||||
|
</p>
|
||||||
|
<p className="amount mt-1.5 text-[1.5rem] font-semibold">{eur(pot, 0)}</p>
|
||||||
|
<p className="mt-0.5 text-[13px] text-muted">
|
||||||
|
Compte-titres, {real.positions.length ? `${real.positions.length} position${real.positions.length > 1 ? "s" : ""}` : `${eur(real.cash, 0)} en attente`}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function WealthSkeleton() {
|
||||||
|
return (
|
||||||
|
<section aria-busy="true" className="pb-2">
|
||||||
|
<p className="text-[15px] text-muted">Mon patrimoine</p>
|
||||||
|
<div className="skeleton mt-2 h-12 w-56 rounded-xl" />
|
||||||
|
<div className="skeleton mt-5 h-3.5 rounded-full" />
|
||||||
|
<div className="mt-4 grid grid-cols-2 gap-4">
|
||||||
|
<div className="skeleton h-16 rounded-xl" />
|
||||||
|
<div className="skeleton h-16 rounded-xl" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ce que tu as à faire : seulement la base de données, donc rapide. */
|
||||||
async function Todo() {
|
async function Todo() {
|
||||||
await connection();
|
await connection();
|
||||||
const [settings, rdv, adhoc, ideas] = await Promise.all([getSettings(), getLatestRendezvous(), getPendingAdhocCards(), getIdeas()]);
|
const [settings, rdv, adhoc, ideas] = await Promise.all([getSettings(), getLatestRendezvous(), getPendingAdhocCards(), getIdeas()]);
|
||||||
const isToday = rdv?.date === parisDate();
|
const isToday = rdv?.date === parisDate();
|
||||||
const cards = [...(rdv?.cards ?? []), ...adhoc];
|
const cards = [...(rdv?.cards ?? []), ...adhoc.filter((c) => c.rendezvousId !== rdv?.id)];
|
||||||
const pending = cards.filter((c) => c.status === "pending");
|
const pending = cards.filter((c) => c.status === "pending");
|
||||||
const shown = isToday ? cards : pending;
|
const shown = isToday ? cards.filter((c) => c.status !== "expired") : pending;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{!settings.trAccountOpenedAt && (
|
{!settings.trAccountOpenedAt && (
|
||||||
<Card tone="warn" title="À configurer">
|
<Card tone="pot" title="Dis à l'app où tu en es">
|
||||||
<p className="text-sm leading-relaxed">
|
<p className="text-[15px] leading-relaxed">
|
||||||
Indique à l'app où en est ton compte Trade Republic (versements, PEA, actions déjà achetées). Ça prend 1 minute, et aucun identifiant n'est demandé.
|
Versements, PEA, actions déjà achetées : une minute suffit, et aucun identifiant Trade Republic n'est demandé.
|
||||||
</p>
|
</p>
|
||||||
<Link href="/reel" className={`${primaryBtn} mt-3 w-full`}>
|
<Link href="/reel" className={`${primaryBtn} mt-4 w-full`}>
|
||||||
Configurer mon compte
|
Configurer mon compte
|
||||||
</Link>
|
</Link>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
title={rdv ? `Rendez-vous · ${isToday ? "aujourd'hui" : formatDateFr(rdv.date)}` : "Rendez-vous du soir"}
|
title={rdv && !isToday ? `Rendez-vous du ${formatDateFr(rdv.date)}` : "Ton rendez-vous du soir"}
|
||||||
tone={pending.length ? "accent" : undefined}
|
tone={pending.length ? "accent" : undefined}
|
||||||
action={pending.length ? <Badge tone="accent">{pending.length} à traiter</Badge> : undefined}
|
action={pending.length ? <Badge tone="accent">{pending.length} à traiter</Badge> : undefined}
|
||||||
>
|
>
|
||||||
{rdv?.summary && isToday && <p className="mb-3 whitespace-pre-line text-sm leading-relaxed">{rdv.summary}</p>}
|
{rdv?.summary && isToday && <p className="mb-4 whitespace-pre-line text-[15px] leading-relaxed">{rdv.summary}</p>}
|
||||||
{!shown.length && (
|
{!shown.length && (
|
||||||
<Empty>
|
<Empty>
|
||||||
Rien à faire pour l'instant. Ton prochain rendez-vous arrive à {hhmm(settings.rendezvousMinutes)} (en semaine), ou lance une recherche tout de suite.
|
Rien à faire pour l'instant. L'IA prépare ton prochain rendez-vous pour {hhmm(settings.rendezvousMinutes)}, en semaine. Tu peux aussi lancer une recherche maintenant.
|
||||||
</Empty>
|
</Empty>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
@ -56,63 +139,37 @@ async function Todo() {
|
|||||||
<ActionCard key={c.id} id={c.id} kind={c.kind} training={c.training} status={c.status} symbol={c.symbol} payload={c.payload} />
|
<ActionCard key={c.id} id={c.id} kind={c.kind} training={c.training} status={c.status} symbol={c.symbol} payload={c.payload} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3">
|
<div className="mt-4">
|
||||||
<FindIdeas />
|
<FindIdeas />
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{!pending.length && ideas && ideas.items.length > 0 && (
|
{!pending.length && ideas && ideas.items.length > 0 && (
|
||||||
<Card title="Idées à tester" action={<Link href="/actions" className="text-sm font-medium text-accent">Toutes les actions</Link>}>
|
<Card
|
||||||
<ul className="flex flex-col gap-2">
|
title="Idées à tester"
|
||||||
|
action={
|
||||||
|
<Link href="/actions" className="text-[14px] font-semibold text-accent">
|
||||||
|
Toutes les actions
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ul className="-my-1 divide-y divide-line">
|
||||||
{ideas.items.slice(0, 3).map((i) => (
|
{ideas.items.slice(0, 3).map((i) => (
|
||||||
<li key={i.symbol}>
|
<li key={i.symbol}>
|
||||||
<Link href={`/actions/${encodeURIComponent(i.symbol)}?montant=150&stop=7&objectif=12`} className="flex items-center justify-between gap-3 rounded-xl bg-surface-2 px-3 py-2.5">
|
<Link href={`/actions/${encodeURIComponent(i.symbol)}?montant=150&stop=7&objectif=12`} className="flex items-center justify-between gap-3 py-3">
|
||||||
<span className="font-medium">{i.name}</span>
|
<span className="font-semibold">{i.name}</span>
|
||||||
<span className="num text-xs text-muted">
|
<span className="num shrink-0 text-[14px] text-danger">{pct(i.pullbackPct)} cette semaine</span>
|
||||||
tendance +{i.trendPct} % · repli {i.pullbackPct} %
|
|
||||||
</span>
|
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
<p className="mt-2 text-xs text-muted">Repérées par une règle simple (sans IA). À essayer dans ton bac à sable.</p>
|
<p className="mt-3 text-[13px] leading-relaxed text-muted">Des actions en hausse de fond qui viennent de reculer. Repérées par une règle simple, sans IA : essaie-les dans ton bac à sable.</p>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Patrimoine : dépend des cours (PEA + compte-titres). */
|
|
||||||
async function Wealth() {
|
|
||||||
await connection();
|
|
||||||
const settings = await getSettings();
|
|
||||||
const [real, pea] = await Promise.all([getPortfolioState("real"), getPea(settings)]);
|
|
||||||
const total = (pea?.value ?? 0) + real.equity;
|
|
||||||
return (
|
|
||||||
<Card title="Mon patrimoine">
|
|
||||||
<p className="num text-3xl font-semibold tracking-tight">{eur(total)}</p>
|
|
||||||
<div className="mt-4 grid grid-cols-2 gap-3 text-sm">
|
|
||||||
<Link href="/reel#pea" className="rounded-xl bg-surface-2 p-3">
|
|
||||||
<p className="text-muted">PEA · cœur</p>
|
|
||||||
<p className="num mt-1 text-lg font-semibold">{eur(pea?.value ?? 0)}</p>
|
|
||||||
{pea && pea.invested > 0 ? (
|
|
||||||
<p className="text-xs">
|
|
||||||
<Delta value={pea.gain}>{signedEur(pea.gain)}</Delta> <span className="text-muted">sur {eur(pea.invested, 0)}</span>
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<p className="text-xs text-muted">{settings.peaPlan ? "Premier achat à venir" : "Pas encore configuré ›"}</p>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
<Link href="/reel" className="rounded-xl bg-surface-2 p-3">
|
|
||||||
<p className="text-muted">Compte-titres</p>
|
|
||||||
<p className="num mt-1 text-lg font-semibold">{eur(real.equity)}</p>
|
|
||||||
<p className="text-xs text-muted">{real.positions.length ? `${real.positions.length} position(s)` : `${eur(real.cash, 0)} en liquidités ›`}</p>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Classement et critères du mode réel : dépendent de l'indice S&P 500. */
|
/** Classement et critères du mode réel : dépendent de l'indice S&P 500. */
|
||||||
async function Progress() {
|
async function Progress() {
|
||||||
await connection();
|
await connection();
|
||||||
@ -123,55 +180,69 @@ async function Progress() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card title="Classement" action={<Link href="/ia" className="text-sm font-medium text-accent">Détails</Link>}>
|
<Card
|
||||||
<ol className="flex flex-col gap-2">
|
title="Qui gagne ?"
|
||||||
|
action={
|
||||||
|
<Link href="/ia" className="text-[14px] font-semibold text-accent">
|
||||||
|
Voir l'IA
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ol className="-my-1 divide-y divide-line">
|
||||||
{board.map((row, i) => (
|
{board.map((row, i) => (
|
||||||
<li key={row.label} className="flex items-center justify-between rounded-xl bg-surface-2 px-3 py-2.5">
|
<li key={row.label} className="flex items-center gap-3 py-3">
|
||||||
<span className="font-medium">
|
<span className={`amount w-6 text-[1.4rem] font-bold ${i === 0 ? "text-accent" : "text-muted"}`}>{i + 1}</span>
|
||||||
{["🥇", "🥈", "🥉"][i]} {row.label}
|
<span className="min-w-0 flex-1">
|
||||||
<span className="ml-2 text-xs font-normal text-muted">{row.detail}</span>
|
<span className="block font-semibold">{row.label}</span>
|
||||||
|
<span className="block text-[13px] text-muted">{row.detail}</span>
|
||||||
</span>
|
</span>
|
||||||
<Delta value={row.pct}>{pct(row.pct)}</Delta>
|
<Delta value={row.pct}>{pct(row.pct)}</Delta>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
<p className="mt-3 text-xs text-muted">L'IA et toi partez chacun de 200 € virtuels. Le S&P 500, c'est ce que tu aurais gagné sans rien faire.</p>
|
<p className="mt-3 text-[13px] leading-relaxed text-muted">
|
||||||
|
L'IA et toi partez de 200 € virtuels. Le S&P 500 montre ce que tu aurais gagné sans rien faire.
|
||||||
|
</p>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Passage à l'argent réel" action={gate.realActive ? <Badge tone="accent">Débloqué</Badge> : <Badge tone="warn">{met}/5 critères</Badge>}>
|
<Card title="Passer à l'argent réel" action={gate.realActive ? <Badge tone="gain">Débloqué</Badge> : <Badge tone="pot">{met} critères sur 5</Badge>}>
|
||||||
{settings.realLockedReason && <p className="mb-3 text-sm text-danger">Coupe-circuit : {settings.realLockedReason}</p>}
|
{settings.realLockedReason && <p className="mb-3 text-[15px] text-danger">Coupe-circuit : {settings.realLockedReason}</p>}
|
||||||
<div className="mb-3 h-2 overflow-hidden rounded-full bg-surface-2">
|
<div className="mb-4 grid grid-cols-5 gap-1.5" aria-hidden>
|
||||||
<div className="h-full rounded-full bg-accent" style={{ width: `${(met / 5) * 100}%` }} />
|
{gate.criteria.map((c) => (
|
||||||
|
<div key={c.label} className={`h-2 rounded-full ${c.ok ? "bg-gain" : "bg-surface-2"}`} />
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
<details>
|
<ul className="-my-1 divide-y divide-line text-[15px]">
|
||||||
<summary className="cursor-pointer text-sm font-medium text-accent">Voir les 5 critères</summary>
|
{gate.criteria.map((c) => (
|
||||||
<ul className="mt-2 flex flex-col gap-2 text-sm">
|
<li key={c.label} className="flex items-center justify-between gap-3 py-2.5">
|
||||||
{gate.criteria.map((c) => (
|
<span className="flex items-center gap-2">
|
||||||
<li key={c.label} className="flex items-center justify-between gap-3">
|
<span className={`h-2 w-2 shrink-0 rounded-full ${c.ok ? "bg-gain" : "bg-line"}`} aria-hidden />
|
||||||
<span>
|
{c.label}
|
||||||
{c.ok ? "✅" : "⏳"} {c.label}
|
</span>
|
||||||
</span>
|
<span className="num shrink-0 text-right text-[14px] text-muted">
|
||||||
<span className="num shrink-0 text-muted">
|
<span className="block text-ink">{c.value}</span>
|
||||||
{c.value} <span className="text-xs">/ {c.target}</span>
|
<span className="block text-[12px]">objectif {c.target}</span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Budget IA ce mois-ci">
|
<Card title="Budget IA du mois">
|
||||||
{aiEnabled() ? (
|
{aiEnabled() ? (
|
||||||
<>
|
<>
|
||||||
<div className="h-2 overflow-hidden rounded-full bg-surface-2">
|
<p className="amount text-[1.6rem] font-semibold">
|
||||||
|
{spend.monthUsd.toFixed(2)} $ <span className="text-[1rem] font-normal text-muted">sur {settings.aiMonthlyBudgetUsd} $</span>
|
||||||
|
</p>
|
||||||
|
<div className="mt-3 h-2 overflow-hidden rounded-full bg-surface-2">
|
||||||
<div className="h-full rounded-full bg-accent" style={{ width: `${Math.min(100, (spend.monthUsd / settings.aiMonthlyBudgetUsd) * 100)}%` }} />
|
<div className="h-full rounded-full bg-accent" style={{ width: `${Math.min(100, (spend.monthUsd / settings.aiMonthlyBudgetUsd) * 100)}%` }} />
|
||||||
</div>
|
</div>
|
||||||
<p className="num mt-2 text-sm text-muted">
|
<p className="mt-2 text-[13px] text-muted">Ce coût est déduit des résultats de l'IA avant de la comparer au S&P 500.</p>
|
||||||
{spend.monthUsd.toFixed(2)} $ sur {settings.aiMonthlyBudgetUsd} $ · coût déduit des résultats de l'IA
|
|
||||||
</p>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Empty>IA pas encore branchée : ajoute ta clé Anthropic (ANTHROPIC_API_KEY, voir le README). En attendant, l'app te propose des idées sans IA.</Empty>
|
<Empty>
|
||||||
|
L'IA n'est pas encore branchée : ajoute ta clé Anthropic (ANTHROPIC_API_KEY, voir le README). En attendant, l'app te propose des idées sans IA.
|
||||||
|
</Empty>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
@ -180,16 +251,22 @@ async function Progress() {
|
|||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<Page title="Cagnotte 🌱" subtitle="Ce qu'il y a à faire aujourd'hui." action={<SettingsLink />}>
|
<main className="mx-auto flex w-full max-w-lg flex-col gap-4 px-4 pb-32 pt-[max(env(safe-area-inset-top),1.5rem)]">
|
||||||
<Suspense fallback={<CardSkeleton title="Rendez-vous du soir" height="h-32" />}>
|
<header className="flex items-center justify-between gap-3">
|
||||||
<Todo />
|
<Suspense fallback={<p className="text-[15px] font-semibold text-muted">Aujourd'hui</p>}>
|
||||||
</Suspense>
|
<Today />
|
||||||
<Suspense fallback={<CardSkeleton title="Mon patrimoine" height="h-28" />}>
|
</Suspense>
|
||||||
|
<SettingsLink />
|
||||||
|
</header>
|
||||||
|
<Suspense fallback={<WealthSkeleton />}>
|
||||||
<Wealth />
|
<Wealth />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Suspense fallback={<CardSkeleton title="Classement" height="h-36" />}>
|
<Suspense fallback={<CardSkeleton title="Ton rendez-vous du soir" height="h-32" />}>
|
||||||
|
<Todo />
|
||||||
|
</Suspense>
|
||||||
|
<Suspense fallback={<CardSkeleton title="Qui gagne ?" height="h-36" />}>
|
||||||
<Progress />
|
<Progress />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Page>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,15 +29,12 @@ async function AccountContent() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card>
|
<Card
|
||||||
<p className="text-sm leading-relaxed text-muted">
|
title="Mon compte-titres"
|
||||||
🔒 Trade Republic n'offre pas de connexion pour les applications : l'app ne se branche jamais à ton compte et ne te demandera jamais tes identifiants.
|
tone={configured ? undefined : "pot"}
|
||||||
Tu lui indiques ce que tu as, elle fait les calculs et te dit quoi faire.
|
action={configured ? <Badge tone="gain">Configuré</Badge> : <Badge tone="pot">À faire</Badge>}
|
||||||
</p>
|
>
|
||||||
</Card>
|
{configured && <p className="-mt-2 mb-4 text-[13px] text-muted">Ouvert le {formatDateFr(settings.trAccountOpenedAt!)}.</p>}
|
||||||
|
|
||||||
<Card title="1 · Mon compte-titres" tone={configured ? undefined : "warn"} action={configured ? <Badge tone="accent">configuré</Badge> : <Badge tone="warn">à faire</Badge>}>
|
|
||||||
{configured && <p className="mb-3 text-xs text-muted">Ouvert le {formatDateFr(settings.trAccountOpenedAt!)}.</p>}
|
|
||||||
<AccountForm
|
<AccountForm
|
||||||
openedAt={settings.trAccountOpenedAt}
|
openedAt={settings.trAccountOpenedAt}
|
||||||
monthly={settings.realMonthlyDeposit}
|
monthly={settings.realMonthlyDeposit}
|
||||||
@ -47,43 +44,59 @@ async function AccountContent() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Ma cagnotte réelle" action={realActive ? <Badge tone="accent">Mode réel actif</Badge> : <Badge tone="warn">Simulation d'abord</Badge>}>
|
<Card>
|
||||||
<div className="flex items-end justify-between">
|
<div className="mb-1 flex items-center justify-between gap-3">
|
||||||
<p className="num text-3xl font-semibold">{eur(state.equity)}</p>
|
<p className="flex items-center gap-2 text-[15px] text-muted">
|
||||||
{deposited > 0 && <Delta value={gain}>{signedEur(gain)}</Delta>}
|
<span className="h-2.5 w-2.5 rounded-full bg-pot" aria-hidden />
|
||||||
|
Ma cagnotte réelle
|
||||||
|
</p>
|
||||||
|
{realActive ? <Badge tone="gain">Mode réel actif</Badge> : <Badge tone="pot">Simulation d'abord</Badge>}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 grid grid-cols-3 gap-2 text-sm">
|
<div className="flex items-end justify-between gap-3">
|
||||||
<Stat label="liquidités">{eur(state.cash, 0)}</Stat>
|
<p className="amount text-[2.8rem] font-bold">{eur(state.equity)}</p>
|
||||||
|
{deposited > 0 && (
|
||||||
|
<p className="amount pb-1 text-[1.3rem]">
|
||||||
|
<Delta value={gain}>{signedEur(gain)}</Delta>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="mt-5 grid grid-cols-3 gap-3">
|
||||||
|
<Stat label="à investir">{eur(state.cash, 0)}</Stat>
|
||||||
<Stat label="versés">{eur(deposited, 0)}</Stat>
|
<Stat label="versés">{eur(deposited, 0)}</Stat>
|
||||||
<Stat label="partis au PEA">{eur(toPea, 0)}</Stat>
|
<Stat label="mis à l'abri">{eur(toPea, 0)}</Stat>
|
||||||
</div>
|
</div>
|
||||||
{!realActive && (
|
{!realActive && (
|
||||||
<p className="mt-3 text-xs leading-relaxed text-muted">
|
<p className="mt-4 text-[14px] leading-relaxed text-muted">
|
||||||
Tant que l'IA n'a pas prouvé en simulation qu'elle bat le S&P 500, elle ne te propose pas de trade réel : ton argent attend sur le compte. Tu peux quand même
|
Tant que l'IA n'a pas prouvé en simulation qu'elle bat le S&P 500, elle ne te propose aucun trade réel : ton argent attend sur le compte. Tu peux
|
||||||
enregistrer ici ce que tu fais de ton côté.
|
quand même noter ici ce que tu fais de ton côté.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<div className="mt-4">
|
<div className="mt-5 border-t border-line pt-4">
|
||||||
<CashForms cash={state.cash} />
|
<CashForms cash={state.cash} />
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="2 · Mes actions chez Trade Republic">
|
<Card title="Mes actions chez Trade Republic">
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-4">
|
||||||
<RealPositions positions={state.positions} />
|
<RealPositions positions={state.positions} />
|
||||||
<AddHolding />
|
<AddHolding />
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Suspense fallback={<CardSkeleton title="3 · Mon PEA" height="h-40" />}>
|
<Suspense fallback={<CardSkeleton title="Mon PEA" height="h-40" />}>
|
||||||
<PeaSection />
|
<PeaSection />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
{closed.length > 0 && (
|
{closed.length > 0 && (
|
||||||
<Card title="Historique réel">
|
<Card title="Mes trades réels terminés">
|
||||||
<ClosedList positions={closed} />
|
<ClosedList positions={closed} />
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<p className="px-1 text-[13px] leading-relaxed text-muted">
|
||||||
|
Trade Republic ne permet à aucune application de se connecter à ton compte. L'app ne te demandera donc jamais tes identifiants : tu lui dis ce que tu as, elle fait les
|
||||||
|
calculs et te dit quoi faire.
|
||||||
|
</p>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -94,23 +107,32 @@ async function PeaSection() {
|
|||||||
const plan = settings.peaPlan ?? defaultPeaPlan(parisDate());
|
const plan = settings.peaPlan ?? defaultPeaPlan(parisDate());
|
||||||
const pea = await getPea(settings);
|
const pea = await getPea(settings);
|
||||||
return (
|
return (
|
||||||
<section id="pea">
|
<section id="pea" className="scroll-mt-6">
|
||||||
<Card title="3 · Mon PEA (cœur)">
|
<Card>
|
||||||
|
<p className="mb-1 flex items-center gap-2 text-[15px] text-muted">
|
||||||
|
<span className="h-2.5 w-2.5 rounded-full bg-accent" aria-hidden />
|
||||||
|
Mon PEA, la part à l'abri
|
||||||
|
</p>
|
||||||
{pea && (
|
{pea && (
|
||||||
<div className="mb-4 grid grid-cols-3 gap-2 text-sm">
|
<>
|
||||||
<Stat label="valeur">{eur(pea.value, 0)}</Stat>
|
<p className="amount text-[2.4rem] font-bold">{eur(pea.value)}</p>
|
||||||
<Stat label="versés">{eur(pea.invested, 0)}</Stat>
|
<div className="mb-5 mt-5 grid grid-cols-3 gap-3">
|
||||||
<Stat label="parts">{pea.shares.toLocaleString("fr-FR", { maximumFractionDigits: 3 })}</Stat>
|
<Stat label="versés">{eur(pea.invested, 0)}</Stat>
|
||||||
</div>
|
<Stat label="gain">{signedEur(pea.gain)}</Stat>
|
||||||
|
<Stat label="parts d'ETF">{pea.shares.toLocaleString("fr-FR", { maximumFractionDigits: 3 })}</Stat>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<PeaForm
|
<div className={pea ? "border-t border-line pt-4" : "mt-3"}>
|
||||||
has={Boolean(settings.peaPlan)}
|
<PeaForm
|
||||||
symbol={plan.etfSymbol}
|
has={Boolean(settings.peaPlan)}
|
||||||
amount={plan.monthlyAmount}
|
symbol={plan.etfSymbol}
|
||||||
day={plan.dayOfMonth}
|
amount={plan.monthlyAmount}
|
||||||
start={plan.startDate}
|
day={plan.dayOfMonth}
|
||||||
calibration={plan.calibration?.shares ?? null}
|
start={plan.startDate}
|
||||||
/>
|
calibration={plan.calibration?.shares ?? null}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
@ -118,7 +140,7 @@ async function PeaSection() {
|
|||||||
|
|
||||||
export default function AccountPage() {
|
export default function AccountPage() {
|
||||||
return (
|
return (
|
||||||
<Page title="Mon compte" subtitle="Ton compte Trade Republic : compte-titres (satellite) et PEA (cœur)." action={<SettingsLink />}>
|
<Page title="Mon compte" subtitle="Ton compte Trade Republic : le compte-titres où travaille la cagnotte, et le PEA où l'argent est à l'abri." action={<SettingsLink />}>
|
||||||
<Suspense fallback={<CardSkeleton height="h-64" />}>
|
<Suspense fallback={<CardSkeleton height="h-64" />}>
|
||||||
<AccountContent />
|
<AccountContent />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Suspense } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { logout, saveSettings } from "@/app/actions";
|
import { logout, saveSettings } from "@/app/actions";
|
||||||
|
import { BackLink } from "@/components/nav";
|
||||||
import { PushManager } from "@/components/push-manager";
|
import { PushManager } from "@/components/push-manager";
|
||||||
import { RunNow } from "@/components/run-now";
|
import { RunNow } from "@/components/run-now";
|
||||||
import { Card, CardSkeleton, inputCls, Page, primaryBtn, secondaryBtn } from "@/components/ui";
|
import { Card, CardSkeleton, inputCls, Page, primaryBtn, secondaryBtn } from "@/components/ui";
|
||||||
@ -11,10 +12,10 @@ import { getSettings } from "@/lib/settings";
|
|||||||
|
|
||||||
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
|
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<label className="flex flex-col gap-1 text-sm">
|
<label className="flex flex-col gap-1 text-[15px]">
|
||||||
<span className="font-medium">{label}</span>
|
<span className="font-semibold">{label}</span>
|
||||||
{children}
|
{children}
|
||||||
{hint && <span className="text-xs text-muted">{hint}</span>}
|
{hint && <span className="text-[13px] text-muted">{hint}</span>}
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -33,7 +34,7 @@ async function SettingsForm() {
|
|||||||
</Field>
|
</Field>
|
||||||
<Field
|
<Field
|
||||||
label="Budget IA mensuel ($)"
|
label="Budget IA mensuel ($)"
|
||||||
hint={aiEnabled() ? "L'IA s'arrête d'elle-même si le plafond est atteint." : "⚠️ Clé Anthropic absente : l'IA est en pause (les idées sans IA continuent)."}
|
hint={aiEnabled() ? "L'IA s'arrête d'elle-même si le plafond est atteint." : "Clé Anthropic absente : l'IA est en pause (les idées sans IA continuent)."}
|
||||||
>
|
>
|
||||||
<input className={inputCls} name="aiBudget" inputMode="decimal" defaultValue={s.aiMonthlyBudgetUsd} />
|
<input className={inputCls} name="aiBudget" inputMode="decimal" defaultValue={s.aiMonthlyBudgetUsd} />
|
||||||
</Field>
|
</Field>
|
||||||
@ -56,20 +57,24 @@ async function Diagnostics() {
|
|||||||
await connection();
|
await connection();
|
||||||
const d = await getDiagnostics();
|
const d = await getDiagnostics();
|
||||||
const row = (ok: boolean, label: string, value: React.ReactNode) => (
|
const row = (ok: boolean, label: string, value: React.ReactNode) => (
|
||||||
<li className="flex items-start justify-between gap-3">
|
<li className="flex items-center justify-between gap-3 py-2.5">
|
||||||
<span>
|
<span className="flex items-center gap-2">
|
||||||
{ok ? "✅" : "⚠️"} {label}
|
<span className={`h-2 w-2 shrink-0 rounded-full ${ok ? "bg-gain" : "bg-pot"}`} aria-hidden />
|
||||||
|
<span>
|
||||||
|
{label}
|
||||||
|
{!ok && <span className="sr-only"> (à vérifier)</span>}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="num shrink-0 text-right text-muted">{value}</span>
|
<span className="num shrink-0 text-right text-muted">{value}</span>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Card title="Diagnostic de l'IA">
|
<Card title="Diagnostic de l'IA">
|
||||||
<ul className="flex flex-col gap-2 text-sm">
|
<ul className="-my-1 divide-y divide-line text-[15px]">
|
||||||
{row(d.aiOn, "Clé Anthropic", d.aiOn ? "présente" : "absente")}
|
{row(d.aiOn, "Clé Anthropic", d.aiOn ? "présente" : "absente")}
|
||||||
{row(d.news48h > 0, "Actus des 48 dernières heures", d.news48h)}
|
{row(d.news48h > 0, "Actus des 48 dernières heures", d.news48h)}
|
||||||
{row(!d.aiOn || d.triagedTotal > 0, "Actus triées par l'IA", d.triagedTotal)}
|
{row(!d.aiOn || d.triagedTotal > 0, "Actus triées par l'IA (48 h)", d.triagedTotal)}
|
||||||
{row(d.positiveStrong > 0, "Actus positives ≥ 6/10", d.positiveStrong)}
|
{row(d.positiveStrong > 0, "Actus positives ≥ 6/10 (48 h)", d.positiveStrong)}
|
||||||
{row(d.signals.length > 0, "Analyses (7 derniers jours)", d.signals.length)}
|
{row(d.signals.length > 0, "Analyses (7 derniers jours)", d.signals.length)}
|
||||||
{row(true, "Coût IA ce mois-ci", `${d.spend.monthUsd.toFixed(2)} $`)}
|
{row(true, "Coût IA ce mois-ci", `${d.spend.monthUsd.toFixed(2)} $`)}
|
||||||
{row(Boolean(d.lastTick), "Dernière mise à jour", ago(d.lastTick?.at))}
|
{row(Boolean(d.lastTick), "Dernière mise à jour", ago(d.lastTick?.at))}
|
||||||
@ -77,8 +82,8 @@ async function Diagnostics() {
|
|||||||
</ul>
|
</ul>
|
||||||
{d.signals.length > 0 && (
|
{d.signals.length > 0 && (
|
||||||
<details className="mt-3">
|
<details className="mt-3">
|
||||||
<summary className="cursor-pointer text-sm font-medium text-accent">Décisions récentes de l'IA</summary>
|
<summary className="cursor-pointer text-[15px] font-semibold text-accent">Décisions récentes de l'IA</summary>
|
||||||
<ul className="mt-2 flex flex-col gap-1.5 text-xs">
|
<ul className="mt-2 flex flex-col gap-1.5 text-[13px]">
|
||||||
{d.signals.map((s) => (
|
{d.signals.map((s) => (
|
||||||
<li key={s.id}>
|
<li key={s.id}>
|
||||||
<b>{s.name}</b> · {s.decision === "buy" ? "achat" : "passe"} ({s.confidence} %)
|
<b>{s.name}</b> · {s.decision === "buy" ? "achat" : "passe"} ({s.confidence} %)
|
||||||
@ -92,8 +97,8 @@ async function Diagnostics() {
|
|||||||
(l, i) =>
|
(l, i) =>
|
||||||
l && (
|
l && (
|
||||||
<details key={i} className="mt-2">
|
<details key={i} className="mt-2">
|
||||||
<summary className="cursor-pointer text-sm font-medium text-accent">Journal {i ? "du rendez-vous" : "de la mise à jour"}</summary>
|
<summary className="cursor-pointer text-[15px] font-semibold text-accent">Journal {i ? "du rendez-vous" : "de la mise à jour"}</summary>
|
||||||
<ul className="mt-2 list-disc pl-5 text-xs text-muted">
|
<ul className="mt-2 list-disc pl-5 text-[13px] text-muted">
|
||||||
{l.log.length ? l.log.map((x, j) => <li key={j}>{x}</li>) : <li>Rien à signaler.</li>}
|
{l.log.length ? l.log.map((x, j) => <li key={j}>{x}</li>) : <li>Rien à signaler.</li>}
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
@ -107,11 +112,7 @@ export default function SettingsPage() {
|
|||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title="Réglages"
|
title="Réglages"
|
||||||
action={
|
action={<BackLink href="/" label="Ce soir" />}
|
||||||
<Link href="/" className="text-sm font-medium text-accent">
|
|
||||||
‹ Accueil
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Card title="Notifications iPhone">
|
<Card title="Notifications iPhone">
|
||||||
<PushManager />
|
<PushManager />
|
||||||
@ -122,7 +123,7 @@ export default function SettingsPage() {
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
<Card title="Compte Trade Republic et PEA">
|
<Card title="Compte Trade Republic et PEA">
|
||||||
<p className="mb-3 text-sm text-muted">Versements, liquidités, actions détenues et plan PEA se règlent dans l'onglet « Mon compte ».</p>
|
<p className="mb-3 text-[15px] text-muted">Versements, liquidités, actions détenues et plan PEA se règlent dans l'onglet « Mon compte ».</p>
|
||||||
<Link href="/reel" className={`${secondaryBtn} w-full`}>
|
<Link href="/reel" className={`${secondaryBtn} w-full`}>
|
||||||
Ouvrir Mon compte
|
Ouvrir Mon compte
|
||||||
</Link>
|
</Link>
|
||||||
@ -141,7 +142,7 @@ export default function SettingsPage() {
|
|||||||
Se déconnecter
|
Se déconnecter
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<p className="text-center text-xs leading-relaxed text-muted">
|
<p className="text-center text-[13px] leading-relaxed text-muted">
|
||||||
Outil d'aide à la décision, pas un conseil en investissement. Les performances passées ne préjugent pas des performances futures.
|
Outil d'aide à la décision, pas un conseil en investissement. Les performances passées ne préjugent pas des performances futures.
|
||||||
</p>
|
</p>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@ -1,34 +1,52 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cagnotte : un carnet d'épargne à deux compartiments.
|
||||||
|
* Cobalt « tampon » = ce qui est à l'abri (PEA) et les actions à faire.
|
||||||
|
* Ocre = la cagnotte que l'IA fait travailler.
|
||||||
|
* Vert / rouge = uniquement les gains et les pertes.
|
||||||
|
*/
|
||||||
:root {
|
:root {
|
||||||
--bg: #f6f5f1;
|
--bg: #f1f2f6;
|
||||||
--surface: #ffffff;
|
--surface: #ffffff;
|
||||||
--surface-2: #efede7;
|
--surface-2: #e8eaf1;
|
||||||
--border: #e2dfd6;
|
--border: #dcdfe8;
|
||||||
--text: #1b1a17;
|
--text: #151a30;
|
||||||
--muted: #6d6a62;
|
--muted: #5d6278;
|
||||||
--accent: #0f7b5f;
|
--accent: #2f44c9;
|
||||||
--accent-soft: #dcefe7;
|
--accent-soft: #e3e7fb;
|
||||||
--danger: #b4233c;
|
--accent-ink: #ffffff;
|
||||||
--danger-soft: #f8e1e5;
|
--pot: #b97a0e;
|
||||||
--warn: #9a6200;
|
--pot-soft: #f6ecd7;
|
||||||
--warn-soft: #f7ecd6;
|
--gain: #0e7f57;
|
||||||
|
--gain-soft: #dcf1e8;
|
||||||
|
--danger: #c0383e;
|
||||||
|
--danger-soft: #f8e2e3;
|
||||||
|
--warn: #9a6400;
|
||||||
|
--warn-soft: #f6ecd7;
|
||||||
|
color-scheme: light;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
--bg: #0f1012;
|
--bg: #0d1020;
|
||||||
--surface: #17191c;
|
--surface: #161a2c;
|
||||||
--surface-2: #1f2226;
|
--surface-2: #1f2438;
|
||||||
--border: #2a2e33;
|
--border: #2a3047;
|
||||||
--text: #ecebe6;
|
--text: #e8eaf4;
|
||||||
--muted: #9a988f;
|
--muted: #9ba1b8;
|
||||||
--accent: #3ccf9f;
|
--accent: #8d9bff;
|
||||||
--accent-soft: #123a2e;
|
--accent-soft: #232a52;
|
||||||
--danger: #ff6b81;
|
--accent-ink: #0d1020;
|
||||||
--danger-soft: #3b1820;
|
--pot: #e7b54a;
|
||||||
--warn: #f0b44c;
|
--pot-soft: #3a2e14;
|
||||||
--warn-soft: #3a2c12;
|
--gain: #4fd19c;
|
||||||
|
--gain-soft: #123528;
|
||||||
|
--danger: #ff7b80;
|
||||||
|
--danger-soft: #3d1a1f;
|
||||||
|
--warn: #e7b54a;
|
||||||
|
--warn-soft: #3a2e14;
|
||||||
|
color-scheme: dark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,12 +59,17 @@
|
|||||||
--color-muted: var(--muted);
|
--color-muted: var(--muted);
|
||||||
--color-accent: var(--accent);
|
--color-accent: var(--accent);
|
||||||
--color-accent-soft: var(--accent-soft);
|
--color-accent-soft: var(--accent-soft);
|
||||||
|
--color-accent-ink: var(--accent-ink);
|
||||||
|
--color-pot: var(--pot);
|
||||||
|
--color-pot-soft: var(--pot-soft);
|
||||||
|
--color-gain: var(--gain);
|
||||||
|
--color-gain-soft: var(--gain-soft);
|
||||||
--color-danger: var(--danger);
|
--color-danger: var(--danger);
|
||||||
--color-danger-soft: var(--danger-soft);
|
--color-danger-soft: var(--danger-soft);
|
||||||
--color-warn: var(--warn);
|
--color-warn: var(--warn);
|
||||||
--color-warn-soft: var(--warn-soft);
|
--color-warn-soft: var(--warn-soft);
|
||||||
--font-sans: var(--font-geist-sans);
|
--font-sans: var(--font-atkinson);
|
||||||
--font-mono: var(--font-geist-mono);
|
--font-display: var(--font-bricolage);
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@ -57,8 +80,60 @@ body {
|
|||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Titres et montants : Bricolage Grotesque, resserrée en grand comme un relevé de compte. */
|
||||||
|
.display {
|
||||||
|
font-family: var(--font-bricolage);
|
||||||
|
font-variation-settings: "wdth" 88, "opsz" 48;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.amount {
|
||||||
|
font-family: var(--font-bricolage);
|
||||||
|
font-variation-settings: "wdth" 82, "opsz" 96;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.num {
|
.num {
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Le seul mouvement non déclenché : la barre « à l'abri / cagnotte IA » se remplit à l'ouverture. */
|
||||||
|
@keyframes grow {
|
||||||
|
from {
|
||||||
|
transform: scaleX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bar-fill {
|
||||||
|
transform-origin: left;
|
||||||
|
animation: grow 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes shimmer {
|
||||||
|
50% {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.skeleton {
|
||||||
|
background: var(--surface-2);
|
||||||
|
animation: shimmer 1.4s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.bar-fill,
|
||||||
|
.skeleton {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import type { Metadata, Viewport } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Atkinson_Hyperlegible_Next, Bricolage_Grotesque } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
|
// Montants et titres : Bricolage Grotesque (largeur et taille optique variables).
|
||||||
const geistMono = Geist_Mono({ variable: "--font-geist-mono", subsets: ["latin"] });
|
const display = Bricolage_Grotesque({ variable: "--font-bricolage", subsets: ["latin"], axes: ["wdth", "opsz"] });
|
||||||
|
// Texte : Atkinson Hyperlegible Next, dessinée pour être lisible par tous.
|
||||||
|
const body = Atkinson_Hyperlegible_Next({ variable: "--font-atkinson", subsets: ["latin"], adjustFontFallback: false });
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Cagnotte",
|
title: "Cagnotte",
|
||||||
@ -16,14 +18,14 @@ export const viewport: Viewport = {
|
|||||||
initialScale: 1,
|
initialScale: 1,
|
||||||
viewportFit: "cover",
|
viewportFit: "cover",
|
||||||
themeColor: [
|
themeColor: [
|
||||||
{ media: "(prefers-color-scheme: light)", color: "#f6f5f1" },
|
{ media: "(prefers-color-scheme: light)", color: "#f1f2f6" },
|
||||||
{ media: "(prefers-color-scheme: dark)", color: "#0f1012" },
|
{ media: "(prefers-color-scheme: dark)", color: "#0d1020" },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({ children }: LayoutProps<"/">) {
|
export default function RootLayout({ children }: LayoutProps<"/">) {
|
||||||
return (
|
return (
|
||||||
<html lang="fr" className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}>
|
<html lang="fr" className={`${display.variable} ${body.variable} h-full antialiased`}>
|
||||||
<body className="min-h-full font-sans">{children}</body>
|
<body className="min-h-full font-sans">{children}</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,9 +3,12 @@ import { LoginForm } from "./login-form";
|
|||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
return (
|
return (
|
||||||
<main className="mx-auto flex min-h-dvh w-full max-w-sm flex-col justify-center px-6">
|
<main className="mx-auto flex min-h-dvh w-full max-w-sm flex-col justify-center px-6">
|
||||||
<p className="text-4xl">🌱</p>
|
<div className="flex h-3 w-24 gap-1 overflow-hidden rounded-full" aria-hidden>
|
||||||
<h1 className="mt-3 text-2xl font-semibold tracking-tight">Cagnotte</h1>
|
<div className="bar-fill w-1/2 rounded-full bg-accent" />
|
||||||
<p className="mt-1 text-sm text-muted">Ton argent travaille, l'IA t'aide à décider.</p>
|
<div className="bar-fill flex-1 rounded-full bg-pot" style={{ animationDelay: "120ms" }} />
|
||||||
|
</div>
|
||||||
|
<h1 className="display mt-6 text-[2.6rem] font-bold">Cagnotte</h1>
|
||||||
|
<p className="mt-2 text-[16px] leading-snug text-muted">La moitié à l'abri, la moitié qui travaille. L'IA t'aide à décider.</p>
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -19,15 +19,15 @@ import { Delta, Empty, inputCls, primaryBtn, secondaryBtn } from "./ui";
|
|||||||
|
|
||||||
function Result({ r }: { r: FormResult }) {
|
function Result({ r }: { r: FormResult }) {
|
||||||
if (!r) return null;
|
if (!r) return null;
|
||||||
return <p className={`text-sm ${r.ok ? "text-accent" : "text-danger"}`}>{r.message}</p>;
|
return <p className={`text-[14px] font-semibold ${r.ok ? "text-gain" : "text-danger"}`}>{r.message}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
|
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<label className="flex flex-col gap-1 text-sm">
|
<label className="flex flex-col gap-1.5 text-[15px]">
|
||||||
<span className="font-medium">{label}</span>
|
<span className="font-semibold">{label}</span>
|
||||||
{children}
|
{children}
|
||||||
{hint && <span className="text-xs text-muted">{hint}</span>}
|
{hint && <span className="text-[13px] text-muted">{hint}</span>}
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -56,11 +56,11 @@ export function AccountForm(props: { openedAt: string | null; monthly: number; d
|
|||||||
<input className={inputCls} name="depositDay" inputMode="numeric" defaultValue={props.day} />
|
<input className={inputCls} name="depositDay" inputMode="numeric" defaultValue={props.day} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
<label className="flex items-start gap-2 text-sm">
|
<label className="flex items-start gap-2 text-[15px]">
|
||||||
<input type="checkbox" name="autoDeposit" defaultChecked={props.auto} className="mt-1 h-4 w-4 accent-[var(--accent)]" />
|
<input type="checkbox" name="autoDeposit" defaultChecked={props.auto} className="mt-1 h-4 w-4 accent-[var(--accent)]" />
|
||||||
<span>
|
<span>
|
||||||
J'ai programmé ce virement chaque mois
|
J'ai programmé ce virement chaque mois
|
||||||
<span className="block text-xs text-muted">L'app l'ajoutera toute seule à tes liquidités à chaque échéance.</span>
|
<span className="block text-[13px] text-muted">L'app l'ajoutera toute seule à tes liquidités à chaque échéance.</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<button className={primaryBtn} disabled={pending}>
|
<button className={primaryBtn} disabled={pending}>
|
||||||
@ -131,7 +131,7 @@ export function AddHolding() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3 rounded-xl border border-line p-3">
|
<div className="flex flex-col gap-3 rounded-xl border border-line p-3">
|
||||||
<p className="text-sm font-semibold">Ajouter une action détenue chez Trade Republic</p>
|
<p className="text-[15px] font-semibold">Ajouter une action détenue chez Trade Republic</p>
|
||||||
<input
|
<input
|
||||||
className={inputCls}
|
className={inputCls}
|
||||||
placeholder="Rechercher l'action"
|
placeholder="Rechercher l'action"
|
||||||
@ -143,11 +143,11 @@ export function AddHolding() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!picked && hits.length > 0 && (
|
{!picked && hits.length > 0 && (
|
||||||
<ul className="overflow-hidden rounded-xl border border-line text-sm">
|
<ul className="overflow-hidden rounded-xl border border-line text-[15px]">
|
||||||
{hits.map((h) => (
|
{hits.map((h) => (
|
||||||
<li key={h.symbol}>
|
<li key={h.symbol}>
|
||||||
<button className="w-full bg-surface-2 px-3 py-2.5 text-left" onClick={() => (setPicked(h), setHits([]))}>
|
<button className="w-full bg-surface-2 px-3 py-2.5 text-left" onClick={() => (setPicked(h), setHits([]))}>
|
||||||
{h.name} <span className="text-xs text-muted">· {h.symbol}</span>
|
{h.name} <span className="text-[13px] text-muted">· {h.symbol}</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@ -164,11 +164,11 @@ export function AddHolding() {
|
|||||||
<Field label="Stop (% sous le prix d'achat)" hint="Laisse vide si tu n'as pas mis d'ordre Stop.">
|
<Field label="Stop (% sous le prix d'achat)" hint="Laisse vide si tu n'as pas mis d'ordre Stop.">
|
||||||
<input className={inputCls} inputMode="decimal" value={stop} onChange={(e) => setStop(e.target.value)} />
|
<input className={inputCls} inputMode="decimal" value={stop} onChange={(e) => setStop(e.target.value)} />
|
||||||
</Field>
|
</Field>
|
||||||
<label className="flex items-start gap-2 text-sm">
|
<label className="flex items-start gap-2 text-[15px]">
|
||||||
<input type="checkbox" checked={paid} onChange={(e) => setPaid(e.target.checked)} className="mt-1 h-4 w-4" />
|
<input type="checkbox" checked={paid} onChange={(e) => setPaid(e.target.checked)} className="mt-1 h-4 w-4" />
|
||||||
<span>
|
<span>
|
||||||
Retirer le coût de mes liquidités
|
Retirer le coût de mes liquidités
|
||||||
<span className="block text-xs text-muted">Décoche si ces liquidités ne sont pas encore comptées dans l'app (achat ancien).</span>
|
<span className="block text-[13px] text-muted">Décoche si ces liquidités ne sont pas encore comptées dans l'app (achat ancien).</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
@ -217,14 +217,14 @@ function RealPosition({ p }: { p: PositionView }) {
|
|||||||
const [res, setRes] = useState<FormResult>(null);
|
const [res, setRes] = useState<FormResult>(null);
|
||||||
const [pending, start] = useTransition();
|
const [pending, start] = useTransition();
|
||||||
return (
|
return (
|
||||||
<li className="rounded-xl bg-surface-2 p-3">
|
<li className="rounded-2xl bg-surface-2 p-4">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="font-semibold">{p.name}</p>
|
<p className="font-semibold">{p.name}</p>
|
||||||
<p className="num text-xs text-muted">
|
<p className="num text-[13px] text-muted">
|
||||||
{fmtShares(p.shares)} × {price(p.entryPrice, p.currency)} → {p.price !== null ? price(p.price, p.currency) : "?"}
|
{fmtShares(p.shares)} × {price(p.entryPrice, p.currency)} → {p.price !== null ? price(p.price, p.currency) : "?"}
|
||||||
</p>
|
</p>
|
||||||
{p.stopPrice && <p className="num text-xs text-muted">Stop {price(p.stopPrice, p.currency)}</p>}
|
{p.stopPrice && <p className="num text-[13px] text-muted">Stop {price(p.stopPrice, p.currency)}</p>}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<p className="num font-semibold">{eur(p.valueEur)}</p>
|
<p className="num font-semibold">{eur(p.valueEur)}</p>
|
||||||
@ -275,11 +275,11 @@ export function PeaForm(props: { has: boolean; symbol: string; amount: number; d
|
|||||||
const [has, setHas] = useState(props.has);
|
const [has, setHas] = useState(props.has);
|
||||||
return (
|
return (
|
||||||
<form action={action} className="flex flex-col gap-3">
|
<form action={action} className="flex flex-col gap-3">
|
||||||
<label className="flex items-start gap-2 text-sm">
|
<label className="flex items-start gap-2 text-[15px]">
|
||||||
<input type="checkbox" name="hasPea" checked={has} onChange={(e) => setHas(e.target.checked)} className="mt-1 h-4 w-4" />
|
<input type="checkbox" name="hasPea" checked={has} onChange={(e) => setHas(e.target.checked)} className="mt-1 h-4 w-4" />
|
||||||
<span>
|
<span>
|
||||||
J'ai un PEA avec un plan d'épargne ETF
|
J'ai un PEA avec un plan d'épargne ETF
|
||||||
<span className="block text-xs text-muted">L'app calcule sa valeur toute seule, chaque jour, à partir du cours de l'ETF.</span>
|
<span className="block text-[13px] text-muted">L'app calcule sa valeur toute seule, chaque jour, à partir du cours de l'ETF.</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
{has && (
|
{has && (
|
||||||
|
|||||||
@ -42,58 +42,64 @@ export function ActionCard({ id, kind, training, status, symbol, payload }: Prop
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const icon = { buy: "🟢", sell: "🔴", move_stop: "🛡️", to_pea: "🏦" }[kind] ?? "•";
|
const kindLabel = { buy: "Acheter", sell: "Vendre", move_stop: "Protéger un gain", to_pea: "Mettre à l'abri" }[kind] ?? "À faire";
|
||||||
|
const kindTone = ({ buy: "gain", sell: "danger", move_stop: "accent", to_pea: "accent" } as const)[kind as "buy"] ?? "neutral";
|
||||||
|
const done = status !== "pending";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="rounded-2xl border border-line bg-surface-2 p-4">
|
<article className={`rounded-2xl bg-surface-2 p-4 ${done ? "opacity-70" : ""}`}>
|
||||||
<div className="mb-2 flex flex-wrap items-center gap-2">
|
<div className="mb-2.5 flex flex-wrap items-center gap-2">
|
||||||
{training ? <Badge tone="warn">Entraînement</Badge> : <Badge tone="accent">Argent réel</Badge>}
|
<Badge tone={kindTone}>{kindLabel}</Badge>
|
||||||
{status !== "pending" && <Badge>{status === "done" ? (training ? "Tu l'aurais pris" : "Fait") : "Passé"}</Badge>}
|
{training ? <Badge tone="pot">Entraînement</Badge> : <Badge tone="accent">Argent réel</Badge>}
|
||||||
|
{done && <Badge>{status === "done" ? (training ? "Tu l'aurais pris" : "Fait") : status === "expired" ? "Expirée" : "Passée"}</Badge>}
|
||||||
</div>
|
</div>
|
||||||
<h3 className="text-base font-semibold leading-snug">
|
<h3 className="display text-[1.15rem] font-semibold">{payload.title}</h3>
|
||||||
{icon} {payload.title}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<button type="button" onClick={() => setOpen(!open)} className="mt-2 text-sm font-medium text-accent">
|
<ol className="mt-3 flex flex-col gap-2 text-[15px] leading-relaxed">
|
||||||
{open ? "Masquer le pourquoi" : "Pourquoi ?"}
|
{payload.steps.map((s, i) => (
|
||||||
</button>
|
<li key={s} className="flex gap-3">
|
||||||
{open && <p className="mt-2 whitespace-pre-line text-sm leading-relaxed text-muted">{payload.why}</p>}
|
<span className="amount mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-surface text-[0.9rem] font-bold text-accent" aria-hidden>
|
||||||
|
{i + 1}
|
||||||
<ol className="mt-3 flex list-decimal flex-col gap-1.5 pl-5 text-sm leading-relaxed">
|
</span>
|
||||||
{payload.steps.map((s) => (
|
<span>{s}</span>
|
||||||
<li key={s}>{s}</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
{kind === "buy" && symbol && (
|
<button type="button" onClick={() => setOpen(!open)} aria-expanded={open} className="mt-3 text-[14px] font-semibold text-accent">
|
||||||
|
{open ? "Masquer l'explication" : "Pourquoi ce conseil ?"}
|
||||||
|
</button>
|
||||||
|
{open && <p className="mt-2 whitespace-pre-line text-[15px] leading-relaxed text-muted">{payload.why}</p>}
|
||||||
|
|
||||||
|
{kind === "buy" && symbol && !done && (
|
||||||
<Link href={sandboxHref(symbol, payload)} className={`${training ? primaryBtn : secondaryBtn} mt-4 w-full`}>
|
<Link href={sandboxHref(symbol, payload)} className={`${training ? primaryBtn : secondaryBtn} mt-4 w-full`}>
|
||||||
🧪 Essayer dans mon bac à sable
|
Essayer dans mon bac à sable
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{status === "pending" && (
|
{status === "pending" && (
|
||||||
<div className="mt-3 flex flex-col gap-3">
|
<div className="mt-4 flex flex-col gap-3 border-t border-line pt-4">
|
||||||
{needsFill && (
|
{needsFill && (
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Prix exécuté ({payload.currency === "USD" ? "$" : "€"})
|
Prix obtenu ({payload.currency === "USD" ? "$" : "€"})
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={priceVal} onChange={(e) => setPrice(e.target.value)} placeholder="prix réel" />
|
<input className={`${inputCls} mt-1 bg-surface!`} inputMode="decimal" value={priceVal} onChange={(e) => setPrice(e.target.value)} placeholder="prix réel" />
|
||||||
</label>
|
</label>
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Nombre d'actions
|
Nombre d'actions
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={sharesVal} onChange={(e) => setShares(e.target.value)} />
|
<input className={`${inputCls} mt-1 bg-surface!`} inputMode="decimal" value={sharesVal} onChange={(e) => setShares(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<button className={training ? secondaryBtn : primaryBtn} disabled={pending} onClick={() => answer("done")}>
|
<button className={training ? `${secondaryBtn} bg-surface!` : primaryBtn} disabled={pending} onClick={() => answer("done")}>
|
||||||
{training ? "✅ Je l'aurais pris" : "✅ C'est fait"}
|
{training ? "Je l'aurais pris" : "C'est fait"}
|
||||||
</button>
|
</button>
|
||||||
<button className={secondaryBtn} disabled={pending} onClick={() => answer("skipped")}>
|
<button className={`${secondaryBtn} bg-surface!`} disabled={pending} onClick={() => answer("skipped")}>
|
||||||
❌ Je passe
|
Je passe
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <p className="text-sm text-danger">{error}</p>}
|
{error && <p className="text-[14px] text-danger">{error}</p>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { findIdeasNow } from "@/app/actions";
|
|||||||
import { secondaryBtn } from "./ui";
|
import { secondaryBtn } from "./ui";
|
||||||
|
|
||||||
/** Lance l'analyse du soir tout de suite, sans attendre le rendez-vous. */
|
/** Lance l'analyse du soir tout de suite, sans attendre le rendez-vous. */
|
||||||
export function FindIdeas({ label = "🔎 Chercher des idées maintenant" }: { label?: string }) {
|
export function FindIdeas({ label = "Chercher des idées maintenant" }: { label?: string }) {
|
||||||
const [pending, start] = useTransition();
|
const [pending, start] = useTransition();
|
||||||
const [log, setLog] = useState<string[] | null>(null);
|
const [log, setLog] = useState<string[] | null>(null);
|
||||||
return (
|
return (
|
||||||
@ -26,7 +26,7 @@ export function FindIdeas({ label = "🔎 Chercher des idées maintenant" }: { l
|
|||||||
>
|
>
|
||||||
{pending ? "Analyse en cours… (jusqu'à 1 minute)" : label}
|
{pending ? "Analyse en cours… (jusqu'à 1 minute)" : label}
|
||||||
</button>
|
</button>
|
||||||
{log && log.length > 0 && <p className="text-xs text-muted">{log.at(-1)}</p>}
|
{log && log.length > 0 && <p className="text-[13px] text-muted">{log.at(-1)}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import Link from "next/link";
|
|||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
|
|
||||||
const TABS = [
|
const TABS = [
|
||||||
{ href: "/", label: "Accueil", icon: "M3 11.5 12 4l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z" },
|
{ href: "/", label: "Ce soir", icon: "M12 3a6 6 0 0 0 0 12 6 6 0 0 1 0-12zM4 20h16M7 17h10" },
|
||||||
{ href: "/actions", label: "Actions", icon: "M3 17l5-5 4 4 8-8M15 8h5v5" },
|
{ href: "/actions", label: "Actions", icon: "M3 17l5-5 4 4 8-8M15 8h5v5" },
|
||||||
{ href: "/bac-a-sable", label: "Bac à sable", icon: "M4 19h16M6 16l3-6 3 3 4-7 2 10" },
|
{ href: "/bac-a-sable", label: "Bac à sable", icon: "M4 19h16M6 16l3-6 3 3 4-7 2 10" },
|
||||||
{ href: "/ia", label: "IA", icon: "M12 3v3m0 12v3M3 12h3m12 0h3M7 7h10v10H7zM10 10h4v4h-4z" },
|
{ href: "/ia", label: "L'IA", icon: "M12 3v3m0 12v3M3 12h3m12 0h3M7 7h10v10H7zM10 10h4v4h-4z" },
|
||||||
{ href: "/reel", label: "Mon compte", icon: "M3 7h18v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM3 7l2-3h14l2 3M16 13h2" },
|
{ href: "/reel", label: "Mon compte", icon: "M3 7h18v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM3 7l2-3h14l2 3M16 13h2" },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -18,19 +18,22 @@ export function Nav() {
|
|||||||
/** La même barre sans onglet actif : affichée instantanément, avant que l'adresse soit connue. */
|
/** La même barre sans onglet actif : affichée instantanément, avant que l'adresse soit connue. */
|
||||||
export function NavBar({ pathname }: { pathname: string | null }) {
|
export function NavBar({ pathname }: { pathname: string | null }) {
|
||||||
return (
|
return (
|
||||||
<nav className="fixed inset-x-0 bottom-0 z-20 border-t border-line bg-surface/95 pb-[env(safe-area-inset-bottom)] backdrop-blur">
|
<nav className="fixed inset-x-0 bottom-0 z-20 border-t border-line bg-bg/90 pb-[env(safe-area-inset-bottom)] backdrop-blur-md">
|
||||||
<ul className="mx-auto flex max-w-lg">
|
<ul className="mx-auto flex max-w-lg px-1">
|
||||||
{TABS.map((t) => {
|
{TABS.map((t) => {
|
||||||
const active = pathname !== null && (t.href === "/" ? pathname === "/" : pathname.startsWith(t.href));
|
const active = pathname !== null && (t.href === "/" ? pathname === "/" : pathname.startsWith(t.href));
|
||||||
return (
|
return (
|
||||||
<li key={t.href} className="flex-1">
|
<li key={t.href} className="flex-1">
|
||||||
<Link
|
<Link
|
||||||
href={t.href}
|
href={t.href}
|
||||||
className={`flex flex-col items-center gap-1 py-2.5 text-[11px] font-medium ${active ? "text-accent" : "text-muted"}`}
|
aria-current={active ? "page" : undefined}
|
||||||
|
className={`flex flex-col items-center gap-1 pb-2 pt-2 text-[12px] font-semibold ${active ? "text-accent" : "text-muted"}`}
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 24 24" className="h-6 w-6" fill="none" stroke="currentColor" strokeWidth={1.7} strokeLinecap="round" strokeLinejoin="round" aria-hidden>
|
<span className={`flex h-8 w-14 items-center justify-center rounded-full transition-colors ${active ? "bg-accent-soft" : ""}`}>
|
||||||
<path d={t.icon} />
|
<svg viewBox="0 0 24 24" className="h-[22px] w-[22px]" fill="none" stroke="currentColor" strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round" aria-hidden>
|
||||||
</svg>
|
<path d={t.icon} />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
{t.label}
|
{t.label}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
@ -44,10 +47,22 @@ export function NavBar({ pathname }: { pathname: string | null }) {
|
|||||||
/** Raccourci vers les réglages, en haut à droite des pages. */
|
/** Raccourci vers les réglages, en haut à droite des pages. */
|
||||||
export function SettingsLink() {
|
export function SettingsLink() {
|
||||||
return (
|
return (
|
||||||
<Link href="/reglages" aria-label="Réglages" className="flex h-9 w-9 items-center justify-center rounded-full border border-line bg-surface text-muted">
|
<Link href="/reglages" aria-label="Réglages" className="flex h-10 w-10 items-center justify-center rounded-full bg-surface text-muted dark:ring-1 dark:ring-line">
|
||||||
<svg viewBox="0 0 24 24" className="h-5 w-5" fill="none" stroke="currentColor" strokeWidth={1.7} strokeLinecap="round" strokeLinejoin="round" aria-hidden>
|
<svg viewBox="0 0 24 24" className="h-5 w-5" fill="none" stroke="currentColor" strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round" aria-hidden>
|
||||||
<path d="M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19 12l2-1-2-4-2 .5-1.5-1L15 4h-6l-.5 2.5-1.5 1L5 7l-2 4 2 1-2 1 2 4 2-.5 1.5 1L9 20h6l.5-2.5 1.5-1 2 .5 2-4z" />
|
<path d="M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19 12l2-1-2-4-2 .5-1.5-1L15 4h-6l-.5 2.5-1.5 1L5 7l-2 4 2 1-2 1 2 4 2-.5 1.5 1L9 20h6l.5-2.5 1.5-1 2 .5 2-4z" />
|
||||||
</svg>
|
</svg>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Lien retour en haut d'une page secondaire. */
|
||||||
|
export function BackLink({ href, label }: { href: string; label: string }) {
|
||||||
|
return (
|
||||||
|
<Link href={href} className="inline-flex h-10 items-center gap-1 rounded-full bg-surface px-3.5 text-[14px] font-semibold text-ink dark:ring-1 dark:ring-line">
|
||||||
|
<svg viewBox="0 0 24 24" className="h-4 w-4" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden>
|
||||||
|
<path d="M15 5l-7 7 7 7" />
|
||||||
|
</svg>
|
||||||
|
{label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import { Page } from "./ui";
|
import { CardSkeleton, Page } from "./ui";
|
||||||
|
|
||||||
/** Affiché pendant le chargement des données d'une page. */
|
/** Affiché pendant le chargement des données d'une page. */
|
||||||
export function PageSkeleton({ title }: { title: string }) {
|
export function PageSkeleton({ title }: { title: string }) {
|
||||||
return (
|
return (
|
||||||
<Page title={title}>
|
<Page title={title}>
|
||||||
{[0, 1, 2].map((i) => (
|
<CardSkeleton height="h-28" />
|
||||||
<div key={i} className="h-32 animate-pulse rounded-2xl border border-line bg-surface" />
|
<CardSkeleton height="h-40" />
|
||||||
))}
|
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,35 +11,37 @@ export function PositionList({ positions, sellable = false }: { positions: Posit
|
|||||||
const [pending, start] = useTransition();
|
const [pending, start] = useTransition();
|
||||||
if (!positions.length) return <Empty>Aucune position ouverte.</Empty>;
|
if (!positions.length) return <Empty>Aucune position ouverte.</Empty>;
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col gap-2">
|
<ul className="-my-1 divide-y divide-line">
|
||||||
{positions.map((p) => (
|
{positions.map((p) => (
|
||||||
<li key={p.id} className="rounded-xl bg-surface-2 p-3">
|
<li key={p.id} className="py-3">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<Link href={`/actions/${encodeURIComponent(p.symbol)}`} className="font-semibold">
|
<Link href={`/actions/${encodeURIComponent(p.symbol)}`} className="font-semibold">
|
||||||
{p.name}
|
{p.name}
|
||||||
</Link>
|
</Link>
|
||||||
<p className="num text-xs text-muted">
|
<p className="num mt-0.5 text-[13px] text-muted">
|
||||||
{shares(p.shares)} × {price(p.entryPrice, p.currency)} → {p.price !== null ? price(p.price, p.currency) : "?"}
|
{shares(p.shares)} action{p.shares > 1 ? "s" : ""}, achat {price(p.entryPrice, p.currency)}, cours {p.price !== null ? price(p.price, p.currency) : "inconnu"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<div className="shrink-0 text-right">
|
||||||
<p className="num font-semibold">{eur(p.valueEur)}</p>
|
<p className="amount text-[1.2rem] font-semibold">{eur(p.valueEur)}</p>
|
||||||
<Delta value={p.pnlOpenEur}>
|
<p className="mt-0.5 text-[13px]">
|
||||||
{signedEur(p.pnlOpenEur)} ({pct(p.pnlOpenPct)})
|
<Delta value={p.pnlOpenEur}>
|
||||||
</Delta>
|
{signedEur(p.pnlOpenEur)} ({pct(p.pnlOpenPct)})
|
||||||
|
</Delta>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{(p.stopPrice || p.targetPrice || p.maxExitDate) && (
|
{(p.stopPrice || p.targetPrice || p.maxExitDate) && (
|
||||||
<p className="num mt-2 text-xs text-muted">
|
<div className="num mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[13px] text-muted">
|
||||||
{p.stopPrice ? `Stop ${price(p.stopPrice, p.currency)}` : ""}
|
{p.stopPrice ? <span>Stop {price(p.stopPrice, p.currency)}</span> : null}
|
||||||
{p.targetPrice ? ` · Objectif ${price(p.targetPrice, p.currency)}` : ""}
|
{p.targetPrice ? <span>Objectif {price(p.targetPrice, p.currency)}</span> : null}
|
||||||
{p.maxExitDate ? ` · Sortie au plus tard le ${p.maxExitDate}` : ""}
|
{p.maxExitDate ? <span>Vente au plus tard le {p.maxExitDate.split("-").reverse().join("/")}</span> : null}
|
||||||
</p>
|
</div>
|
||||||
)}
|
)}
|
||||||
{sellable && (
|
{sellable && (
|
||||||
<button
|
<button
|
||||||
className={`${secondaryBtn} mt-3 h-9 w-full`}
|
className={`${secondaryBtn} mt-3 h-10 w-full`}
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
start(async () => {
|
start(async () => {
|
||||||
@ -60,18 +62,20 @@ export function PositionList({ positions, sellable = false }: { positions: Posit
|
|||||||
export function PendingOrders({ orders, cancellable = false }: { orders: Order[]; cancellable?: boolean }) {
|
export function PendingOrders({ orders, cancellable = false }: { orders: Order[]; cancellable?: boolean }) {
|
||||||
const [pending, start] = useTransition();
|
const [pending, start] = useTransition();
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col gap-2 text-sm">
|
<ul className="-my-1 divide-y divide-line text-[15px]">
|
||||||
{orders.map((o) => (
|
{orders.map((o) => (
|
||||||
<li key={o.id} className="flex items-center justify-between gap-3 rounded-xl bg-surface-2 p-3">
|
<li key={o.id} className="flex items-center justify-between gap-3 py-3">
|
||||||
<span>
|
<span>
|
||||||
{o.side === "buy" ? "Achat" : "Vente"} {shares(o.shares)} {o.name}
|
<span className="font-semibold">
|
||||||
<span className="num block text-xs text-muted">
|
{o.side === "buy" ? "Achat" : "Vente"} de {shares(o.shares)} {o.name}
|
||||||
{o.type === "limit" && o.limitPrice ? `limite ${price(o.limitPrice, o.currency)}` : "au marché"}
|
</span>
|
||||||
{o.validUntil ? ` · valable jusqu'au ${o.validUntil}` : ""}
|
<span className="num block text-[13px] text-muted">
|
||||||
|
{o.type === "limit" && o.limitPrice ? `Cours limite ${price(o.limitPrice, o.currency)}` : "Au marché"}
|
||||||
|
{o.validUntil ? `, valable jusqu'au ${o.validUntil.split("-").reverse().join("/")}` : ""}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
{cancellable && (
|
{cancellable && (
|
||||||
<button className="text-sm font-medium text-danger" disabled={pending} onClick={() => start(() => cancelSandboxOrder(o.id))}>
|
<button className="shrink-0 text-[14px] font-semibold text-danger" disabled={pending} onClick={() => start(() => cancelSandboxOrder(o.id))}>
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
@ -84,13 +88,13 @@ export function PendingOrders({ orders, cancellable = false }: { orders: Order[]
|
|||||||
export function ClosedList({ positions }: { positions: Position[] }) {
|
export function ClosedList({ positions }: { positions: Position[] }) {
|
||||||
if (!positions.length) return <Empty>Pas encore de trade terminé.</Empty>;
|
if (!positions.length) return <Empty>Pas encore de trade terminé.</Empty>;
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col divide-y divide-line text-sm">
|
<ul className="-my-1 divide-y divide-line text-[15px]">
|
||||||
{positions.map((p) => (
|
{positions.map((p) => (
|
||||||
<li key={p.id} className="flex items-center justify-between gap-3 py-2.5">
|
<li key={p.id} className="flex items-center justify-between gap-3 py-3">
|
||||||
<span>
|
<span className="min-w-0">
|
||||||
<span className="font-medium">{p.name}</span>
|
<span className="block truncate font-semibold">{p.name}</span>
|
||||||
<span className="block text-xs text-muted">
|
<span className="block text-[13px] text-muted">
|
||||||
{p.closedAt?.toLocaleDateString("fr-FR")} · {EXIT_REASONS[p.exitReason ?? ""] ?? p.exitReason}
|
{p.closedAt?.toLocaleDateString("fr-FR")}, {EXIT_REASONS[p.exitReason ?? ""] ?? p.exitReason}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<Delta value={p.pnlEur ?? 0}>{signedEur(p.pnlEur ?? 0)}</Delta>
|
<Delta value={p.pnlEur ?? 0}>{signedEur(p.pnlEur ?? 0)}</Delta>
|
||||||
|
|||||||
@ -49,13 +49,13 @@ export function PushManager() {
|
|||||||
const s = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(key) });
|
const s = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(key) });
|
||||||
setSub(s);
|
setSub(s);
|
||||||
await subscribePush(JSON.parse(JSON.stringify(s)));
|
await subscribePush(JSON.parse(JSON.stringify(s)));
|
||||||
setMsg("Notifications activées ✅");
|
setMsg("Notifications activées.");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === "loading") return <p className="text-sm text-muted">Vérification…</p>;
|
if (status === "loading") return <p className="text-[15px] text-muted">Vérification…</p>;
|
||||||
if (status === "needs-install")
|
if (status === "needs-install")
|
||||||
return (
|
return (
|
||||||
<ol className="list-decimal pl-5 text-sm leading-relaxed">
|
<ol className="list-decimal pl-5 text-[15px] leading-relaxed">
|
||||||
<li>Ouvre ce site dans <b>Safari</b>.</li>
|
<li>Ouvre ce site dans <b>Safari</b>.</li>
|
||||||
<li>
|
<li>
|
||||||
Touche le bouton <b>Partager</b> (carré avec une flèche vers le haut).
|
Touche le bouton <b>Partager</b> (carré avec une flèche vers le haut).
|
||||||
@ -66,13 +66,13 @@ export function PushManager() {
|
|||||||
<li>Ouvre l'app depuis la nouvelle icône, reviens ici et active les notifications.</li>
|
<li>Ouvre l'app depuis la nouvelle icône, reviens ici et active les notifications.</li>
|
||||||
</ol>
|
</ol>
|
||||||
);
|
);
|
||||||
if (status === "unsupported") return <p className="text-sm text-muted">Ce navigateur ne gère pas les notifications. Sur iPhone, il faut iOS 16.4 ou plus récent.</p>;
|
if (status === "unsupported") return <p className="text-[15px] text-muted">Ce navigateur ne gère pas les notifications. Sur iPhone, il faut iOS 16.4 ou plus récent.</p>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{sub ? (
|
{sub ? (
|
||||||
<>
|
<>
|
||||||
<p className="text-sm">✅ Cet appareil recevra ton rendez-vous du soir.</p>
|
<p className="text-[15px]">Cet appareil recevra ton rendez-vous du soir.</p>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<button className={secondaryBtn} disabled={pending} onClick={() => start(async () => setMsg((await testPush()) ? "Notification envoyée !" : "Échec de l'envoi."))}>
|
<button className={secondaryBtn} disabled={pending} onClick={() => start(async () => setMsg((await testPush()) ? "Notification envoyée !" : "Échec de l'envoi."))}>
|
||||||
Tester
|
Tester
|
||||||
@ -97,7 +97,7 @@ export function PushManager() {
|
|||||||
Activer les notifications
|
Activer les notifications
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{msg && <p className="text-sm text-muted">{msg}</p>}
|
{msg && <p className="text-[15px] text-muted">{msg}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/components/reset-ai.tsx
Normal file
31
src/components/reset-ai.tsx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useTransition } from "react";
|
||||||
|
import { resetAiPot } from "@/app/actions";
|
||||||
|
import { primaryBtn, secondaryBtn } from "./ui";
|
||||||
|
|
||||||
|
/** Remettre la cagnotte de l'IA à zéro : mise en avant quand elle est bloquée, discrète sinon. */
|
||||||
|
export function ResetAi({ stuck }: { stuck: boolean }) {
|
||||||
|
const [pending, start] = useTransition();
|
||||||
|
const reset = () => {
|
||||||
|
if (
|
||||||
|
confirm(
|
||||||
|
"Remettre la cagnotte de l'IA à 200 € ? Ses trades et sa courbe sont effacés, et la simulation repart d'aujourd'hui : il faudra de nouveau 3 mois et 20 trades pour passer au réel.",
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
start(() => resetAiPot());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (stuck) {
|
||||||
|
return (
|
||||||
|
<button className={`${primaryBtn} w-full`} disabled={pending} onClick={reset}>
|
||||||
|
{pending ? "Remise à zéro…" : "Remettre la cagnotte de l'IA à 200 €"}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<button className={`${secondaryBtn} w-full`} disabled={pending} onClick={reset}>
|
||||||
|
{pending ? "Remise à zéro…" : "Remettre la cagnotte de l'IA à zéro"}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ export function ResetSandbox() {
|
|||||||
const [pending, start] = useTransition();
|
const [pending, start] = useTransition();
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="self-center text-sm text-muted underline"
|
className="self-center py-2 text-[14px] font-semibold text-muted underline underline-offset-4"
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (confirm("Remettre ton bac à sable à 200 € et effacer son historique ?")) start(() => resetSandbox());
|
if (confirm("Remettre ton bac à sable à 200 € et effacer son historique ?")) start(() => resetSandbox());
|
||||||
|
|||||||
@ -18,16 +18,16 @@ export function RunNow() {
|
|||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p className="text-sm text-muted">Normalement tout est automatique. Ces boutons servent à tester.</p>
|
<p className="text-[15px] text-muted">Normalement tout est automatique. Ces boutons servent à tester.</p>
|
||||||
<button className={secondaryBtn} disabled={pending} onClick={() => run("tick")}>
|
<button className={secondaryBtn} disabled={pending} onClick={() => run("tick")}>
|
||||||
Mettre à jour (actus, ordres, stops)
|
Mettre à jour (actus, ordres, stops)
|
||||||
</button>
|
</button>
|
||||||
<button className={secondaryBtn} disabled={pending} onClick={() => run("evening")}>
|
<button className={secondaryBtn} disabled={pending} onClick={() => run("evening")}>
|
||||||
Préparer le rendez-vous maintenant
|
Préparer le rendez-vous maintenant
|
||||||
</button>
|
</button>
|
||||||
{pending && <p className="text-sm text-muted">En cours… (jusqu'à 1-2 minutes)</p>}
|
{pending && <p className="text-[15px] text-muted">En cours… (jusqu'à 1-2 minutes)</p>}
|
||||||
{log && (
|
{log && (
|
||||||
<ul className="mt-1 list-disc pl-5 text-xs text-muted">
|
<ul className="mt-1 list-disc pl-5 text-[13px] text-muted">
|
||||||
{log.length ? log.map((l, i) => <li key={i}>{l}</li>) : <li>Rien à faire pour l'instant.</li>}
|
{log.length ? log.map((l, i) => <li key={i}>{l}</li>) : <li>Rien à faire pour l'instant.</li>}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -20,8 +20,8 @@ export type StockRow = {
|
|||||||
|
|
||||||
const FILTERS = [
|
const FILTERS = [
|
||||||
{ id: "all", label: "Toutes" },
|
{ id: "all", label: "Toutes" },
|
||||||
{ id: "US", label: "🇺🇸 US" },
|
{ id: "US", label: "États-Unis" },
|
||||||
{ id: "EU", label: "🇪🇺 Europe" },
|
{ id: "EU", label: "Europe" },
|
||||||
{ id: "news", label: "Avec actus" },
|
{ id: "news", label: "Avec actus" },
|
||||||
{ id: "up", label: "En hausse" },
|
{ id: "up", label: "En hausse" },
|
||||||
{ id: "down", label: "En baisse" },
|
{ id: "down", label: "En baisse" },
|
||||||
@ -53,55 +53,58 @@ export function StockBrowser({ rows }: { rows: StockRow[] }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<input className={inputCls} placeholder="Rechercher : Apple, LVMH, Airbus…" value={query} onChange={(e) => setQuery(e.target.value)} type="search" />
|
<input className={`${inputCls} bg-surface! dark:border-line`} aria-label="Rechercher une action" placeholder="Apple, LVMH, Airbus…" value={query} onChange={(e) => setQuery(e.target.value)} type="search" />
|
||||||
<div className="-mx-4 flex gap-2 overflow-x-auto px-4 pb-1">
|
<div className="-mx-4 flex gap-2 overflow-x-auto px-4 pb-1" role="group" aria-label="Filtrer les actions">
|
||||||
{FILTERS.map((f) => (
|
{FILTERS.map((f) => (
|
||||||
<button
|
<button
|
||||||
key={f.id}
|
key={f.id}
|
||||||
onClick={() => setFilter(f.id)}
|
onClick={() => setFilter(f.id)}
|
||||||
className={`shrink-0 rounded-full border px-3 py-1.5 text-sm font-medium ${filter === f.id ? "border-accent bg-accent-soft text-accent" : "border-line bg-surface text-muted"}`}
|
aria-pressed={filter === f.id}
|
||||||
|
className={`h-9 shrink-0 rounded-full px-4 text-[14px] font-semibold ${filter === f.id ? "bg-ink text-bg" : "bg-surface text-muted dark:ring-1 dark:ring-line"}`}
|
||||||
>
|
>
|
||||||
{f.label}
|
{f.label}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul className="overflow-hidden rounded-2xl border border-line bg-surface">
|
<ul className="divide-y divide-line overflow-hidden rounded-[22px] bg-surface dark:ring-1 dark:ring-line">
|
||||||
{list.map((r) => (
|
{list.map((r) => (
|
||||||
<li key={r.symbol} className="border-b border-line last:border-0">
|
<li key={r.symbol}>
|
||||||
<Link href={`/actions/${encodeURIComponent(r.symbol)}`} className="flex items-center justify-between gap-3 px-4 py-3 active:bg-surface-2">
|
<Link href={`/actions/${encodeURIComponent(r.symbol)}`} className="flex items-center justify-between gap-3 px-5 py-3.5 active:bg-surface-2">
|
||||||
<span className="min-w-0">
|
<span className="min-w-0">
|
||||||
<span className="flex items-center gap-1.5 font-medium">
|
<span className="flex items-center gap-2 font-semibold">
|
||||||
<span className="truncate">{r.name}</span>
|
<span className="truncate">{r.name}</span>
|
||||||
{r.held && <Badge tone="accent">détenue</Badge>}
|
{r.held && <Badge tone="accent">Détenue</Badge>}
|
||||||
</span>
|
</span>
|
||||||
<span className="block text-xs text-muted">
|
<span className="block text-[13px] text-muted">
|
||||||
{r.symbol}
|
{r.symbol}
|
||||||
{r.news > 0 && ` · 📰 ${r.news} actu${r.news > 1 ? "s" : ""}`}
|
{r.news > 0 && `, ${r.news} actu${r.news > 1 ? "s" : ""} récente${r.news > 1 ? "s" : ""}`}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="shrink-0 text-right">
|
<span className="shrink-0 text-right">
|
||||||
<span className="num block font-semibold">{r.price !== null ? price(r.price, r.currency) : "—"}</span>
|
<span className="amount block text-[1.15rem] font-semibold">{r.price !== null ? price(r.price, r.currency) : "–"}</span>
|
||||||
{r.changePct !== null && <span className={`num text-xs ${r.changePct >= 0 ? "text-accent" : "text-danger"}`}>{pct(r.changePct, 2)}</span>}
|
{r.changePct !== null && <span className={`num text-[13px] font-semibold ${r.changePct >= 0 ? "text-gain" : "text-danger"}`}>{pct(r.changePct, 2)}</span>}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{showHits &&
|
{showHits &&
|
||||||
hits.map((h) => (
|
hits.map((h) => (
|
||||||
<li key={h.symbol} className="border-b border-line last:border-0">
|
<li key={h.symbol}>
|
||||||
<Link href={`/actions/${encodeURIComponent(h.symbol)}`} className="flex items-center justify-between gap-3 px-4 py-3">
|
<Link href={`/actions/${encodeURIComponent(h.symbol)}`} className="flex items-center justify-between gap-3 px-5 py-3.5">
|
||||||
<span>
|
<span>
|
||||||
<span className="font-medium">{h.name}</span>
|
<span className="font-semibold">{h.name}</span>
|
||||||
<span className="block text-xs text-muted">
|
<span className="block text-[13px] text-muted">
|
||||||
{h.symbol} · {h.exchange}
|
{h.symbol}, {h.exchange}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<Badge>{h.type === "ETF" ? "ETF" : "Action"}</Badge>
|
<Badge>{h.type === "ETF" ? "ETF" : "Action"}</Badge>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{!list.length && !(showHits && hits.length) && <li className="px-4 py-6 text-center text-sm text-muted">Aucune action trouvée.</li>}
|
{!list.length && !(showHits && hits.length) && (
|
||||||
|
<li className="px-5 py-8 text-center text-[15px] text-muted">Aucune action ne correspond. Essaie le nom de l'entreprise, par exemple « Airbus ».</li>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -16,14 +16,14 @@ export function StockChart({ bars, lastPrice, stop, target }: { bars: Bar[]; las
|
|||||||
const y = (v: number) => H - 6 - ((v - min) / span) * (H - 12);
|
const y = (v: number) => H - 6 - ((v - min) / span) * (H - 12);
|
||||||
const path = closes.map((c, i) => `${i ? "L" : "M"}${x(i).toFixed(1)},${y(c).toFixed(1)}`).join(" ");
|
const path = closes.map((c, i) => `${i ? "L" : "M"}${x(i).toFixed(1)},${y(c).toFixed(1)}`).join(" ");
|
||||||
const up = closes.at(-1)! >= closes[0];
|
const up = closes.at(-1)! >= closes[0];
|
||||||
const color = up ? "var(--accent)" : "var(--danger)";
|
const color = up ? "var(--gain)" : "var(--danger)";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg viewBox={`0 0 ${W} ${H}`} className="h-32 w-full" preserveAspectRatio="none" role="img" aria-label="Évolution du cours">
|
<svg viewBox={`0 0 ${W} ${H}`} className="h-40 w-full" preserveAspectRatio="none" role="img" aria-label="Évolution du cours">
|
||||||
<path d={`${path} L${W},${H} L0,${H} Z`} fill={color} opacity={0.1} />
|
<path d={`${path} L${W},${H} L0,${H} Z`} fill={color} opacity={0.12} />
|
||||||
<path d={path} fill="none" stroke={color} strokeWidth={2} vectorEffect="non-scaling-stroke" strokeLinejoin="round" />
|
<path d={path} fill="none" stroke={color} strokeWidth={2} vectorEffect="non-scaling-stroke" strokeLinejoin="round" />
|
||||||
{stop != null && <line x1={0} x2={W} y1={y(stop)} y2={y(stop)} stroke="var(--danger)" strokeDasharray="4 4" vectorEffect="non-scaling-stroke" />}
|
{stop != null && <line x1={0} x2={W} y1={y(stop)} y2={y(stop)} stroke="var(--danger)" strokeDasharray="4 4" vectorEffect="non-scaling-stroke" />}
|
||||||
{target != null && <line x1={0} x2={W} y1={y(target)} y2={y(target)} stroke="var(--accent)" strokeDasharray="4 4" vectorEffect="non-scaling-stroke" />}
|
{target != null && <line x1={0} x2={W} y1={y(target)} y2={y(target)} stroke="var(--gain)" strokeDasharray="4 4" vectorEffect="non-scaling-stroke" />}
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,90 +58,91 @@ export function TradePanel({ symbol, currency, lastPrice, fxToEur, cash, askLeft
|
|||||||
setMessage({ ok: r.ok, text: r.message });
|
setMessage({ ok: r.ok, text: r.message });
|
||||||
});
|
});
|
||||||
|
|
||||||
const toggle = (active: boolean) => (active ? "border-accent bg-accent-soft text-accent" : "border-line bg-surface-2 text-muted");
|
const toggle = (active: boolean) => (active ? "bg-ink text-bg" : "bg-surface-2 text-muted");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card title="Acheter dans mon bac à sable" action={<span className="num text-xs text-muted">dispo {eur(cash)}</span>}>
|
<Card title="Acheter dans mon bac à sable">
|
||||||
|
<p className="num -mt-2 mb-4 text-[14px] text-muted">{eur(cash)} disponibles</p>
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<div className="grid grid-cols-2 gap-2 text-sm font-medium">
|
<div className="grid grid-cols-2 gap-2 text-[15px] font-semibold">
|
||||||
<button className={`h-10 rounded-xl border ${toggle(mode === "amount")}`} onClick={() => setMode("amount")}>
|
<button className={`h-10 rounded-full ${toggle(mode === "amount")}`} onClick={() => setMode("amount")}>
|
||||||
Montant en €
|
Montant en €
|
||||||
</button>
|
</button>
|
||||||
<button className={`h-10 rounded-xl border ${toggle(mode === "shares")}`} onClick={() => setMode("shares")}>
|
<button className={`h-10 rounded-full ${toggle(mode === "shares")}`} onClick={() => setMode("shares")}>
|
||||||
Nb d'actions
|
Nb d'actions
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{mode === "amount" ? (
|
{mode === "amount" ? (
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Montant à investir (€)
|
Montant à investir (€)
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={amount} onChange={(e) => setAmount(e.target.value)} />
|
<input className={`${inputCls} mt-1`} inputMode="decimal" value={amount} onChange={(e) => setAmount(e.target.value)} />
|
||||||
<span className="mt-1 flex gap-2">
|
<span className="mt-2 flex gap-2">
|
||||||
{[50, 100, 150].map((v) => (
|
{[50, 100, 150].map((v) => (
|
||||||
<button key={v} className="rounded-full border border-line px-2.5 py-1 text-xs" onClick={() => setAmount(String(v))}>
|
<button key={v} className="h-8 rounded-full bg-surface-2 px-3 text-[13px] font-semibold" onClick={() => setAmount(String(v))}>
|
||||||
{v} €
|
{v} €
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
<button className="rounded-full border border-line px-2.5 py-1 text-xs" onClick={() => setAmount(String(Math.floor(Math.max(cash - 1, 0))))}>
|
<button className="h-8 rounded-full bg-surface-2 px-3 text-[13px] font-semibold" onClick={() => setAmount(String(Math.floor(Math.max(cash - 1, 0))))}>
|
||||||
Tout
|
Tout
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
) : (
|
) : (
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Nombre d'actions (fractions possibles)
|
Nombre d'actions (fractions possibles)
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={shares} onChange={(e) => setShares(e.target.value)} />
|
<input className={`${inputCls} mt-1`} inputMode="decimal" value={shares} onChange={(e) => setShares(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-2 text-sm font-medium">
|
<div className="grid grid-cols-2 gap-2 text-[15px] font-semibold">
|
||||||
<button className={`h-10 rounded-xl border ${toggle(type === "market")}`} onClick={() => setType("market")}>
|
<button className={`h-10 rounded-full ${toggle(type === "market")}`} onClick={() => setType("market")}>
|
||||||
Au marché
|
Au marché
|
||||||
</button>
|
</button>
|
||||||
<button className={`h-10 rounded-xl border ${toggle(type === "limit")}`} onClick={() => setType("limit")}>
|
<button className={`h-10 rounded-full ${toggle(type === "limit")}`} onClick={() => setType("limit")}>
|
||||||
Cours limité
|
Cours limité
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{type === "limit" && (
|
{type === "limit" && (
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
N'acheter que si le cours descend à ({currency === "EUR" ? "€" : "$"})
|
N'acheter que si le cours descend à ({currency === "EUR" ? "€" : "$"})
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={limit} onChange={(e) => setLimit(e.target.value)} />
|
<input className={`${inputCls} mt-1`} inputMode="decimal" value={limit} onChange={(e) => setLimit(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Stop : vendre si −{stop || "?"} %
|
Stop : vendre si −{stop || "?"} %
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={stopPct} onChange={(e) => setStopPct(e.target.value)} placeholder="aucun" />
|
<input className={`${inputCls} mt-1`} inputMode="decimal" value={stopPct} onChange={(e) => setStopPct(e.target.value)} placeholder="aucun" />
|
||||||
</label>
|
</label>
|
||||||
<label className="text-xs text-muted">
|
<label className="text-[13px] text-muted">
|
||||||
Objectif : vendre à +{target || "?"} %
|
Objectif : vendre à +{target || "?"} %
|
||||||
<input className={`${inputCls} mt-1`} inputMode="decimal" value={targetPct} onChange={(e) => setTargetPct(e.target.value)} placeholder="aucun" />
|
<input className={`${inputCls} mt-1`} inputMode="decimal" value={targetPct} onChange={(e) => setTargetPct(e.target.value)} placeholder="aucun" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-xl bg-surface-2 p-3 text-sm">
|
<div className="rounded-2xl bg-surface-2 p-4 text-[15px]">
|
||||||
<p className="num">
|
<p className="num">
|
||||||
≈ {qty.toLocaleString("fr-FR", { maximumFractionDigits: 4 })} action · {eur(costEur)} + 1 € de frais
|
Environ {qty.toLocaleString("fr-FR", { maximumFractionDigits: 4 })} action pour {eur(costEur)}, plus 1 € de frais.
|
||||||
</p>
|
</p>
|
||||||
{stop > 0 && unit > 0 && (
|
{stop > 0 && unit > 0 && (
|
||||||
<p className="num mt-1 text-xs text-muted">
|
<p className="num mt-1.5 text-[14px] leading-relaxed text-muted">
|
||||||
Stop à {price(unit * (1 - stop / 100), currency)} → perte max ≈ {eur(maxLoss ?? 0, 0)}
|
Vente automatique à {price(unit * (1 - stop / 100), currency)} : tu ne perdrais pas plus d'environ {eur(maxLoss ?? 0, 0)}.
|
||||||
{target > 0 && ` · objectif ${price(unit * (1 + target / 100), currency)}`}
|
{target > 0 && ` Objectif de vente à ${price(unit * (1 + target / 100), currency)}.`}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{tooMuch && <p className="mt-1 text-xs text-danger">Pas assez de liquidités dans ton bac à sable.</p>}
|
{tooMuch && <p className="mt-1 text-[13px] text-danger">Pas assez de liquidités dans ton bac à sable.</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button className={primaryBtn} disabled={buying || qty <= 0 || tooMuch} onClick={buy}>
|
<button className={primaryBtn} disabled={buying || qty <= 0 || tooMuch} onClick={buy}>
|
||||||
{buying ? "Envoi…" : "Acheter (argent fictif)"}
|
{buying ? "Envoi…" : "Acheter (argent fictif)"}
|
||||||
</button>
|
</button>
|
||||||
{message && (
|
{message && (
|
||||||
<p className={`text-sm ${message.ok ? "text-accent" : "text-danger"}`}>
|
<p className={`text-[15px] ${message.ok ? "text-gain" : "text-danger"}`}>
|
||||||
{message.text}{" "}
|
{message.text}{" "}
|
||||||
{message.ok && (
|
{message.ok && (
|
||||||
<Link href="/bac-a-sable" className="font-medium underline">
|
<Link href="/bac-a-sable" className="font-semibold underline">
|
||||||
Voir mon bac à sable
|
Voir mon bac à sable
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
@ -150,12 +151,12 @@ export function TradePanel({ symbol, currency, lastPrice, fxToEur, cash, askLeft
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="🤖 L'avis de l'IA">
|
<Card title="L'avis de l'IA">
|
||||||
{!aiOn ? (
|
{!aiOn ? (
|
||||||
<p className="text-sm text-muted">L'IA n'est pas branchée (clé Anthropic manquante, voir le README). Tout le reste fonctionne sans elle.</p>
|
<p className="text-[15px] text-muted">L'IA n'est pas branchée (clé Anthropic manquante, voir le README). Tout le reste fonctionne sans elle.</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p className="text-xs text-muted">{askLeft} avis restant(s) aujourd'hui</p>
|
<p className="text-[13px] text-muted">{askLeft} avis restant(s) aujourd'hui</p>
|
||||||
<input className={inputCls} placeholder="Ex. : c'est le bon moment pour acheter ?" value={question} onChange={(e) => setQuestion(e.target.value)} />
|
<input className={inputCls} placeholder="Ex. : c'est le bon moment pour acheter ?" value={question} onChange={(e) => setQuestion(e.target.value)} />
|
||||||
<button
|
<button
|
||||||
className={secondaryBtn}
|
className={secondaryBtn}
|
||||||
@ -172,14 +173,16 @@ export function TradePanel({ symbol, currency, lastPrice, fxToEur, cash, askLeft
|
|||||||
{asking ? "L'IA réfléchit… (≈ 20 s)" : "Demander son avis"}
|
{asking ? "L'IA réfléchit… (≈ 20 s)" : "Demander son avis"}
|
||||||
</button>
|
</button>
|
||||||
{answer && (
|
{answer && (
|
||||||
<div className="mt-1 flex flex-col gap-2 text-sm">
|
<div className="mt-1 flex flex-col gap-2 text-[15px]">
|
||||||
<p>
|
<p>
|
||||||
<Badge tone={answer.verdict === "acheter" ? "accent" : answer.verdict === "éviter" ? "danger" : "warn"}>{answer.verdict.toUpperCase()}</Badge>{" "}
|
<Badge tone={answer.verdict === "acheter" ? "gain" : answer.verdict === "éviter" ? "danger" : "pot"}>
|
||||||
|
{answer.verdict.charAt(0).toUpperCase() + answer.verdict.slice(1)}
|
||||||
|
</Badge>{" "}
|
||||||
<span className="text-muted">confiance {Math.round(answer.confidence)} %</span>
|
<span className="text-muted">confiance {Math.round(answer.confidence)} %</span>
|
||||||
</p>
|
</p>
|
||||||
<p className="leading-relaxed">{answer.explanation}</p>
|
<p className="leading-relaxed">{answer.explanation}</p>
|
||||||
<p className="leading-relaxed text-muted">⚠️ {answer.risks}</p>
|
<p className="leading-relaxed text-muted">Risques : {answer.risks}</p>
|
||||||
<button className="self-start text-sm font-medium text-accent" onClick={() => setStopPct(String(Math.round(answer.suggestedStopPct)))}>
|
<button className="self-start text-[15px] font-semibold text-accent" onClick={() => setStopPct(String(Math.round(answer.suggestedStopPct)))}>
|
||||||
Utiliser son stop conseillé ({Math.round(answer.suggestedStopPct)} %)
|
Utiliser son stop conseillé ({Math.round(answer.suggestedStopPct)} %)
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -199,7 +202,7 @@ function RealProposal({ symbol, stopPct }: { symbol: string; stopPct: number })
|
|||||||
const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null);
|
const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null);
|
||||||
return (
|
return (
|
||||||
<Card title="Pour de vrai (Trade Republic)">
|
<Card title="Pour de vrai (Trade Republic)">
|
||||||
<p className="mb-3 text-sm text-muted">Le contrôle des risques vérifie la taille et le stop, puis te prépare une fiche pas à pas.</p>
|
<p className="mb-3 text-[15px] text-muted">Le contrôle des risques vérifie la taille et le stop, puis te prépare une fiche pas à pas.</p>
|
||||||
<button
|
<button
|
||||||
className={`${secondaryBtn} w-full`}
|
className={`${secondaryBtn} w-full`}
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
@ -212,7 +215,7 @@ function RealProposal({ symbol, stopPct }: { symbol: string; stopPct: number })
|
|||||||
>
|
>
|
||||||
Vérifier et créer la fiche réelle
|
Vérifier et créer la fiche réelle
|
||||||
</button>
|
</button>
|
||||||
{msg && <p className={`mt-2 text-sm ${msg.ok ? "text-accent" : "text-danger"}`}>{msg.text}</p>}
|
{msg && <p className={`mt-2 text-[15px] ${msg.ok ? "text-gain" : "text-danger"}`}>{msg.text}</p>}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,28 +1,36 @@
|
|||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
/** Une page : grand titre à gauche, sous-titre court, action éventuelle en haut à droite. */
|
||||||
export function Page({ title, subtitle, action, children }: { title: string; subtitle?: ReactNode; action?: ReactNode; children: ReactNode }) {
|
export function Page({ title, subtitle, action, children }: { title: string; subtitle?: ReactNode; action?: ReactNode; children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<main className="mx-auto w-full max-w-lg px-4 pb-28 pt-[max(env(safe-area-inset-top),1.25rem)]">
|
<main className="mx-auto w-full max-w-lg px-4 pb-32 pt-[max(env(safe-area-inset-top),1.5rem)]">
|
||||||
<header className="mb-5 flex items-start justify-between gap-3">
|
<header className="mb-6 flex items-start justify-between gap-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
|
<h1 className="display text-[2.1rem] font-bold">{title}</h1>
|
||||||
{subtitle && <p className="mt-1 text-sm text-muted">{subtitle}</p>}
|
{subtitle && <p className="mt-2 max-w-[34ch] text-[15px] leading-snug text-muted">{subtitle}</p>}
|
||||||
</div>
|
</div>
|
||||||
{action && <div className="shrink-0 pt-1">{action}</div>}
|
{action && <div className="shrink-0 pt-1.5">{action}</div>}
|
||||||
</header>
|
</header>
|
||||||
<div className="flex flex-col gap-4">{children}</div>
|
<div className="flex flex-col gap-4">{children}</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Card({ title, action, children, tone }: { title?: ReactNode; action?: ReactNode; children: ReactNode; tone?: "accent" | "warn" | "danger" }) {
|
type Tone = "accent" | "warn" | "danger" | "pot";
|
||||||
const toneCls =
|
|
||||||
tone === "accent" ? "border-accent/40" : tone === "warn" ? "border-warn/40" : tone === "danger" ? "border-danger/40" : "border-line";
|
/** Un bloc de la page. `tone` le met en avant (à faire, à configurer, alerte). */
|
||||||
|
export function Card({ title, action, children, tone }: { title?: ReactNode; action?: ReactNode; children: ReactNode; tone?: Tone }) {
|
||||||
|
const toneCls = {
|
||||||
|
accent: "bg-surface ring-2 ring-accent/45",
|
||||||
|
warn: "bg-pot-soft",
|
||||||
|
pot: "bg-pot-soft",
|
||||||
|
danger: "bg-danger-soft",
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<section className={`rounded-2xl border bg-surface p-4 ${toneCls}`}>
|
<section className={`rounded-[22px] p-5 ${tone ? toneCls[tone] : "bg-surface dark:ring-1 dark:ring-line"}`}>
|
||||||
{(title || action) && (
|
{(title || action) && (
|
||||||
<div className="mb-3 flex items-center justify-between gap-3">
|
<div className="mb-4 flex items-center justify-between gap-3">
|
||||||
{title && <h2 className="text-sm font-semibold uppercase tracking-wide text-muted">{title}</h2>}
|
{title && <h2 className="display text-[1.2rem] font-semibold">{title}</h2>}
|
||||||
{action}
|
{action}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -31,46 +39,50 @@ export function Card({ title, action, children, tone }: { title?: ReactNode; act
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Badge({ children, tone = "neutral" }: { children: ReactNode; tone?: "neutral" | "accent" | "warn" | "danger" }) {
|
export function Badge({ children, tone = "neutral" }: { children: ReactNode; tone?: "neutral" | "accent" | "warn" | "danger" | "gain" | "pot" }) {
|
||||||
const cls = {
|
const cls = {
|
||||||
neutral: "bg-surface-2 text-muted",
|
neutral: "bg-surface-2 text-muted",
|
||||||
accent: "bg-accent-soft text-accent",
|
accent: "bg-accent-soft text-accent",
|
||||||
warn: "bg-warn-soft text-warn",
|
warn: "bg-warn-soft text-warn",
|
||||||
|
pot: "bg-pot-soft text-pot",
|
||||||
|
gain: "bg-gain-soft text-gain",
|
||||||
danger: "bg-danger-soft text-danger",
|
danger: "bg-danger-soft text-danger",
|
||||||
}[tone];
|
}[tone];
|
||||||
return <span className={`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${cls}`}>{children}</span>;
|
return <span className={`inline-flex items-center rounded-md px-2 py-0.5 text-[13px] font-semibold ${cls}`}>{children}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Un gain en vert, une perte en rouge. */
|
||||||
export function Delta({ value, children }: { value: number; children: ReactNode }) {
|
export function Delta({ value, children }: { value: number; children: ReactNode }) {
|
||||||
return <span className={`num font-medium ${value >= 0 ? "text-accent" : "text-danger"}`}>{children}</span>;
|
return <span className={`num font-semibold ${value >= 0 ? "text-gain" : "text-danger"}`}>{children}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Bloc de chargement pour une section qui attend des cours de bourse. */
|
/** Bloc de chargement : la forme de la section, pendant que les cours arrivent. */
|
||||||
export function CardSkeleton({ title, height = "h-24" }: { title?: string; height?: string }) {
|
export function CardSkeleton({ title, height = "h-24" }: { title?: string; height?: string }) {
|
||||||
return (
|
return (
|
||||||
<section className="rounded-2xl border border-line bg-surface p-4">
|
<section className="rounded-[22px] bg-surface p-5 dark:ring-1 dark:ring-line" aria-busy="true">
|
||||||
{title && <h2 className="mb-3 text-sm font-semibold uppercase tracking-wide text-muted">{title}</h2>}
|
{title ? <h2 className="display mb-4 text-[1.2rem] font-semibold text-muted">{title}</h2> : <div className="skeleton mb-4 h-5 w-32 rounded-md" />}
|
||||||
<div className={`${height} animate-pulse rounded-xl bg-surface-2`} />
|
<div className={`${height} skeleton rounded-2xl`} />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Un chiffre et sa légende, séparés des voisins par un filet. À placer dans une grille. */
|
||||||
export function Stat({ label, children }: { label: string; children: ReactNode }) {
|
export function Stat({ label, children }: { label: string; children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl bg-surface-2 p-2.5 text-center">
|
<div className="min-w-0 border-l border-line pl-3 first:border-l-0 first:pl-0">
|
||||||
<p className="num font-semibold">{children}</p>
|
<p className="amount truncate text-[1.35rem] font-semibold">{children}</p>
|
||||||
<p className="text-xs text-muted">{label}</p>
|
<p className="mt-1 text-[13px] text-muted">{label}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Empty({ children }: { children: ReactNode }) {
|
export function Empty({ children }: { children: ReactNode }) {
|
||||||
return <p className="py-2 text-sm text-muted">{children}</p>;
|
return <p className="py-1 text-[15px] leading-relaxed text-muted">{children}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buttonCls =
|
export const buttonCls =
|
||||||
"inline-flex h-11 items-center justify-center rounded-xl px-4 text-sm font-semibold transition active:scale-[0.98] disabled:opacity-50";
|
"inline-flex h-12 items-center justify-center gap-2 rounded-full px-5 text-[15px] font-bold transition-transform active:scale-[0.98] disabled:opacity-45";
|
||||||
export const primaryBtn = `${buttonCls} bg-accent text-white dark:text-black`;
|
export const primaryBtn = `${buttonCls} bg-accent text-accent-ink`;
|
||||||
export const secondaryBtn = `${buttonCls} border border-line bg-surface-2 text-ink`;
|
export const secondaryBtn = `${buttonCls} bg-surface-2 text-ink`;
|
||||||
export const inputCls =
|
export const inputCls =
|
||||||
"h-11 w-full rounded-xl border border-line bg-surface-2 px-3 text-base text-ink outline-none focus:border-accent";
|
"h-12 w-full rounded-xl border border-transparent bg-surface-2 px-3.5 text-base text-ink outline-none placeholder:text-muted/70 focus:border-accent";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user