2021-08-27 12:35:20 +00:00
|
|
|
import { DefaultSeo } from "next-seo";
|
2022-03-24 16:51:37 +00:00
|
|
|
import Head from "next/head";
|
2021-10-07 15:43:20 +00:00
|
|
|
import superjson from "superjson";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-03-31 08:45:47 +00:00
|
|
|
import "@calcom/embed-core/src/embed-iframe";
|
2022-05-26 17:07:14 +00:00
|
|
|
import LicenseRequired from "@ee/components/LicenseRequired";
|
2022-03-31 08:45:47 +00:00
|
|
|
|
2021-10-20 16:00:11 +00:00
|
|
|
import AppProviders, { AppProps } from "@lib/app-providers";
|
2021-08-27 12:35:20 +00:00
|
|
|
import { seoConfig } from "@lib/config/next-seo.config";
|
2021-03-10 10:02:39 +00:00
|
|
|
|
2021-10-12 13:11:33 +00:00
|
|
|
import I18nLanguageHandler from "@components/I18nLanguageHandler";
|
|
|
|
|
2021-10-07 15:43:20 +00:00
|
|
|
import type { AppRouter } from "@server/routers/_app";
|
2021-11-24 11:45:09 +00:00
|
|
|
import { httpBatchLink } from "@trpc/client/links/httpBatchLink";
|
2021-10-14 19:22:01 +00:00
|
|
|
import { loggerLink } from "@trpc/client/links/loggerLink";
|
|
|
|
import { withTRPC } from "@trpc/next";
|
|
|
|
import type { TRPCClientErrorLike } from "@trpc/react";
|
|
|
|
import { Maybe } from "@trpc/server";
|
2021-10-07 15:43:20 +00:00
|
|
|
|
2022-02-01 21:48:40 +00:00
|
|
|
import { ContractsProvider } from "../contexts/contractsContext";
|
2021-11-04 13:56:02 +00:00
|
|
|
import "../styles/fonts.css";
|
2021-09-22 19:52:38 +00:00
|
|
|
import "../styles/globals.css";
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
function MyApp(props: AppProps) {
|
2022-04-08 05:33:24 +00:00
|
|
|
const { Component, pageProps, err, router } = props;
|
|
|
|
let pageStatus = "200";
|
|
|
|
if (router.pathname === "/404") {
|
|
|
|
pageStatus = "404";
|
|
|
|
} else if (router.pathname === "/500") {
|
|
|
|
pageStatus = "500";
|
|
|
|
}
|
2021-03-24 15:03:04 +00:00
|
|
|
return (
|
2022-02-01 21:48:40 +00:00
|
|
|
<ContractsProvider>
|
|
|
|
<AppProviders {...props}>
|
|
|
|
<DefaultSeo {...seoConfig.defaultNextSeo} />
|
|
|
|
<I18nLanguageHandler />
|
2022-03-24 16:51:37 +00:00
|
|
|
<Head>
|
2022-04-08 05:33:24 +00:00
|
|
|
<script dangerouslySetInnerHTML={{ __html: `window.CalComPageStatus = '${pageStatus}'` }}></script>
|
2022-03-24 16:51:37 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
|
|
</Head>
|
2022-05-26 17:07:14 +00:00
|
|
|
{Component.requiresLicense ? (
|
|
|
|
<LicenseRequired>
|
|
|
|
<Component {...pageProps} err={err} />
|
|
|
|
</LicenseRequired>
|
|
|
|
) : (
|
|
|
|
<Component {...pageProps} err={err} />
|
|
|
|
)}
|
2022-02-01 21:48:40 +00:00
|
|
|
</AppProviders>
|
|
|
|
</ContractsProvider>
|
2021-04-11 17:12:18 +00:00
|
|
|
);
|
2021-03-10 10:02:39 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 14:33:14 +00:00
|
|
|
export default withTRPC<AppRouter>({
|
2021-09-30 12:28:30 +00:00
|
|
|
config() {
|
|
|
|
/**
|
|
|
|
* If you want to use SSR, you need to use the server's full URL
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/links
|
|
|
|
*/
|
|
|
|
links: [
|
|
|
|
// adds pretty logs to your console in development and logs errors in production
|
|
|
|
loggerLink({
|
|
|
|
enabled: (opts) =>
|
2022-02-23 16:37:41 +00:00
|
|
|
!!process.env.NEXT_PUBLIC_DEBUG || (opts.direction === "down" && opts.result instanceof Error),
|
2021-09-30 12:28:30 +00:00
|
|
|
}),
|
2021-11-24 11:45:09 +00:00
|
|
|
httpBatchLink({
|
2021-09-30 12:28:30 +00:00
|
|
|
url: `/api/trpc`,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
* @link https://react-query.tanstack.com/reference/QueryClient
|
|
|
|
*/
|
2021-10-01 14:33:14 +00:00
|
|
|
queryClientConfig: {
|
|
|
|
defaultOptions: {
|
|
|
|
queries: {
|
|
|
|
/**
|
|
|
|
* 1s should be enough to just keep identical query waterfalls low
|
|
|
|
* @example if one page components uses a query that is also used further down the tree
|
|
|
|
*/
|
|
|
|
staleTime: 1000,
|
|
|
|
/**
|
|
|
|
* Retry `useQuery()` calls depending on this function
|
|
|
|
*/
|
|
|
|
retry(failureCount, _err) {
|
|
|
|
const err = _err as never as Maybe<TRPCClientErrorLike<AppRouter>>;
|
|
|
|
const code = err?.data?.code;
|
|
|
|
if (code === "BAD_REQUEST" || code === "FORBIDDEN" || code === "UNAUTHORIZED") {
|
|
|
|
// if input data is wrong or you're not authorized there's no point retrying a query
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const MAX_QUERY_RETRIES = 3;
|
|
|
|
return failureCount < MAX_QUERY_RETRIES;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-07 15:43:20 +00:00
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/data-transformers
|
|
|
|
*/
|
|
|
|
transformer: superjson,
|
2021-09-30 12:28:30 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
ssr: false,
|
2021-10-14 10:57:49 +00:00
|
|
|
})(MyApp);
|