39 lines
849 B
TypeScript
39 lines
849 B
TypeScript
|
import { HandlerContext, Handlers, PageProps } from "$fresh/server.ts";
|
||
|
import { Page } from "@/components/Page.tsx";
|
||
|
// import { getToken, getUser } from "@/db/mod.ts";
|
||
|
// import * as base64 from "$std/encoding/base64.ts";
|
||
|
import { getCookies } from "$std/http/cookie.ts";
|
||
|
import { type User } from "@/types.ts";
|
||
|
|
||
|
export const handler: Handlers<unknown> = {
|
||
|
async GET(request: Request, context) {
|
||
|
return await context.render(context.state.data);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default function Dashboard({ data }: PageProps) {
|
||
|
if (data) {
|
||
|
return You(data);
|
||
|
} else {
|
||
|
return LoginRequired();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function You(data: unknown) {
|
||
|
return (
|
||
|
<Page>
|
||
|
<p>
|
||
|
You are <pre>{data}</pre>.
|
||
|
</p>
|
||
|
</Page>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function LoginRequired() {
|
||
|
return (
|
||
|
<Page>
|
||
|
<a href="/login">You need to login first!</a>
|
||
|
</Page>
|
||
|
);
|
||
|
}
|