Skip to content

Commit

Permalink
fixed stats page routing
Browse files Browse the repository at this point in the history
  • Loading branch information
slzakaria committed Dec 31, 2023
1 parent 1be21ed commit 8827f4c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const router = createBrowserRouter([
errorElement: <Error />,
},
{
path: "/stats",
path: "stats",
element: <Stats />,
errorElement: <Error />,
},
Expand Down
16 changes: 3 additions & 13 deletions src/components/ExpenseItem.jsx
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -22,17 +18,11 @@ const ExpenseItem = ({ expense, showBudget }) => {
{formatCurrency(expense.amount)}
</td>
<td className='text-navy text-xs sm:text-base text-center'>
{formatDateToLocaleString(expense.createdAt)}
{formatDate(expense.createdAt)}
</td>
{showBudget && (
<td className='text-navy text-sm sm:text-base text-center'>
<Link
to={`/budget/${budget.id}`}
style={{
"--accent": budget.color,
}}>
{budget.name}
</Link>
<Link to={`/budget/${budget.id}`}>{budget.name}</Link>
</td>
)}
<td>
Expand Down
1 change: 1 addition & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 8827f4c

Please sign in to comment.