diff --git a/app/components/Header.tsx b/app/components/Header.tsx index c513ff2..fba8284 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -68,7 +68,7 @@ const Header = ({ user, route }: Props) => {
  • - + {
  • - + +
    +
    +

    Work in progress

    +

    + + This page is under construction. +

    + + + + + Back + +
    +
    + + ); +} diff --git a/app/routes/statistics.tsx b/app/routes/statistics.tsx index e69de29..f4f2203 100644 --- a/app/routes/statistics.tsx +++ b/app/routes/statistics.tsx @@ -0,0 +1,74 @@ +import type { User, Team } from "@prisma/client"; +import type { LoaderFunction } from "remix"; +import { redirect, Link, useLoaderData, useCatch } from "remix"; +import { getUser } from "~/utils/session.server"; +import Header from "../components/Header"; + +type LoaderData = { + user: (User & { team: Team & { members: User[] } }) | null; +}; + +export const loader: LoaderFunction = async ({ request }) => { + const user = await getUser(request); + if (!user?.id) { + return redirect("/login"); + } + + const data: LoaderData = { + user, + }; + return data; +}; + +export default function ListExpensesRoute() { + const data = useLoaderData(); + + return ( + <> +
    +
    +
    +
    +

    Work in progress

    +

    + + This page is under construction. +

    + + + + + Back + +
    +
    +
    + + ); +} + +export function CatchBoundary() { + const caught = useCatch(); + + if (caught.status === 401) { + return redirect("/login"); + } + if (caught.status === 404) { + return
    There is no data to display.
    ; + } + throw new Error(`Unexpected caught response with status: ${caught.status}`); +} + +export function ErrorBoundary() { + return
    I did a whoopsies.
    ; +}