mirror of
https://github.com/mosh-hamedani/expense-tracker-starter.git
synced 2026-05-21 11:58:31 +02:00
Fix amount calculation: convert string amounts to numbers
This commit is contained in:
parent
f952787053
commit
eb352e933b
18
src/App.jsx
18
src/App.jsx
|
|
@ -3,14 +3,14 @@ import './App.css'
|
|||
|
||||
function App() {
|
||||
const [transactions, setTransactions] = useState([
|
||||
{ id: 1, description: "Salary", amount: "5000", type: "income", category: "salary", date: "2025-01-01" },
|
||||
{ id: 2, description: "Rent", amount: "1200", type: "expense", category: "housing", date: "2025-01-02" },
|
||||
{ id: 3, description: "Groceries", amount: "150", type: "expense", category: "food", date: "2025-01-03" },
|
||||
{ id: 4, description: "Freelance Work", amount: "800", type: "expense", category: "salary", date: "2025-01-05" },
|
||||
{ id: 5, description: "Electric Bill", amount: "95", type: "expense", category: "utilities", date: "2025-01-06" },
|
||||
{ id: 6, description: "Dinner Out", amount: "65", type: "expense", category: "food", date: "2025-01-07" },
|
||||
{ id: 7, description: "Gas", amount: "45", type: "expense", category: "transport", date: "2025-01-08" },
|
||||
{ id: 8, description: "Netflix", amount: "15", type: "expense", category: "entertainment", date: "2025-01-10" },
|
||||
{ id: 1, description: "Salary", amount: 5000, type: "income", category: "salary", date: "2025-01-01" },
|
||||
{ id: 2, description: "Rent", amount: 1200, type: "expense", category: "housing", date: "2025-01-02" },
|
||||
{ id: 3, description: "Groceries", amount: 150, type: "expense", category: "food", date: "2025-01-03" },
|
||||
{ id: 4, description: "Freelance Work", amount: 800, type: "expense", category: "salary", date: "2025-01-05" },
|
||||
{ id: 5, description: "Electric Bill", amount: 95, type: "expense", category: "utilities", date: "2025-01-06" },
|
||||
{ id: 6, description: "Dinner Out", amount: 65, type: "expense", category: "food", date: "2025-01-07" },
|
||||
{ id: 7, description: "Gas", amount: 45, type: "expense", category: "transport", date: "2025-01-08" },
|
||||
{ id: 8, description: "Netflix", amount: 15, type: "expense", category: "entertainment", date: "2025-01-10" },
|
||||
]);
|
||||
|
||||
const [description, setDescription] = useState("");
|
||||
|
|
@ -47,7 +47,7 @@ function App() {
|
|||
const newTransaction = {
|
||||
id: Date.now(),
|
||||
description,
|
||||
amount,
|
||||
amount: parseFloat(amount),
|
||||
type,
|
||||
category,
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
|
|
|
|||
Loading…
Reference in a new issue