ls-deno/routes/dashboard.tsx

32 lines
733 B
TypeScript
Raw Normal View History

2022-10-08 02:01:48 -05:00
// import { getToken, getUser } from "@/db/mod.ts";
// import * as base64 from "$std/encoding/base64.ts";
2022-10-11 16:17:21 -05:00
import { Handlers, PageProps } from "$fresh/server.ts";
2022-10-11 23:49:36 -05:00
import { type ContextState } from "@/types.ts";
2022-10-08 02:01:48 -05:00
2022-10-08 02:53:13 -05:00
export const handler: Handlers<unknown, ContextState> = {
async GET(_request: Request, context) {
return await context.render(context.state.user);
2022-10-08 02:01:48 -05:00
},
};
export default function Dashboard({ data }: PageProps) {
2022-10-08 02:53:13 -05:00
console.log(data);
2022-10-08 02:01:48 -05:00
if (data) {
return You(data);
} else {
return LoginRequired();
}
}
function You(data: unknown) {
return (
2022-10-11 23:49:36 -05:00
<p>
You are <pre>{JSON.stringify(data)}</pre>.
</p>
2022-10-08 02:01:48 -05:00
);
}
function LoginRequired() {
2022-10-11 23:49:36 -05:00
return <a href="/login">You need to login first!</a>;
2022-10-08 02:01:48 -05:00
}