From 443d8a25010a5cb1c3381399196e4cf2c3bc1724 Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Sat, 8 Mar 2025 08:09:40 +0000
Subject: [PATCH] Implement budget progress visualization
Implement budget progress visualization in the first card, similar to the budget status graph.
---
src/pages/Index.tsx | 117 ++++++++++++++++++++++++++++++++++----------
1 file changed, 92 insertions(+), 25 deletions(-)
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index 538cb59..fd3b9ee 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -1,3 +1,4 @@
+
import React, { useState } from 'react';
import NavBar from '@/components/NavBar';
import BudgetCard from '@/components/BudgetCard';
@@ -57,6 +58,12 @@ const Index = () => {
maximumFractionDigits: 0
}).format(amount);
};
+
+ // 퍼센트 계산 함수
+ const calculatePercentage = (spent: number, target: number) => {
+ return Math.min(Math.round((spent / target) * 100), 100);
+ };
+
return
{/* Header */}
@@ -88,15 +95,35 @@ const Index = () => {
-
-
- 목표 지출 금액
- {formatCurrency(budgetData.daily.targetAmount)}
-
-
-
지출 금액
-
{formatCurrency(budgetData.daily.spentAmount)}
+
+
+
+ 목표 지출 금액
+ {formatCurrency(budgetData.daily.targetAmount)}
+
+
+ 지출 금액
+ {formatCurrency(budgetData.daily.spentAmount)}
+
+
+
+
+
+ = 90
+ ? "text-neuro-expense"
+ : "text-gray-500"
+ }`}>
+ {calculatePercentage(budgetData.daily.spentAmount, budgetData.daily.targetAmount)}%
+
+
+
지출 가능 금액
{formatCurrency(budgetData.daily.remainingAmount)}
@@ -105,15 +132,35 @@ const Index = () => {
-
-
- 목표 지출 금액
- {formatCurrency(budgetData.weekly.targetAmount)}
-
-
-
지출 금액
-
{formatCurrency(budgetData.weekly.spentAmount)}
+
+
+
+ 목표 지출 금액
+ {formatCurrency(budgetData.weekly.targetAmount)}
+
+
+ 지출 금액
+ {formatCurrency(budgetData.weekly.spentAmount)}
+
+
+
+
+
+ = 90
+ ? "text-neuro-expense"
+ : "text-gray-500"
+ }`}>
+ {calculatePercentage(budgetData.weekly.spentAmount, budgetData.weekly.targetAmount)}%
+
+
+
지출 가능 금액
{formatCurrency(budgetData.weekly.remainingAmount)}
@@ -122,15 +169,35 @@ const Index = () => {
-
-
- 목표 지출 금액
- {formatCurrency(budgetData.monthly.targetAmount)}
-
-
-
지출 금액
-
{formatCurrency(budgetData.monthly.spentAmount)}
+
+
+
+ 목표 지출 금액
+ {formatCurrency(budgetData.monthly.targetAmount)}
+
+
+ 지출 금액
+ {formatCurrency(budgetData.monthly.spentAmount)}
+
+
+
+
+
+ = 90
+ ? "text-neuro-expense"
+ : "text-gray-500"
+ }`}>
+ {calculatePercentage(budgetData.monthly.spentAmount, budgetData.monthly.targetAmount)}%
+
+
+
지출 가능 금액
{formatCurrency(budgetData.monthly.remainingAmount)}
@@ -163,4 +230,4 @@ const Index = () => {
;
};
-export default Index;
\ No newline at end of file
+export default Index;