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 + + + ); +}