Files
myeasycms-v2/apps/web/app/layout.tsx
giancarlo e158ff28d8 Improve and update billing flow
This commit updates various components in the billing flow due to a new schema that supports multiple line items per plan. The added flexibility rendered 'line-items-mapper.ts' redundant, which has been removed. Additionally, webhooks have been created for handling account membership insertions and deletions, as well as handling subscription deletions when an account is deleted. This message also introduces a new service to handle sending out invitation emails. Lastly, the validation of the billing provider has been improved for increased security and stability.
2024-03-30 14:51:16 +08:00

81 lines
2.0 KiB
TypeScript

import { Inter as SansFont } from 'next/font/google';
import { cookies, headers } from 'next/headers';
import { Toaster } from '@kit/ui/sonner';
import { cn } from '@kit/ui/utils';
import { RootProviders } from '~/components/root-providers';
import appConfig from '~/config/app.config';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
import '../styles/globals.css';
const sans = SansFont({
subsets: ['latin'],
variable: '--font-family-sans',
fallback: ['system-ui', 'Helvetica Neue', 'Helvetica', 'Arial'],
preload: true,
weight: ['300', '400', '500', '600', '700', '800'],
});
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const { language } = await createI18nServerInstance();
return (
<html lang={language} className={getClassName()}>
<CsrfTokenMeta />
<body>
<RootProviders lang={language}>{children}</RootProviders>
<Toaster richColors={false} />
</body>
</html>
);
}
function getClassName() {
const themeCookie = cookies().get('theme')?.value;
const theme = themeCookie ?? appConfig.theme;
const dark = theme === 'dark';
return cn('min-h-screen bg-background antialiased', {
dark,
[sans.className]: true,
});
}
export const metadata = {
title: appConfig.name,
description: appConfig.description,
metadataBase: new URL(appConfig.url),
openGraph: {
url: appConfig.url,
siteName: appConfig.name,
description: appConfig.description,
},
twitter: {
card: 'summary_large_image',
title: appConfig.title,
description: appConfig.description,
},
icons: {
icon: '/assets/images/favicon/favicon.ico',
shortcut: '/shortcut-icon.png',
apple: '/assets/images/favicon/apple-touch-icon.png',
other: {
rel: 'apple-touch-icon-precomposed',
url: '/apple-touch-icon-precomposed.png',
},
},
};
function CsrfTokenMeta() {
const csrf = headers().get('x-csrf-token') ?? '';
return <meta content={csrf} name="csrf-token" />;
}