From 8827f4cb1fdb6bc86a2bee14eef2df9edf517316 Mon Sep 17 00:00:00 2001 From: "Zackary S." Date: Sun, 31 Dec 2023 20:15:03 +0100 Subject: [PATCH] fixed stats page routing --- src/App.jsx | 2 +- src/components/ExpenseItem.jsx | 16 +++------------- src/helpers.js | 1 + 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 18fb965..4b4536c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -28,7 +28,7 @@ const router = createBrowserRouter([ errorElement: , }, { - path: "/stats", + path: "stats", element: , errorElement: , }, diff --git a/src/components/ExpenseItem.jsx b/src/components/ExpenseItem.jsx index 003d83f..895ce87 100644 --- a/src/components/ExpenseItem.jsx +++ b/src/components/ExpenseItem.jsx @@ -1,10 +1,6 @@ import { Link, useFetcher } from "react-router-dom"; import { FiXCircle } from "react-icons/fi"; -import { - formatCurrency, - formatDateToLocaleString, - getAllMatchingItems, -} from "../helpers"; +import { formatCurrency, getAllMatchingItems, formatDate } from "../helpers"; const ExpenseItem = ({ expense, showBudget }) => { const fetcher = useFetcher(); @@ -22,17 +18,11 @@ const ExpenseItem = ({ expense, showBudget }) => { {formatCurrency(expense.amount)} - {formatDateToLocaleString(expense.createdAt)} + {formatDate(expense.createdAt)} {showBudget && ( - - {budget.name} - + {budget.name} )} diff --git a/src/helpers.js b/src/helpers.js index b887972..f183127 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -72,6 +72,7 @@ export const calculateSpentByBudget = (budgetId) => { }; export const formatDateToLocaleString = (epoch) => new Date(epoch).toLocaleDateString(); +export const formatDate = (epoch) => epoch.replace(/-/g, "/"); export const formatPercentage = (amt) => { return amt.toLocaleString(undefined, {