Implement additional improvements
This commit implements additional improvements as requested.
This commit is contained in:
@@ -1,18 +1,8 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Coffee, Home, Car } from 'lucide-react';
|
||||
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
|
||||
import { FormControl } from '@/components/ui/form';
|
||||
|
||||
// Define expense categories
|
||||
export const EXPENSE_CATEGORIES = ['식비', '생활비', '교통비'];
|
||||
|
||||
// Define category icons mapping
|
||||
export const categoryIcons: Record<string, React.ReactNode> = {
|
||||
식비: <Coffee size={18} />,
|
||||
생활비: <Home size={18} />,
|
||||
교통비: <Car size={18} />,
|
||||
};
|
||||
import { categoryIcons, EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
|
||||
|
||||
interface ExpenseCategorySelectorProps {
|
||||
value: string;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
import React from 'react';
|
||||
import { FormField, FormItem, FormLabel, FormControl, FormMessage } from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Coffee, Home, Car } from 'lucide-react';
|
||||
import { UseFormReturn } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { categoryIcons, EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
|
||||
|
||||
// Form schema for validation
|
||||
export const transactionFormSchema = z.object({
|
||||
title: z.string().min(1, '제목을 입력해주세요'),
|
||||
amount: z.string().min(1, '금액을 입력해주세요'),
|
||||
category: z.enum(['식비', '생활비', '교통비']),
|
||||
category: z.enum(['식비', '생활비', '교통비', '쇼핑', '교육', '의료', '여행', '기타']),
|
||||
});
|
||||
|
||||
export type TransactionFormValues = z.infer<typeof transactionFormSchema>;
|
||||
@@ -21,12 +21,6 @@ export const formatWithCommas = (value: string) => {
|
||||
return numericValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
};
|
||||
|
||||
export const categoryIcons: Record<string, React.ReactNode> = {
|
||||
식비: <Coffee size={18} />,
|
||||
생활비: <Home size={18} />,
|
||||
교통비: <Car size={18} />,
|
||||
};
|
||||
|
||||
interface TransactionFormFieldsProps {
|
||||
form: UseFormReturn<TransactionFormValues>;
|
||||
}
|
||||
@@ -78,7 +72,7 @@ const TransactionFormFields: React.FC<TransactionFormFieldsProps> = ({ form }) =
|
||||
<FormItem>
|
||||
<FormLabel>카테고리</FormLabel>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{['식비', '생활비', '교통비'].map((category) => (
|
||||
{EXPENSE_CATEGORIES.map((category) => (
|
||||
<div
|
||||
key={category}
|
||||
className={`flex items-center gap-2 p-2 rounded-md cursor-pointer border ${
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Coffee, Home, Car } from 'lucide-react';
|
||||
|
||||
export const categoryIcons: Record<string, React.ReactNode> = {
|
||||
식비: <Coffee size={18} />,
|
||||
생활비: <Home size={18} />,
|
||||
교통비: <Car size={18} />,
|
||||
};
|
||||
import { Coffee } from 'lucide-react';
|
||||
import { categoryIcons } from '@/constants/categoryIcons';
|
||||
|
||||
interface TransactionIconProps {
|
||||
category: string;
|
||||
|
||||
Reference in New Issue
Block a user