Fix budget total calculation

Ensure budget total calculation aligns with weekly or monthly budget settings.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 11:13:26 +00:00
parent ef239e6126
commit 5f125de8d7
2 changed files with 9 additions and 1 deletions

View File

@@ -47,6 +47,13 @@ const BudgetProgressCard: React.FC<BudgetProgressCardProps> = ({
return () => clearTimeout(timeoutId); return () => clearTimeout(timeoutId);
}, [budgetData]); }, [budgetData]);
// 컴포넌트 마운트 시 월간 탭을 기본으로 설정
useEffect(() => {
if (selectedTab !== 'monthly') {
setSelectedTab('monthly');
}
}, []);
// budgetDataUpdated 이벤트 감지 // budgetDataUpdated 이벤트 감지
useEffect(() => { useEffect(() => {
const handleBudgetDataUpdated = () => { const handleBudgetDataUpdated = () => {
@@ -76,7 +83,7 @@ const BudgetProgressCard: React.FC<BudgetProgressCardProps> = ({
return ( return (
<div className="neuro-card mb-6 overflow-hidden w-full"> <div className="neuro-card mb-6 overflow-hidden w-full">
<Tabs defaultValue="daily" value={selectedTab} onValueChange={handleTabChange} className="w-full"> <Tabs defaultValue="monthly" value={selectedTab} onValueChange={handleTabChange} className="w-full">
<TabsList className="grid grid-cols-3 mb-4 bg-transparent"> <TabsList className="grid grid-cols-3 mb-4 bg-transparent">
<TabsTrigger <TabsTrigger
value="daily" value="daily"

View File

@@ -110,6 +110,7 @@ export const useBudgetTabContent = ({
// 총액이 0이 아닐 때만 저장 처리 // 총액이 0이 아닐 때만 저장 처리
if (totalBudget > 0) { if (totalBudget > 0) {
// 월간 예산 기준으로 전달
onSaveBudget(totalBudget, updatedCategoryBudgets); onSaveBudget(totalBudget, updatedCategoryBudgets);
setShowBudgetInput(false); setShowBudgetInput(false);