Add "기타" category

Adds "기타" category to the existing categories.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 06:31:08 +00:00
parent a8f29e669f
commit 8de82b17f0
7 changed files with 25 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ const ExpenseForm: React.FC<ExpenseFormProps> = ({ onSubmit, onCancel, isSubmitt
defaultValues: {
title: '',
amount: '',
category: '식',
category: '식',
}
});

View File

@@ -6,11 +6,11 @@ import { UseFormReturn } from 'react-hook-form';
import { z } from 'zod';
import { categoryIcons, EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
// Form schema for validation - 카테고리를 3개로 제한
// Form schema for validation - 카테고리를 4개로 확장
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>;
@@ -40,7 +40,7 @@ const TransactionFormFields: React.FC<TransactionFormFieldsProps> = ({ form }) =
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<div className="grid grid-cols-3 gap-2">
<div className="grid grid-cols-2 gap-2">
{EXPENSE_CATEGORIES.map((category) => (
<div
key={category}

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { Coffee } from 'lucide-react';
import { Coffee, Package } from 'lucide-react';
import { categoryIcons } from '@/constants/categoryIcons';
interface TransactionIconProps {
@@ -8,8 +8,8 @@ interface TransactionIconProps {
}
const TransactionIcon: React.FC<TransactionIconProps> = ({ category }) => {
// 카테고리에 해당하는 아이콘이 없을 경우 기본값으로 Coffee 아이콘 사용
const icon = categoryIcons[category] || <Coffee size={18} />;
// 카테고리에 해당하는 아이콘이 없을 경우 기본값으로 Package 아이콘 사용
const icon = categoryIcons[category] || <Package size={18} />;
return (
<div className="p-2 rounded-full bg-neuro-income/10 text-neuro-income">

View File

@@ -4,10 +4,10 @@ import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
/**
* 카테고리 매핑 함수 - 이전 카테고리명을 새 카테고리명으로 변환
*/
export const mapCategoryToNew = (oldCategory: string): "음식" | "쇼핑" | "교통비" => {
export const mapCategoryToNew = (oldCategory: string): "음식" | "쇼핑" | "교통비" | "기타" => {
if (oldCategory === '식비') return '음식';
if (oldCategory === '생활비') return '쇼핑';
if (EXPENSE_CATEGORIES.includes(oldCategory as any)) return oldCategory as "음식" | "쇼핑" | "교통비";
// 기본값은 '쇼핑'으로 설정
return '쇼핑';
if (EXPENSE_CATEGORIES.includes(oldCategory as any)) return oldCategory as "음식" | "쇼핑" | "교통비" | "기타";
// 기본값은 '기타'로 설정
return '기타';
};