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:
@@ -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>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user