From 50fb9af24fb5de73a710eb0c903a775ed79cedd9 Mon Sep 17 00:00:00 2001 From: nzambello Date: Sat, 18 Feb 2023 23:35:17 +0100 Subject: [PATCH] chore: add placeholder pages for report and stats --- app/routes/report.tsx | 37 +++++++++++++++++++++++++++++++++++++ app/routes/statistics.tsx | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 app/routes/report.tsx create mode 100644 app/routes/statistics.tsx diff --git a/app/routes/report.tsx b/app/routes/report.tsx new file mode 100644 index 0000000..071278c --- /dev/null +++ b/app/routes/report.tsx @@ -0,0 +1,37 @@ +import { Box, Paper } from '@mantine/core'; +import { MetaFunction, LoaderArgs, redirect, json } from '@remix-run/node'; +import { useLoaderData } from '@remix-run/react'; +import { getTimeEntries } from '~/models/timeEntry.server'; +import { requireUserId } from '~/session.server'; + +export const meta: MetaFunction = () => { + return { + title: 'Report | WorkTimer', + description: + 'Generate a report of your time entries. You must be logged in to do this.' + }; +}; + +export async function loader({ request }: LoaderArgs) { + const userId = await requireUserId(request); + if (!userId) return redirect('/login'); + + return json({ + ...(await getTimeEntries({ + userId + })) + }); +} + +export default function ReportPage() { + const data = useLoaderData(); + + return ( + <> +

Report

+ + Coming soon + + + ); +} diff --git a/app/routes/statistics.tsx b/app/routes/statistics.tsx new file mode 100644 index 0000000..4121e2d --- /dev/null +++ b/app/routes/statistics.tsx @@ -0,0 +1,37 @@ +import { Box, Paper } from '@mantine/core'; +import { MetaFunction, LoaderArgs, redirect, json } from '@remix-run/node'; +import { useLoaderData } from '@remix-run/react'; +import { getTimeEntries } from '~/models/timeEntry.server'; +import { requireUserId } from '~/session.server'; + +export const meta: MetaFunction = () => { + return { + title: 'Statistics | WorkTimer', + description: + 'See statistics about your time entries. You must be logged in to do this.' + }; +}; + +export async function loader({ request }: LoaderArgs) { + const userId = await requireUserId(request); + if (!userId) return redirect('/login'); + + return json({ + ...(await getTimeEntries({ + userId + })) + }); +} + +export default function ReportPage() { + const data = useLoaderData(); + + return ( + <> +

Statistics

+ + Coming soon + + + ); +}