trading-app/src/app/(app)/reglages/page.tsx
David 234efda586 Fix trade proposals, speed, Trade Republic setup and stock UI
- Buy by EUR amount (fractional shares, like Trade Republic): 200 EUR can
  now reach every large cap; risk engine sizes in whole euros
- No-AI screener (pullback in uptrend) feeds training cards and AI candidates
- Auto-update on app open via after(); "find ideas now" button (3/day)
- New Actions tab: stock list, stock page with chart, news, AI opinion,
  sandbox buy by amount or shares
- "Mon compte" tab: declare deposits, cash, holdings and PEA plan
  (no broker credentials, no PEA invented by default)
- Yahoo data cached and deduplicated, pages stream per section
- Tests: fractional sizing, screener, no-AI idea flow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 19:05:20 +01:00

88 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Suspense } from "react";
import Link from "next/link";
import { connection } from "next/server";
import { logout, saveSettings } from "@/app/actions";
import { PushManager } from "@/components/push-manager";
import { RunNow } from "@/components/run-now";
import { Card, CardSkeleton, inputCls, Page, primaryBtn, secondaryBtn } from "@/components/ui";
import { aiEnabled } from "@/lib/ai";
import { getSettings } from "@/lib/settings";
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
return (
<label className="flex flex-col gap-1 text-sm">
<span className="font-medium">{label}</span>
{children}
{hint && <span className="text-xs text-muted">{hint}</span>}
</label>
);
}
async function SettingsForm() {
await connection();
const s = await getSettings();
const hh = String(Math.floor(s.rendezvousMinutes / 60)).padStart(2, "0");
const mm = String(s.rendezvousMinutes % 60).padStart(2, "0");
return (
<form action={saveSettings}>
<Card title="Rendez-vous et IA">
<div className="flex flex-col gap-3">
<Field label="Heure du rendez-vous" hint="Le soir, en semaine. L'IA prépare tes fiches 30 minutes avant.">
<input className={inputCls} type="time" name="rendezvous" defaultValue={`${hh}:${mm}`} />
</Field>
<Field
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)."}
>
<input className={inputCls} name="aiBudget" inputMode="decimal" defaultValue={s.aiMonthlyBudgetUsd} />
</Field>
<button className={primaryBtn} type="submit">
Enregistrer
</button>
</div>
</Card>
</form>
);
}
export default function SettingsPage() {
return (
<Page
title="Réglages"
action={
<Link href="/" className="text-sm font-medium text-accent">
‹ Accueil
</Link>
}
>
<Card title="Notifications iPhone">
<PushManager />
</Card>
<Suspense fallback={<CardSkeleton title="Rendez-vous et IA" />}>
<SettingsForm />
</Suspense>
<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&apos;onglet « Mon compte ».</p>
<Link href="/reel" className={`${secondaryBtn} w-full`}>
Ouvrir Mon compte
</Link>
</Card>
<Card title="Lancer à la main">
<RunNow />
</Card>
<form action={logout}>
<button className={`${secondaryBtn} w-full`} type="submit">
Se déconnecter
</button>
</form>
<p className="text-center text-xs leading-relaxed text-muted">
Outil d&apos;aide à la décision, pas un conseil en investissement. Les performances passées ne préjugent pas des performances futures.
</p>
</Page>
);
}