// routes/index.tsx import { define, State } from "../utils.ts"; import GuestHome from "../islands/GuestHome.tsx"; import MemberHome from "../islands/MemberHome.tsx"; import { page } from "fresh"; import { getYear } from "../helpers.ts"; import { SessionCookie } from "./auth/callback.ts"; import { createPublicId } from "../helpers.ts"; import { getOnboardingStatus } from "../services/onboardingService.ts"; const _authority = Deno.env.get("AUTHORITY")!; const _clientId = Deno.env.get("CLIENT_ID")!; const _redirectUri = Deno.env.get("REDIRECT_URI")!; export const handler = define.handlers(async (ctx) => { const state = ctx.state as State; const stateData: SessionCookie = state.data ?? { started_on: 0, user_name: "", user_id: "", role: "", user_encrypted: false, }; const publicId = stateData.user_id ? await createPublicId(stateData.user_id) : ""; const onboardingStatus = stateData.user_id ? await getOnboardingStatus(stateData.user_id) : null; return page({ stateData, urlRoute: ctx.state.urlRoute, publicId, stateId: state.stateId, onboardingStatus, }); }); export default define.page( ( { data }: { data: { stateData: SessionCookie; urlRoute: string; publicId: string; stateId: string; onboardingStatus: Awaited>; }; }, ) => { return (
{data.stateData.user_id ? : }
); }, );