From 4746374ce43cb264ce47c0c72567fbccd606f41b Mon Sep 17 00:00:00 2001 From: nzambello Date: Mon, 14 Feb 2022 17:21:00 +0100 Subject: [PATCH] feat: add team page --- app/components/Header.tsx | 4 +-- app/routes/team.tsx | 73 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 4a3e092..c513ff2 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -56,7 +56,7 @@ const Header = ({ user, route }: Props) => {
  • - + {
  • - + { + const user = await getUser(request); + if (!user) { + return redirect("/login"); + } + const data: LoaderData = { user }; + return data; +}; + +export default function JokesIndexRoute() { + const data = useLoaderData(); + + return ( + <> +
    +
    +

    + Team: {data.user.team.id} +

    + {!data.user.team.members || data.user.team.members?.length === 0 ? ( +

    No members

    + ) : ( + data.user.team.members.map((member) => ( +
    +
    +
    +
    + {member.icon ?? member.username[0]} +
    +
    +
    +

    {member.username}

    +
    +
    +
    + )) + )} +
    + + ); +} + +export function CatchBoundary() { + const caught = useCatch(); + + if (caught.status === 404) { + return ( +
    There are no users to display.
    + ); + } + throw new Error(`Unexpected caught response with status: ${caught.status}`); +} + +export function ErrorBoundary() { + return
    I did a whoopsies.
    ; +}