2021-08-27 12:35:20 +00:00
import { DefaultSeo } from "next-seo" ;
2023-02-28 23:38:46 +00:00
import { Inter } from "next/font/google" ;
import localFont from "next/font/local" ;
2022-03-24 16:51:37 +00:00
import Head from "next/head" ;
2022-12-08 23:39:15 +00:00
import Script from "next/script" ;
2021-09-22 19:52:38 +00:00
2022-03-31 08:45:47 +00:00
import "@calcom/embed-core/src/embed-iframe" ;
2023-04-13 18:26:31 +00:00
import { useEmbedUiConfig } from "@calcom/embed-core/src/embed-iframe" ;
2022-07-28 19:58:26 +00:00
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired" ;
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" ;
import AppProviders 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-09-22 19:52:38 +00:00
import "../styles/globals.css" ;
2023-02-17 17:53:17 +00:00
const interFont = Inter ( { subsets : [ "latin" ] , variable : "--font-inter" , preload : true , display : "swap" } ) ;
const calFont = localFont ( {
src : "../fonts/CalSans-SemiBold.woff2" ,
variable : "--font-cal" ,
preload : true ,
display : "swap" ,
} ) ;
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" ;
2023-04-13 18:26:31 +00:00
const { cssVarsPerTheme } = useEmbedUiConfig ( ) ;
const cssVarsStyle = [ ] ;
if ( cssVarsPerTheme ) {
for ( const [ themeName , cssVars ] of Object . entries ( cssVarsPerTheme ) ) {
cssVarsStyle . push ( ` . ${ themeName } { ` ) ;
for ( const [ cssVarName , value ] of Object . entries ( cssVars ) ) {
cssVarsStyle . push ( ` -- ${ cssVarName } : ${ value } ; ` ) ;
}
cssVarsStyle . push ( ` } ` ) ;
}
}
2022-04-08 05:33:24 +00:00
if ( router . pathname === "/404" ) {
pageStatus = "404" ;
} else if ( router . pathname === "/500" ) {
pageStatus = "500" ;
}
2023-02-06 22:50:08 +00:00
// On client side don't let nonce creep into DOM
// It also avoids hydration warning that says that Client has the nonce value but server has "" because browser removes nonce attributes before DOM is built
// See https://github.com/kentcdodds/nonce-hydration-issues
// Set "" only if server had it set otherwise keep it undefined because server has to match with client to avoid hydration error
const nonce = typeof window !== "undefined" ? ( pageProps . nonce ? "" : undefined ) : pageProps . nonce ;
const providerProps = {
. . . props ,
pageProps : {
. . . props . pageProps ,
nonce ,
} ,
} ;
2022-08-09 09:21:15 +00:00
// Use the layout defined at the page level, if available
const getLayout = Component . getLayout ? ? ( ( page ) = > page ) ;
2021-03-24 15:03:04 +00:00
return (
2023-02-06 22:50:08 +00:00
< AppProviders { ...providerProps } >
2022-07-28 19:58:26 +00:00
< DefaultSeo { ...seoConfig.defaultNextSeo } / >
< I18nLanguageHandler / >
2022-12-08 23:39:15 +00:00
< Script
2023-02-06 22:50:08 +00:00
nonce = { nonce }
2022-12-08 23:39:15 +00:00
id = "page-status"
dangerouslySetInnerHTML = { { __html : ` window.CalComPageStatus = ' ${ pageStatus } ' ` } }
/ >
2023-02-17 17:53:17 +00:00
< style jsx global > { `
: root {
-- font - inter : $ { interFont . style . fontFamily } ;
-- font - cal : $ { calFont . style . fontFamily } ;
}
` }</style>
2023-04-13 18:26:31 +00:00
< style jsx global >
{ `
$ { cssVarsStyle . join ( "" ) }
` }
< / style >
2022-07-28 19:58:26 +00:00
< Head >
< meta name = "viewport" content = "width=device-width, initial-scale=1, maximum-scale=1" / >
< / Head >
2022-08-09 09:21:15 +00:00
{ getLayout (
Component . requiresLicense ? (
< LicenseRequired >
< Component { ...pageProps } err = { err } / >
< / LicenseRequired >
) : (
2022-07-28 19:58:26 +00:00
< Component { ...pageProps } err = { err } / >
2022-09-02 19:00:41 +00:00
) ,
router
2022-07-28 19:58:26 +00:00
) }
< / AppProviders >
2021-04-11 17:12:18 +00:00
) ;
2021-03-10 10:02:39 +00:00
}
2023-02-10 20:05:02 +00:00
export default trpc . withTRPC ( MyApp ) ;