From 13b633e23cc40e5fa7c242c31d0d92958c597843 Mon Sep 17 00:00:00 2001 From: nzambello Date: Mon, 14 Feb 2022 18:05:13 +0100 Subject: [PATCH] feat: add wip placeholder for exp list and stats --- app/components/Header.tsx | 4 +- app/routes/expenses/list.tsx | 33 ++++++++++++++++ app/routes/statistics.tsx | 74 ++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) 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.
    ; +}