{"version":3,"file":"index-f99a7ef9.js","sources":["../../../client-app/src/common/applicationPages/Status/loader.ts","../../../client-app/src/common/applicationPages/Status/index.tsx"],"sourcesContent":["import { ApplicationPaths } from '@n2-common/applicationPages/ApplicationFormsHelpers';\nimport { safeRedirect } from '@n2-common/applicationPages/applicationStatusHelpers';\nimport { assertDataIsNotResponse } from '@n2-common/asserts';\nimport { getApplicationIds } from '@n2-common/components/ApplicationContext';\nimport { ApplicationStatusModel } from '@n2-common/serverGeneratedTypings/applicationStatusModel';\nimport { N2ApplicationStatus } from '@n2-common/serverGeneratedTypings/n2ApplicationStatus';\nimport { getApplicationStatus } from '@n2-common/services/legacyApplicationApiService';\nimport { logErrorToServerside } from '@n2-common/services/serverSideLogging';\nimport { generatePath, LoaderFunctionArgs, redirect, useLoaderData } from 'react-router-dom';\nimport { type TFunction } from 'i18next';\nimport { getI18n } from 'react-i18next';\n\ntype StatusPageStatus = N2ApplicationStatus | 'SignCompleted' | 'SetPinCompleted';\n\nexport function getStatusPageLoader(status: N2ApplicationStatus) {\n const { getFixedT } = getI18n();\n const t = getFixedT(null, 'common', 'ApplicationLandingPages');\n const predicate: (applicationStatus: ApplicationStatusModel) => boolean = (applicationStatus) => {\n return applicationStatus.Status == status;\n };\n return async function StatusPageLoader({ request }: LoaderFunctionArgs) {\n const { applicantId, applicationId } = await getApplicationIds(request);\n\n if (applicantId === null || applicationId === null) {\n return redirect(generatePath(ApplicationPaths.error));\n }\n\n try {\n const applicationStatus = await getApplicationStatus(applicationId, applicantId, request.signal);\n\n if (!predicate(applicationStatus)) {\n return safeRedirect(request.url, applicationStatus, applicantId);\n }\n return getStatusPageData(status, t);\n } catch (err) {\n logErrorToServerside(`Error loading data for '${status}'.`, applicationId, applicantId, err || {});\n return redirect(generatePath(ApplicationPaths.error));\n }\n };\n}\n\nexport function getLandingPageLoader(status: StatusPageStatus) {\n return async function StatusPageLoader() {\n const i18n = getI18n();\n if (!i18n.isInitialized) {\n const t = await new Promise((resolve) => {\n i18n.on('initialized', () => resolve(i18n.getFixedT(null, 'common', 'ApplicationLandingPages')));\n });\n return getStatusPageData(status, t);\n }\n return getStatusPageData(status, i18n.getFixedT(null, 'common', 'ApplicationLandingPages'));\n };\n}\n\ntype StatusPageData = {\n heading: string;\n subheading: string;\n body?: string;\n linkText?: string;\n};\nexport function useStatusPageLoaderData() {\n const data = useLoaderData() as Awaited;\n assertDataIsNotResponse(data);\n return data;\n}\nfunction getStatusPageData(status: StatusPageStatus, t: TFunction): StatusPageData {\n return {\n heading: t(`${status}.Headline`, ''),\n subheading: t(`${status}.SubHeadline`, ''),\n body: t(`${status}.Body`, ''),\n linkText: t(`${status}.LinkText`, ''),\n };\n}\n","import React from 'react';\nimport style from './style.module.scss';\nimport { ExternalLink, Headline, HtmlContainer, Section } from '@n2-common/ui';\nimport { useStatusPageLoaderData } from './loader';\n\nexport * from './loader';\n\ntype StatusPageProps = { linkKey?: Parameters[0]['linkKey'] };\n\nexport default function StatusPage({ linkKey }: StatusPageProps) {\n const data = useStatusPageLoaderData();\n return ;\n}\n\nexport function StatusPageComponent({ heading, subheading, body, linkKey, linkText }: ReturnType & StatusPageProps) {\n return (\n
\n {heading && {heading}}\n {subheading && {subheading}}\n {body && (\n
\n \n
\n )}\n {linkKey && linkText && (\n
\n \n {linkText}\n \n
\n )}\n
\n );\n}\n"],"names":["getLandingPageLoader","status","i18n","getI18n","t","resolve","getStatusPageData","useStatusPageLoaderData","data","useLoaderData","assertDataIsNotResponse","StatusPage","linkKey","jsx","StatusPageComponent","heading","subheading","body","linkText","jsxs","style","Headline","Section","HtmlContainer","ExternalLink"],"mappings":"0NAyCO,SAASA,EAAqBC,EAA0B,CAC3D,OAAO,gBAAkC,CACrC,MAAMC,EAAOC,IACT,GAAA,CAACD,EAAK,cAAe,CACrB,MAAME,EAAI,MAAM,IAAI,QAAoBC,GAAY,CAC3CH,EAAA,GAAG,cAAe,IAAMG,EAAQH,EAAK,UAAU,KAAM,SAAU,yBAAyB,CAAC,CA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