From 74afe6da2d982003de0f02f3657a1bfbfc18f639 Mon Sep 17 00:00:00 2001 From: Thomas Huber Date: Mon, 3 Aug 2026 10:51:57 +0200 Subject: [PATCH] feat: #94 Loan summary text for double checking in the create transaction dialog. Also improved the formating of the dialog (white fields on gray background) (cherry picked from commit 1c06ffaec38ff30190f261d86a2bdb327c45ecfa) --- src/components/form/form-date-picker.tsx | 10 ++- src/components/form/form-number-input.tsx | 12 ++- src/components/form/form-select.tsx | 5 +- .../loans/loan-add-transaction-control.tsx | 2 +- src/components/loans/transaction-dialog.tsx | 32 ++++++- .../loans/transaction-form-fields.tsx | 4 + .../loans/transaction-dialog-loan-context.ts | 85 +++++++++++++++++++ src/messages/de/dashboard.json | 6 ++ 8 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 src/lib/loans/transaction-dialog-loan-context.ts diff --git a/src/components/form/form-date-picker.tsx b/src/components/form/form-date-picker.tsx index 4f178e54..53ca41ef 100644 --- a/src/components/form/form-date-picker.tsx +++ b/src/components/form/form-date-picker.tsx @@ -10,9 +10,16 @@ interface FormDatePickerProps { label?: string; placeholder?: string; disabled?: (date: Date) => boolean; + className?: string; } -export function FormDatePicker({ name, label, placeholder = 'Pick a date', disabled }: FormDatePickerProps) { +export function FormDatePicker({ + name, + label, + placeholder = 'Pick a date', + disabled, + className, +}: FormDatePickerProps) { const form = useFormContext(); return ( @@ -28,6 +35,7 @@ export function FormDatePicker({ name, label, placeholder = 'Pick a date', disab onChange={(date) => field.onChange(date ?? '')} placeholder={placeholder} calendarDisabled={disabled} + className={className} /> diff --git a/src/components/form/form-number-input.tsx b/src/components/form/form-number-input.tsx index be941910..2b493eaa 100644 --- a/src/components/form/form-number-input.tsx +++ b/src/components/form/form-number-input.tsx @@ -4,7 +4,7 @@ import { useFormContext } from 'react-hook-form'; import { FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; -import { NumberParser } from '@/lib/utils'; +import { cn, NumberParser } from '@/lib/utils'; interface FormNumberInputProps { name: string; @@ -18,6 +18,7 @@ interface FormNumberInputProps { minimumFractionDigits?: number; maximumFractionDigits?: number; autoFocus?: boolean; + className?: string; } export function FormNumberInput({ @@ -32,6 +33,7 @@ export function FormNumberInput({ minimumFractionDigits = 2, maximumFractionDigits = 2, autoFocus, + className, }: FormNumberInputProps) { const form = useFormContext(); @@ -77,9 +79,11 @@ export function FormNumberInput({ const value = parser.strip(event.target.value); field.onChange(value); }} - className={`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none ${ - prefix ? 'pl-12 ' : '' - }`} + className={cn( + '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', + prefix && 'pl-12', + className, + )} /> diff --git a/src/components/form/form-select.tsx b/src/components/form/form-select.tsx index 39d2d99e..ec9857f5 100644 --- a/src/components/form/form-select.tsx +++ b/src/components/form/form-select.tsx @@ -13,6 +13,7 @@ import { FormMessage, } from '@/components/ui/form'; import { Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { cn } from '@/lib/utils'; type SelectOption = | { @@ -35,6 +36,7 @@ interface FormSelectProps { align?: 'start' | 'center' | 'end'; customContent?: () => ReactNode; clearable?: boolean; + className?: string; } export function FormSelect({ @@ -49,6 +51,7 @@ export function FormSelect({ align = 'start', customContent, clearable = false, + className, }: FormSelectProps) { const t = useTranslations('common'); const form = useFormContext(); @@ -63,7 +66,7 @@ export function FormSelect({