31 lines
743 B
TypeScript
31 lines
743 B
TypeScript
import { Handlers, PageProps } from "$fresh/server.ts";
|
|
import { getUser } from "@/db/mod.ts";
|
|
import { type Team, type User } from "@/types.ts";
|
|
|
|
interface UserPageProps {
|
|
user: User;
|
|
}
|
|
|
|
export const handler: Handlers<UserPageProps> = {
|
|
async GET(request, context) {
|
|
console.debug({ request, context });
|
|
const user = await getUser({ id: context.params.id });
|
|
if (!user) throw "unable to fetch from database";
|
|
return await context.render({ user });
|
|
},
|
|
};
|
|
|
|
export default function Team(
|
|
{ data: { user: { username, createdAt, displayName } } }: PageProps<
|
|
UserPageProps
|
|
>,
|
|
) {
|
|
return (
|
|
<>
|
|
<h1>
|
|
{(displayName || username).trim()} - joined {createdAt.toLocaleString()}
|
|
</h1>
|
|
</>
|
|
);
|
|
}
|