Investigate default value for number inputs

The prompt asks to investigate the current default value (0) for number input fields and consider alternative approaches based on other applications.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 05:41:05 +00:00
parent 74865848f5
commit 50520ed254
4 changed files with 38 additions and 16 deletions

View File

@@ -29,14 +29,16 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
}) => {
const percentage = calculatePercentage(data.spentAmount, data.targetAmount);
const [isOpen, setIsOpen] = useState(false);
const [budgetInput, setBudgetInput] = useState(data.targetAmount.toString());
const [budgetInput, setBudgetInput] = useState(data.targetAmount > 0 ? data.targetAmount.toString() : '');
// 저장된 카테고리 예산을 불러옵니다
const savedCategoryBudgets = localStorage.getItem('categoryBudgets');
const defaultCategoryAmount = data.targetAmount > 0 ? Math.round(data.targetAmount / EXPENSE_CATEGORIES.length) : 0;
const initialCategoryBudgets = savedCategoryBudgets
? JSON.parse(savedCategoryBudgets)
: EXPENSE_CATEGORIES.reduce((acc, category) => {
acc[category] = Math.round(data.targetAmount / EXPENSE_CATEGORIES.length);
acc[category] = defaultCategoryAmount;
return acc;
}, {} as Record<string, number>);