"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(null); const [pending, start] = useTransition(); return (
{op.emoji} {op.label}
prévu le {formatDateFr(op.date)} · {op.kind === "EXPENSE" ? "payé par" : "reçu par"} {op.who}
{error &&
{error}
}
setAmount(e.target.value)} /> setDate(e.target.value)} />
); }