Refactor expense form and categories

-   Rename "지출 추가" to "지출 입력" in the add expense dialog.
-   Rename "교통비" to "교통" in categories and ensure all 4 icons are displayed on a single line.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 06:45:50 +00:00
parent c1a64ed711
commit 508eea9cde
5 changed files with 13 additions and 12 deletions

View File

@@ -1,4 +1,3 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { PlusIcon } from 'lucide-react'; import { PlusIcon } from 'lucide-react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog';
@@ -155,7 +154,7 @@ const AddTransactionButton = () => {
}}> }}>
<DialogContent className="w-[90%] max-w-sm mx-auto"> <DialogContent className="w-[90%] max-w-sm mx-auto">
<DialogHeader> <DialogHeader>
<DialogTitle> </DialogTitle> <DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<ExpenseForm <ExpenseForm
onSubmit={onSubmit} onSubmit={onSubmit}

View File

@@ -17,7 +17,7 @@ const ExpenseCategorySelector: React.FC<ExpenseCategorySelectorProps> = ({
<FormControl> <FormControl>
<ToggleGroup <ToggleGroup
type="single" type="single"
className="justify-start flex-wrap gap-2" className="justify-between flex-nowrap gap-1"
value={value} value={value}
onValueChange={(value) => { onValueChange={(value) => {
if (value) onValueChange(value); if (value) onValueChange(value);
@@ -27,7 +27,7 @@ const ExpenseCategorySelector: React.FC<ExpenseCategorySelectorProps> = ({
<ToggleGroupItem <ToggleGroupItem
key={category} key={category}
value={category} value={category}
className="px-4 py-2 rounded-md border flex items-center gap-2" className="px-3 py-2 rounded-md border flex items-center gap-1"
> >
<div className="text-neuro-income"> <div className="text-neuro-income">
{categoryIcons[category]} {categoryIcons[category]}

View File

@@ -10,7 +10,7 @@ import { categoryIcons, EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
export const transactionFormSchema = z.object({ export const transactionFormSchema = z.object({
title: z.string().min(1, '제목을 입력해주세요'), title: z.string().min(1, '제목을 입력해주세요'),
amount: z.string().min(1, '금액을 입력해주세요'), amount: z.string().min(1, '금액을 입력해주세요'),
category: z.enum(['음식', '쇼핑', '교통', '기타']), category: z.enum(['음식', '쇼핑', '교통', '기타']),
}); });
export type TransactionFormValues = z.infer<typeof transactionFormSchema>; export type TransactionFormValues = z.infer<typeof transactionFormSchema>;
@@ -40,7 +40,7 @@ const TransactionFormFields: React.FC<TransactionFormFieldsProps> = ({ form }) =
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel></FormLabel> <FormLabel></FormLabel>
<div className="grid grid-cols-2 gap-2"> <div className="grid grid-cols-4 gap-2">
{EXPENSE_CATEGORIES.map((category) => ( {EXPENSE_CATEGORIES.map((category) => (
<div <div
key={category} key={category}

View File

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

View File

@@ -6,29 +6,30 @@ import { Coffee, Home, Car, Package, Banknote } from 'lucide-react';
export const categoryIcons: Record<string, React.ReactNode> = { export const categoryIcons: Record<string, React.ReactNode> = {
: <Coffee size={18} />, : <Coffee size={18} />,
: <Home size={18} />, : <Home size={18} />,
: <Car size={18} />, : <Car size={18} />,
: <Package size={18} />, : <Package size={18} />,
: <Banknote size={18} />, : <Banknote size={18} />,
}; };
// 지출 카테고리 목록 - 4개로 확장 // 지출 카테고리 목록 - 4개로 확장
export const EXPENSE_CATEGORIES = ['음식', '쇼핑', '교통', '기타']; export const EXPENSE_CATEGORIES = ['음식', '쇼핑', '교통', '기타'];
// 카테고리 부가 설명 정의 // 카테고리 부가 설명 정의
export const CATEGORY_DESCRIPTIONS: Record<string, string> = { export const CATEGORY_DESCRIPTIONS: Record<string, string> = {
: '(식비, 음료)', : '(식비, 음료)',
: '', : '',
: '(차량 유지비)', : '(차량 유지비)',
: '(기타 지출)', : '(기타 지출)',
: '(식비, 음료)', // 이전 이름과의 호환성 유지 : '(식비, 음료)', // 이전 이름과의 호환성 유지
: '', // 이전 이름과의 호환성 유지 : '', // 이전 이름과의 호환성 유지
: '(차량 유지비)', // 이전 이름과의 호환성 유지
}; };
// 기본 카테고리 예산 설정 // 기본 카테고리 예산 설정
export const DEFAULT_CATEGORY_BUDGETS = { export const DEFAULT_CATEGORY_BUDGETS = {
음식: 400000, 음식: 400000,
쇼핑: 600000, 쇼핑: 600000,
교통: 200000, 교통: 200000,
기타: 100000 기타: 100000
}; };