2023-10-10 16:36:28 +00:00
|
|
|
import type { IncomingMessage } from "http";
|
|
|
|
import type { AppContextType } from "next/dist/shared/lib/utils";
|
2023-08-09 22:54:51 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2023-10-10 16:36:28 +00:00
|
|
|
import { getLocale } from "@calcom/features/auth/lib/getLocale";
|
2023-02-10 20:05:02 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-03-31 08:45:47 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { AppProps } from "@lib/app-providers";
|
2021-10-12 13:11:33 +00:00
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import "../styles/globals.css";
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
function MyApp(props: AppProps) {
|
2023-04-18 18:45:32 +00:00
|
|
|
const { Component, pageProps } = props;
|
2023-10-10 16:36:28 +00:00
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
if (Component.PageWrapper !== undefined) return Component.PageWrapper(props);
|
|
|
|
return <Component {...pageProps} />;
|
2021-03-10 10:02:39 +00:00
|
|
|
}
|
|
|
|
|
2023-10-10 16:36:28 +00:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
calNewLocale: string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MyApp.getInitialProps = async (ctx: AppContextType) => {
|
|
|
|
const { req } = ctx.ctx;
|
|
|
|
|
|
|
|
let newLocale = "en";
|
|
|
|
|
|
|
|
if (req) {
|
|
|
|
newLocale = await getLocale(req as IncomingMessage & { cookies: Record<string, any> });
|
|
|
|
} else if (typeof window !== "undefined" && window.calNewLocale) {
|
|
|
|
newLocale = window.calNewLocale;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
pageProps: {
|
|
|
|
newLocale,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const WrappedMyApp = trpc.withTRPC(MyApp);
|
|
|
|
|
|
|
|
export default WrappedMyApp;
|