import { getUserTeams } from "@/db/mod.ts"; import { Handlers, PageProps } from "$fresh/server.ts"; import { type ContextState, type PublicUser, type Team } from "@/types.ts"; interface DashboardProps { user: PublicUser; teams: Team[]; } export const handler: Handlers = { async GET(_request: Request, context) { if (context.state.user?.id) { const teams = await getUserTeams(context.state.user) || []; return await context.render({ user: context.state.user, teams }); } return await context.render(); }, }; export default function Page( { data }: PageProps, ) { if (data) { return Dashboard(data); } else { return LoginRequired(); } } function Dashboard({ teams, user }: DashboardProps) { return ( <>

Hello, {(user.displayName || user.username).trim()}!

Which team are we working with today?

); } function LoginRequired() { return You need to login first!; }