Add payment method selection

Adds a payment method selection (Credit Card, Cash) to the expense form and includes a line separator. Also requests to add a graph showing the proportion of credit card and cash usage in expense analytics, but this part is not implemented in this commit.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 07:08:02 +00:00
parent 60ef765380
commit aa8381a823
12 changed files with 489 additions and 23 deletions

View File

@@ -8,11 +8,14 @@ import { Loader2 } from 'lucide-react';
import ExpenseCategorySelector from './ExpenseCategorySelector';
import { Badge } from '@/components/ui/badge';
import { getPersonalizedTitleSuggestions } from '@/utils/userTitlePreferences';
import { Separator } from '@/components/ui/separator';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
export interface ExpenseFormValues {
title: string;
amount: string;
category: string;
paymentMethod: '신용카드' | '현금';
}
interface ExpenseFormProps {
@@ -27,6 +30,7 @@ const ExpenseForm: React.FC<ExpenseFormProps> = ({ onSubmit, onCancel, isSubmitt
title: '',
amount: '',
category: '음식',
paymentMethod: '신용카드'
}
});
@@ -113,7 +117,7 @@ const ExpenseForm: React.FC<ExpenseFormProps> = ({ onSubmit, onCancel, isSubmitt
)}
/>
{/* 금액 필드를 마지막으로 배치 */}
{/* 금액 필드를 세 번째로 배치 */}
<FormField
control={form.control}
name="amount"
@@ -130,6 +134,36 @@ const ExpenseForm: React.FC<ExpenseFormProps> = ({ onSubmit, onCancel, isSubmitt
)}
/>
{/* 구분선 추가 */}
<Separator className="my-2" />
{/* 지출 방법 필드 추가 */}
<FormField
control={form.control}
name="paymentMethod"
render={({ field }) => (
<FormItem>
<FormLabel> </FormLabel>
<RadioGroup
onValueChange={field.onChange}
defaultValue={field.value}
className="flex gap-4"
value={field.value}
disabled={isSubmitting}
>
<div className="flex items-center space-x-2">
<RadioGroupItem value="신용카드" id="credit-card" />
<label htmlFor="credit-card" className="cursor-pointer"></label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="현금" id="cash" />
<label htmlFor="cash" className="cursor-pointer"></label>
</div>
</RadioGroup>
</FormItem>
)}
/>
<div className="flex justify-end gap-2 pt-2">
<Button
type="button"