58 lines
1.5 KiB
TypeScript
Executable File

// _app.tsx
import { define, type PageProps } from "../utils.ts";
import WelcomeBar from "../islands/WelcomeBar/WelcomeBar.tsx";
import ThemeHydration from "../islands/ThemeHydration.tsx";
import { createPublicId } from "../helpers.ts";
import { SessionCookie } from "./auth/callback.ts";
export default define.page(async function App(props: PageProps) {
const {
Component,
state,
url,
} = props;
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 now = new Date();
const serverCalendarPath =
`/calendar/financial-calendar/${now.getFullYear()}/${
(now.getMonth() + 1).toString().padStart(2, "0")
}`;
const themeMode = state.themePreference ?? "dark";
return (
<html data-theme-mode={themeMode}>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cyber Hybrid Hub</title>
</head>
<body>
<WelcomeBar
publicId={publicId}
user_name={stateData.user_name}
currentRoute={url.pathname}
isEncrypted={stateData.user_encrypted}
stateId={state.stateId}
serverCalendarPath={serverCalendarPath}
/>
<div class="page-offset">
<Component />
</div>
<ThemeHydration />
</body>
</html>
);
});