From 10272179116db76942f260ab6b0c92c1d383d5ed 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:07:19 +0000 Subject: [PATCH] Refactor transaction display Modify transaction page to display total budget instead of total income and only show expense transactions. Update color scheme to use neuro-income color. --- src/pages/Transactions.tsx | 42 +++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/pages/Transactions.tsx b/src/pages/Transactions.tsx index df8b4a2..36602da 100644 --- a/src/pages/Transactions.tsx +++ b/src/pages/Transactions.tsx @@ -1,8 +1,10 @@ + import React, { useState } from 'react'; import NavBar from '@/components/NavBar'; import TransactionCard, { Transaction } from '@/components/TransactionCard'; import AddTransactionButton from '@/components/AddTransactionButton'; import { Calendar, Search, ChevronLeft, ChevronRight } from 'lucide-react'; + const Transactions = () => { const [selectedMonth, setSelectedMonth] = useState('8월'); @@ -21,13 +23,6 @@ const Transactions = () => { date: '8월 24일, 3:45 PM', category: 'transportation', type: 'expense' - }, { - id: '3', - title: '월급', - amount: 2500000, - date: '8월 20일, 9:00 AM', - category: 'income', - type: 'income' }, { id: '4', title: '아마존 프라임', @@ -51,15 +46,25 @@ const Transactions = () => { type: 'expense' }]; + // Filter only expense transactions + const expenseTransactions = transactions.filter(t => t.type === 'expense'); + + // Calculate total expenses + const totalExpenses = expenseTransactions.reduce((sum, transaction) => sum + transaction.amount, 0); + + // Set budget (for demo purposes - in a real app this would come from user settings) + const totalBudget = 1000000; + // Group transactions by date const groupedTransactions: Record = {}; - transactions.forEach(transaction => { + expenseTransactions.forEach(transaction => { const datePart = transaction.date.split(',')[0]; if (!groupedTransactions[datePart]) { groupedTransactions[datePart] = []; } groupedTransactions[datePart].push(transaction); }); + return
{/* Header */} @@ -91,12 +96,24 @@ const Transactions = () => { {/* Summary */}
-

총 수입

-

₩2,500,000

+

총 예산

+

+ {new Intl.NumberFormat('ko-KR', { + style: 'currency', + currency: 'KRW', + maximumFractionDigits: 0 + }).format(totalBudget)} +

총 지출

-

₩740,400

+

+ {new Intl.NumberFormat('ko-KR', { + style: 'currency', + currency: 'KRW', + maximumFractionDigits: 0 + }).format(totalExpenses)} +

@@ -121,4 +138,5 @@ const Transactions = () => {
; }; -export default Transactions; \ No newline at end of file + +export default Transactions;