chore: migrate the event-types page to the app directory (#12390)

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
Greg PabianandOmar López authored and GitHub committed 2023-11-22 19:17:33 +00:00
1 parent 53d7e2ec3f
commit 1de05ebf3d
24 files changed
+640 -99

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
"use client";
import type { ComponentProps } from "react";
import React from "react";
import Shell from "@calcom/features/shell/Shell";
export default function MainLayout({
children,
...rest
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
return (
<Shell withoutMain={true} {...rest}>
{children}
</Shell>
);
}
export const getLayout = (page: React.ReactElement) => <MainLayout>{page}</MainLayout>;
+12 -3
View File
@@ -2,9 +2,11 @@ import { parse } from "accept-language-parser";
import { lookup } from "bcp-47-match";
import type { GetTokenParams } from "next-auth/jwt";
import { getToken } from "next-auth/jwt";
import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
import { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
//@ts-expect-error no type definitions
import { i18n } from "@calcom/web/next-i18next.config";
import { i18n } from "@calcom/config/next-i18next.config";
/**
* This is a slimmed down version of the `getServerSession` function from
@@ -17,9 +19,16 @@ import { i18n } from "@calcom/web/next-i18next.config";
* token has expired (30 days). This should be fine as we call `/auth/session`
* frequently enough on the client-side to keep the session alive.
*/
export const getLocale = async (req: GetTokenParams["req"]): Promise<string> => {
export const getLocale = async (
req:
| GetTokenParams["req"]
| {
cookies: ReadonlyRequestCookies;
headers: ReadonlyHeaders;
}
): Promise<string> => {
const token = await getToken({
req,
req: req as GetTokenParams["req"],
});
const tokenLocale = token?.["locale"];
+8 -1
View File
@@ -106,4 +106,11 @@ export const APP_CREDENTIAL_SHARING_ENABLED =
export const DEFAULT_LIGHT_BRAND_COLOR = "#292929";
export const DEFAULT_DARK_BRAND_COLOR = "#fafafa";
export const AB_TEST_BUCKET_PROBABILITY = Number(process.env.AB_TEST_BUCKET_PROBABILITY ?? "10");
const defaultOnNaN = (testedValue: number, defaultValue: number) =>
!Number.isNaN(testedValue) ? testedValue : defaultValue;
export const AB_TEST_BUCKET_PROBABILITY = defaultOnNaN(
parseInt(process.env.AB_TEST_BUCKET_PROBABILITY ?? "10", 10),
10
);
+23
View File
@@ -0,0 +1,23 @@
import i18next from "i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
//@ts-expect-error no type definitions
import config from "@calcom/web/next-i18next.config";
export const create = async (locale: string, ns: string) => {
const { _nextI18Next } = await serverSideTranslations(locale, [ns], config);
const _i18n = i18next.createInstance();
_i18n.init({
lng: locale,
resources: _nextI18Next?.initialI18nStore,
fallbackLng: _nextI18Next?.userConfig?.i18n.defaultLocale,
});
return _i18n;
};
export const getFixedT = async (locale: string, ns: string) => {
const i18n = await create(locale, ns);
return i18n.getFixedT(locale, ns);
};