Fix type errors in BudgetContext

Addresses type errors related to category budgets in BudgetContext and Index page. Specifically, ensures correct type assignment for category budget updates.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 10:54:24 +00:00
parent 53096ae26e
commit bbf0f75b66
4 changed files with 35 additions and 65 deletions

View File

@@ -1,16 +1,11 @@
import React from 'react';
import { Input } from '@/components/ui/input';
interface CategoryBudget {
식비: number;
생활비: number;
교통비: number;
}
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
interface CategoryBudgetInputsProps {
categoryBudgets: CategoryBudget;
handleCategoryInputChange: (value: string, category: keyof CategoryBudget) => void;
categoryBudgets: Record<string, number>;
handleCategoryInputChange: (value: string, category: string) => void;
}
const CategoryBudgetInputs: React.FC<CategoryBudgetInputsProps> = ({
@@ -23,7 +18,7 @@ const CategoryBudgetInputs: React.FC<CategoryBudgetInputsProps> = ({
};
// Handle input with comma formatting
const handleInput = (e: React.ChangeEvent<HTMLInputElement>, category: keyof CategoryBudget) => {
const handleInput = (e: React.ChangeEvent<HTMLInputElement>, category: string) => {
// Remove all non-numeric characters before passing to parent handler
const numericValue = e.target.value.replace(/[^0-9]/g, '');
handleCategoryInputChange(numericValue, category);
@@ -31,32 +26,16 @@ const CategoryBudgetInputs: React.FC<CategoryBudgetInputsProps> = ({
return (
<div className="space-y-2">
<div className="flex items-center justify-between">
<label className="text-sm text-gray-600"></label>
<Input
value={formatWithCommas(categoryBudgets.)}
onChange={(e) => handleInput(e, '식비')}
className="neuro-pressed max-w-[150px]"
/>
</div>
<div className="flex items-center justify-between">
<label className="text-sm text-gray-600"></label>
<Input
value={formatWithCommas(categoryBudgets.)}
onChange={(e) => handleInput(e, '생활비')}
className="neuro-pressed max-w-[150px]"
/>
</div>
<div className="flex items-center justify-between">
<label className="text-sm text-gray-600"></label>
<Input
value={formatWithCommas(categoryBudgets.)}
onChange={(e) => handleInput(e, '교통비')}
className="neuro-pressed max-w-[150px]"
/>
</div>
{EXPENSE_CATEGORIES.map(category => (
<div key={category} className="flex items-center justify-between">
<label className="text-sm text-gray-600">{category}</label>
<Input
value={formatWithCommas(categoryBudgets[category] || 0)}
onChange={(e) => handleInput(e, category)}
className="neuro-pressed max-w-[150px]"
/>
</div>
))}
</div>
);
};