diff --git a/frontend/src/components/InlineEditCell.tsx b/frontend/src/components/InlineEditCell.tsx index fbbdc93..ce19bb9 100644 --- a/frontend/src/components/InlineEditCell.tsx +++ b/frontend/src/components/InlineEditCell.tsx @@ -1,4 +1,5 @@ import { useState } from 'react' +import { Pencil } from 'lucide-react' import { TableCell } from '@/components/ui/table' import { Input } from '@/components/ui/input' import { formatCurrency } from '@/lib/format' @@ -8,10 +9,12 @@ interface InlineEditCellProps { value: number currency: string onSave: (value: number) => Promise + onSaveSuccess?: () => void + onSaveError?: () => void className?: string } -export function InlineEditCell({ value, currency, onSave, className }: InlineEditCellProps) { +export function InlineEditCell({ value, currency, onSave, onSaveSuccess, onSaveError, className }: InlineEditCellProps) { const [editing, setEditing] = useState(false) const [inputValue, setInputValue] = useState(String(value)) @@ -23,7 +26,13 @@ export function InlineEditCell({ value, currency, onSave, className }: InlineEdi const handleBlur = async () => { const num = parseFloat(inputValue) if (!isNaN(num) && num !== value) { - await onSave(num) + try { + await onSave(num) + onSaveSuccess?.() + } catch { + setInputValue(String(value)) + onSaveError?.() + } } setEditing(false) } @@ -49,10 +58,14 @@ export function InlineEditCell({ value, currency, onSave, className }: InlineEdi /> ) : ( {formatCurrency(value, currency)} + )}