fosrl.pangolin/src/app/layout.tsx

87 lines
3.2 KiB
TypeScript
Raw Normal View History

2024-09-27 19:48:49 -04:00
import type { Metadata } from "next";
import "./globals.css";
2025-04-27 13:03:00 -04:00
import { Inter } from "next/font/google";
2024-10-14 12:10:02 -04:00
import { Toaster } from "@/components/ui/toaster";
2024-10-14 18:26:07 -04:00
import { ThemeProvider } from "@app/providers/ThemeProvider";
import EnvProvider from "@app/providers/EnvProvider";
2025-01-04 20:22:01 -05:00
import { pullEnv } from "@app/lib/pullEnv";
2025-03-20 22:16:02 -04:00
import SupportStatusProvider from "@app/providers/SupporterStatusProvider";
2025-04-27 13:03:00 -04:00
import { priv } from "@app/lib/api";
2025-03-20 22:16:02 -04:00
import { AxiosResponse } from "axios";
import { IsSupporterKeyVisibleResponse } from "@server/routers/supporterKey";
2025-04-27 13:03:00 -04:00
import LicenseStatusProvider from "@app/providers/LicenseStatusProvider";
import { GetLicenseStatusResponse } from "@server/routers/license";
import LicenseViolation from "./components/LicenseViolation";
2025-05-13 11:09:38 -04:00
import { cache } from "react";
2025-05-25 19:01:20 +00:00
import { NextIntlClientProvider } from "next-intl";
import { getLocale } from "next-intl/server";
2024-09-27 19:48:49 -04:00
export const metadata: Metadata = {
2024-10-26 17:24:31 -04:00
title: `Dashboard - Pangolin`,
description: ""
2024-09-27 19:48:49 -04:00
};
2025-04-07 13:32:07 -07:00
export const dynamic = "force-dynamic";
2025-01-04 20:22:01 -05:00
// const font = Figtree({ subsets: ["latin"] });
const font = Inter({ subsets: ["latin"] });
2024-10-06 11:13:50 -04:00
export default async function RootLayout({
children
2024-09-27 19:48:49 -04:00
}: Readonly<{
2024-09-27 21:39:03 -04:00
children: React.ReactNode;
2024-09-27 19:48:49 -04:00
}>) {
2025-01-04 20:22:01 -05:00
const env = pullEnv();
2025-05-04 15:11:42 +00:00
const locale = await getLocale();
2025-01-04 20:22:01 -05:00
2025-03-20 22:16:02 -04:00
let supporterData = {
visible: true
2025-03-21 18:36:11 -04:00
} as any;
2025-03-20 22:16:02 -04:00
2025-04-07 13:32:07 -07:00
const res = await priv.get<AxiosResponse<IsSupporterKeyVisibleResponse>>(
"supporter-key/visible"
);
2025-03-20 22:16:02 -04:00
supporterData.visible = res.data.data.visible;
2025-03-21 18:36:11 -04:00
supporterData.tier = res.data.data.tier;
2025-03-20 22:16:02 -04:00
2025-05-13 11:09:38 -04:00
const licenseStatusRes = await cache(
async () =>
await priv.get<AxiosResponse<GetLicenseStatusResponse>>(
"/license/status"
)
)();
2025-04-27 13:03:00 -04:00
const licenseStatus = licenseStatusRes.data.data;
2024-09-27 21:39:03 -04:00
return (
2025-05-04 15:11:42 +00:00
<html suppressHydrationWarning lang={locale}>
2025-04-12 19:50:30 -04:00
<body className={`${font.className} h-screen overflow-hidden`}>
2025-05-04 15:11:42 +00:00
<NextIntlClientProvider>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<EnvProvider env={pullEnv()}>
<LicenseStatusProvider licenseStatus={licenseStatus}>
<SupportStatusProvider
supporterStatus={supporterData}
>
{/* Main content */}
<div className="h-full flex flex-col">
<div className="flex-1 overflow-auto">
<LicenseViolation />
{children}
</div>
2025-04-27 13:03:00 -04:00
</div>
2025-05-04 15:11:42 +00:00
</SupportStatusProvider>
</LicenseStatusProvider>
</EnvProvider>
<Toaster />
</ThemeProvider>
</NextIntlClientProvider>
2024-10-06 11:13:50 -04:00
</body>
2024-09-27 21:39:03 -04:00
</html>
);
2024-09-27 19:48:49 -04:00
}