71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { DefaultLayout } from "@Front/Components/LayoutTemplates/DefaultLayout";
|
|
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
|
import "@Front/index.scss";
|
|
import type { NextPage } from "next";
|
|
import type { AppType, AppProps } from "next/app";
|
|
import type { ReactElement, ReactNode } from "react";
|
|
|
|
export type NextPageWithLayout<TProps = Record<string, unknown>, TInitialProps = TProps> = NextPage<TProps, TInitialProps> & {
|
|
getLayout?: (page: ReactElement) => ReactNode;
|
|
};
|
|
|
|
type AppPropsWithLayout = AppProps & {
|
|
Component: NextPageWithLayout;
|
|
} & {
|
|
backApiProtocol: string;
|
|
backApiHost: string;
|
|
backApiRootUrl: string;
|
|
backApiVersion: string;
|
|
frontAppHost: string;
|
|
idNotAuthorizeEndpoint: string;
|
|
idNotClientId: string;
|
|
fcAuthorizeEndpoint: string;
|
|
fcClientId: string;
|
|
};
|
|
|
|
const MyApp = (({
|
|
Component,
|
|
pageProps,
|
|
backApiProtocol,
|
|
backApiHost,
|
|
backApiRootUrl,
|
|
backApiVersion,
|
|
frontAppHost,
|
|
idNotAuthorizeEndpoint,
|
|
idNotClientId,
|
|
fcAuthorizeEndpoint,
|
|
fcClientId
|
|
}: AppPropsWithLayout) => {
|
|
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
|
|
|
const instance = FrontendVariables.getInstance();
|
|
instance.BACK_API_PROTOCOL = backApiProtocol ?? "https://";
|
|
instance.BACK_API_HOST = backApiHost ?? "api.stg.lecoffre.smart-chain.fr";
|
|
instance.BACK_API_ROOT_URL = backApiRootUrl ?? "/api";
|
|
instance.BACK_API_VERSION = backApiVersion ?? "/v1";
|
|
instance.FRONT_APP_HOST = frontAppHost ?? "app.stg.lecoffre.smart-chain.fr";
|
|
instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint ?? "https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1";
|
|
instance.IDNOT_CLIENT_ID = idNotClientId ?? "4501646203F3EF67";
|
|
instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint ?? "https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize";
|
|
instance.FC_CLIENT_ID = fcClientId ?? "211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e";
|
|
|
|
return getLayout(<Component {...pageProps} />);
|
|
}) as AppType;
|
|
|
|
MyApp.getInitialProps = async () => {
|
|
return {
|
|
backApiProtocol: process.env["NEXT_PUBLIC_BACK_API_PROTOCOL"],
|
|
backApiHost: process.env["NEXT_PUBLIC_BACK_API_HOST"],
|
|
backApiRootUrl: process.env["NEXT_PUBLIC_BACK_API_ROOT_URL"],
|
|
backApiVersion: process.env["NEXT_PUBLIC_BACK_API_VERSION"],
|
|
frontAppHost: process.env["NEXT_PUBLIC_FRONT_APP_HOST"],
|
|
frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"],
|
|
idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"],
|
|
idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"],
|
|
fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"],
|
|
fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"]
|
|
};
|
|
};
|
|
|
|
export default MyApp;
|