From 19ecbd27280ea9dbcd437d93d55d7180ded21635 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 02:22:33 +0000 Subject: [PATCH] Refactor budget input card The budget input card will now be a collapsible element, only showing its title until expanded. This change is intended to reduce visual clutter on the main screen. --- src/components/BudgetInputCard.tsx | 105 ++++++++++++++++++----------- src/pages/Index.tsx | 25 ++++--- 2 files changed, 79 insertions(+), 51 deletions(-) diff --git a/src/components/BudgetInputCard.tsx b/src/components/BudgetInputCard.tsx index bfb19f1..e2c36ea 100644 --- a/src/components/BudgetInputCard.tsx +++ b/src/components/BudgetInputCard.tsx @@ -1,8 +1,11 @@ + import React, { useState, useEffect } from 'react'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; -import { Check } from 'lucide-react'; +import { Check, ChevronDown, ChevronUp } from 'lucide-react'; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; + interface BudgetGoalProps { initialBudgets: { daily: number; @@ -11,6 +14,7 @@ interface BudgetGoalProps { }; onSave: (type: 'daily' | 'weekly' | 'monthly', amount: number) => void; } + const BudgetInputCard: React.FC = ({ initialBudgets, onSave @@ -21,6 +25,7 @@ const BudgetInputCard: React.FC = ({ weekly: initialBudgets.weekly.toString(), monthly: initialBudgets.monthly.toString() }); + const [isOpen, setIsOpen] = useState(false); // Format for display without commas const formatForInput = (amount: number) => { @@ -31,6 +36,7 @@ const BudgetInputCard: React.FC = ({ const formatWithCommas = (amount: string) => { return amount.replace(/\B(?=(\d{3})+(?!\d))/g, ','); }; + useEffect(() => { setBudgetInputs({ daily: formatForInput(initialBudgets.daily), @@ -38,6 +44,7 @@ const BudgetInputCard: React.FC = ({ monthly: formatForInput(initialBudgets.monthly) }); }, [initialBudgets]); + const handleInputChange = (value: string, type: 'daily' | 'weekly' | 'monthly') => { // Remove all non-numeric characters const numericValue = value.replace(/[^0-9]/g, ''); @@ -46,48 +53,70 @@ const BudgetInputCard: React.FC = ({ [type]: numericValue })); }; + const handleSave = () => { const amount = parseInt(budgetInputs[selectedTab], 10) || 0; onSave(selectedTab, amount); + // Close the collapsible after saving + setIsOpen(false); }; - return
- setSelectedTab(value as 'daily' | 'weekly' | 'monthly')} className="w-full"> - - 일일 예산 - 주간 예산 - 월간 예산 - - -
- handleInputChange(e.target.value, 'daily')} placeholder="목표 금액 입력" className="neuro-pressed" /> - -
-

현재 일일 목표: {formatWithCommas(budgetInputs.daily)}원

-
+ return ( + + + 예산 목표 설정하기 + {isOpen ? ( + + ) : ( + + )} + + + + setSelectedTab(value as 'daily' | 'weekly' | 'monthly')} className="w-full"> + + 일일 예산 + 주간 예산 + 월간 예산 + - -
- handleInputChange(e.target.value, 'weekly')} placeholder="목표 금액 입력" className="neuro-pressed" /> - -
-

현재 주간 목표: {formatWithCommas(budgetInputs.weekly)}원

-
+ +
+ handleInputChange(e.target.value, 'daily')} placeholder="목표 금액 입력" className="neuro-pressed" /> + +
+

현재 일일 목표: {formatWithCommas(budgetInputs.daily)}원

+
- -
- handleInputChange(e.target.value, 'monthly')} placeholder="목표 금액 입력" className="neuro-pressed" /> - -
-

현재 월간 목표: {formatWithCommas(budgetInputs.monthly)}원

-
-
-
; + +
+ handleInputChange(e.target.value, 'weekly')} placeholder="목표 금액 입력" className="neuro-pressed" /> + +
+

현재 주간 목표: {formatWithCommas(budgetInputs.weekly)}원

+
+ + +
+ handleInputChange(e.target.value, 'monthly')} placeholder="목표 금액 입력" className="neuro-pressed" /> + +
+

현재 월간 목표: {formatWithCommas(budgetInputs.monthly)}원

+
+ + + + ); }; -export default BudgetInputCard; \ No newline at end of file + +export default BudgetInputCard; diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 7df9875..d059a61 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -4,7 +4,7 @@ import BudgetCard from '@/components/BudgetCard'; import BudgetInputCard from '@/components/BudgetInputCard'; import TransactionCard, { Transaction } from '@/components/TransactionCard'; import AddTransactionButton from '@/components/AddTransactionButton'; -import { Wallet, TrendingUp, Bell } from 'lucide-react'; +import { Bell } from 'lucide-react'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { toast } from '@/components/ui/use-toast'; @@ -100,7 +100,7 @@ const Index = () => { - {/* 목표 진행 상황 - 제목을 카드 위로 이동 */} + {/* 목표 진행 상황 */}

예산과 지출

@@ -205,15 +205,7 @@ const Index = () => {
- {/* 목표 입력 */} -

예산 입력

- - - {/* Budget Progress */} + {/* 지출 카테고리 */}

지출 카테고리

@@ -221,8 +213,15 @@ const Index = () => {
- {/* Recent Transactions */} -

최근 지출

+ {/* 예산 입력 카드 - 이제는 접힌 상태로 표시됩니다 */} + + + {/* 최근 지출 */} +

최근 지출

{transactions.map(transaction => )}