ls-deno/routes/dashboard.tsx
2022-10-12 03:31:26 -05:00

31 lines
712 B
TypeScript

// import { getToken, getUser } from "@/db/mod.ts";
// import * as base64 from "$std/encoding/base64.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
import { type ContextState } from "@/types.ts";
export const handler: Handlers<unknown, ContextState> = {
async GET(_request: Request, context) {
return await context.render(context.state.user);
},
};
export default function Dashboard({ data }: PageProps) {
if (data) {
return You(data);
} else {
return LoginRequired();
}
}
function You(data: unknown) {
return (
<p>
You are <pre>{JSON.stringify(data)}</pre>.
</p>
);
}
function LoginRequired() {
return <a href="/login">You need to login first!</a>;
}