feat: recurring templates, planned and to-confirm lists

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
YugonitoandClaude Opus 5.5 committed 2026-10-27 18:25:40 +01:00
1 parent 63620f8c52
commit bfaa38510b
10 files changed
+792

No files matched your search

@@ -0,0 +1,52 @@
"use client";
import { useState, useTransition } from "react";
import { decimalFromCents } from "@/domain/money";
import type { OpKind } from "@/domain/types";
import { formatDateFr } from "@/lib/dates";
import { confirmOperationAction, skipOperationAction } from "@/server/actions/operations";
import { Button } from "../ui/Button";
import { Input } from "../ui/Field";
export function ToConfirmRow({
op,
}: {
op: { id: string; label: string; emoji: string; amount: number; date: string; kind: OpKind; who: string };
}) {
const [amount, setAmount] = useState(decimalFromCents(op.amount).replace(".", ","));
const [date, setDate] = useState(op.date);
const [error, setError] = useState<string | null>(null);
const [pending, start] = useTransition();
return (
<div className="flex flex-col gap-2 border-b border-line-soft py-3 last:border-0 md:flex-row md:items-center">
<div className="min-w-0 flex-1">
<b>
{op.emoji} {op.label}
</b>
<div className="text-[13px] text-muted">
prévu le {formatDateFr(op.date)} · {op.kind === "EXPENSE" ? "payé par" : "reçu par"} {op.who}
</div>
{error && <div className="text-[13px] text-neg">{error}</div>}
</div>
<div className="flex flex-wrap items-center gap-2">
<Input aria-label="Montant" inputMode="decimal" className="w-28" value={amount} onChange={(e) => setAmount(e.target.value)} />
<Input aria-label="Date" type="date" className="w-40" value={date} onChange={(e) => setDate(e.target.value)} />
<Button
disabled={pending}
onClick={() =>
start(async () => {
const r = await confirmOperationAction(op.id, amount, date);
setError(r.ok ? null : r.error);
})
}
>
Confirmer
</Button>
<Button variant="ghost" disabled={pending} onClick={() => start(async () => void (await skipOperationAction(op.id)))}>
Ignorer
</Button>
</div>
</div>
);
}