Skip to content

Commit c7e12c4

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 9e29d04 commit c7e12c4

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed
Lines changed: 35 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FrontEnd/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" href="/assets/CroppedImage-BxF6_1jf.png" type="image/png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>PennyTracker</title>
8-
<script type="module" crossorigin src="/assets/index-BlZ77C3m.js"></script>
8+
<script type="module" crossorigin src="/assets/index-eJWQ9OJs.js"></script>
99
<link rel="stylesheet" crossorigin href="/assets/index-CZzhD3MO.css">
1010
</head>
1111
<body>

FrontEnd/src/pages/Dashboard.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const FinanceDashboard = () => {
107107
const currentYear = parseInt(year);
108108

109109
const [monthlyResponse, totalResponse, monthlyDebitResponse, dailyResponse] = await Promise.all([
110-
dispatch(fetchMonthlySummary(userId)).unwrap(),
110+
dispatch(fetchMonthlySummary({userId, currentYear})).unwrap(),
111111
dispatch(fetchTotalAmounts(userId)).unwrap(),
112112
dispatch(fetchMonthlyDebitCredit({ userId, currentMonth, currentYear })).unwrap(),
113113
dispatch(fetchDailyTransactions({ userId, currentMonth, currentYear })).unwrap(),
@@ -125,10 +125,10 @@ const FinanceDashboard = () => {
125125
const dailyTransactions = dailyResponse.monthlyMessages;
126126
setDailyDebitAndCredit(dailyTransactions);
127127

128-
const debitTransactions = processTransactions(dailyTransactions, "Debited");
128+
const debitTransactions = processTransactions(dailyTransactions, "Debited", "DEBIT");
129129
setDailyDebit(debitTransactions);
130130

131-
const creditTransactions = processTransactions(dailyTransactions, "Credited");
131+
const creditTransactions = processTransactions(dailyTransactions, "Credited", "CREDIT");
132132
setDailyCredit(creditTransactions);
133133

134134
} catch (error) {
@@ -246,9 +246,9 @@ const FinanceDashboard = () => {
246246
}).format(value);
247247
};
248248

249-
const processTransactions = (transactions, type) => {
249+
const processTransactions = (transactions, type1, type2) => {
250250
const filteredTransactions = transactions
251-
.filter(transaction => transaction.type === type)
251+
.filter(transaction => transaction.type === type1 || transaction.type === type2)
252252
.map(transaction => {
253253
const [datePart, timePart] = transaction.date.split(' ');
254254
const [day, month, year] = datePart.split('/');
@@ -303,9 +303,9 @@ const FinanceDashboard = () => {
303303
let CreditedTotal = 0;
304304
let DebitedTotal = 0;
305305
dailyDebitAndCredit.forEach((message) => {
306-
if (message.type === "Credited") {
306+
if (message.type === "Credited" || message.type === "CREDIT") {
307307
CreditedTotal += parseFloat(message.amount.replace(/,/g, ''))
308-
} else if (message.type === "Debited") {
308+
} else if (message.type === "Debited" || message.type === "DEBIT") {
309309
DebitedTotal += parseFloat(parseFloat(message.amount.replace(/,/g, '')).toFixed(2));
310310
}
311311
});

FrontEnd/src/store/expensesSlice.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const API_URL = import.meta.env.VITE_API_URL;
55

66
export const fetchMonthlySummary = createAsyncThunk(
77
"expenses/fetchMonthlySummary",
8-
async (userId, { rejectWithValue }) => {
8+
async ({userId, currentYear}, { rejectWithValue }) => {
99
try {
1010
const response = await axios.get(
11-
`${API_URL}/api/expense/allMonthSummary/${userId}/2024`
11+
`${API_URL}/api/expense/allMonthSummary/${userId}/${currentYear}`
1212
);
1313
return response.data;
1414
} catch (error) {

0 commit comments

Comments
 (0)