{"version":3,"file":"loan-se-ccc0be4f.js","sources":["../../../client-app/src/apps/loan-se/i18n.ts","../../../client-app/src/apps/loan-se/LoanApplicationWizard/actions/index.tsx","../../../client-app/src/apps/loan-se/LoanApplicationWizard/LoanApplicationWizard.tsx","../../../client-app/src/apps/loan-se/App.tsx","../../../client-app/src/apps/loan-se/main.tsx"],"sourcesContent":["import i18next from 'i18next';\nimport { initReactI18next } from 'react-i18next';\nimport HttpApi from 'i18next-http-backend';\nimport { getRuntime } from '../../common/lib/runtime';\n\nconst runtime = getRuntime();\n\ni18next //\n .use(initReactI18next)\n .use(HttpApi)\n .init({\n interpolation: { escapeValue: false },\n lng: 'se',\n debug: false, //!runtime.isProd,\n ns: ['common', 'validation'],\n backend: {\n loadPath: `${runtime.isProd ? '/client-apps' : ''}/locales/{{lng}}/{{ns}}.json?v=${runtime.build}`,\n },\n fallbackLng: 'se',\n });\n","import o2ApiService from '@n2-common/services/o2Service';\nimport pollForApplicationState from '@n2-common/services/o2Service/pollForApplicationState';\nimport { State } from '@n2-common/services/o2Service/types';\nimport { getTracking } from '@n2-common/lib/useTracking';\nimport { OutcomeValues, type Outcome, PostLoanApplicationResult } from '@n2-common/models';\nimport { SwedishLoanApplication } from '@n2-common/components/WizardFormManager/se/fieldDefinitions';\n\nexport async function postLoanApplication(values: SwedishLoanApplication): Promise {\n const application = { ...values, tracking: await getTracking() };\n\n const applicationId = await o2ApiService.postApplication(application, 'SE', 'loan');\n const state = await pollForApplicationState(applicationId, null, (s) => s != null);\n if (!state) {\n return { outcome: 'Pending', applicationId };\n }\n if (state.status == 'Redirect') {\n return { outcome: 'Redirect', applicationId, applicantId: state.applicantId };\n }\n return { outcome: getOutcome(state.status), applicationId };\n}\n\nfunction getOutcome(status: State): Outcome {\n if ((OutcomeValues as ReadonlyArray).includes(status)) {\n return status as Outcome;\n }\n return 'Pending';\n}\n","import { Headline, HtmlContainer, Paragraph, useDismissableErrorMessage } from '@n2-common/ui';\nimport { submitSsnToGetGpid } from '@n2-common/services/legacyApplicationApiService';\nimport { useNavigate } from 'react-router-dom';\nimport style from './style.module.scss';\nimport { startTransition, useCallback, useEffect, useMemo, useState } from 'react';\nimport Wizard from '@n2-common/components/MultiStageOnePageWizard';\nimport { navigateToStep, ApplicationPaths } from '@n2-common/applicationPages/ApplicationFormsHelpers';\nimport { ProductTypeForTracking, trackCoreBankEvent, trackEcommerceEvent } from '@n2-common/lib/gtm';\nimport { SubmitState } from '@n2-common/components/MultiStageOnePageWizard/types';\nimport { errorToAction } from '@n2-common/applicationPages/applicationErrorHelper';\nimport { postLoanApplication } from './actions';\nimport { redirect } from '@n2-common/models';\nimport { useWizardFormManager } from '@n2-common/components/WizardFormManager';\nimport { useTranslation } from 'react-i18next';\n\nconst productType: ProductTypeForTracking = 'CLF';\n\nconst WizardAppComponent = () => {\n const { t } = useTranslation('common');\n const { initialValues, getWizardStages, mapForSubmit } = useWizardFormManager('SE-CL');\n const navigate = useNavigate();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const { setErrorMessage, ErrorOutput } = useDismissableErrorMessage();\n const country = 'SE';\n const [gpid, setGpid] = useState('');\n\n useEffect(() => {\n document.title = 'Ansök om lån';\n trackCoreBankEvent(productType, country, 'application_start');\n trackEcommerceEvent(productType, country, 'view_item', 0);\n }, [country]);\n\n const stages = useMemo(() => getWizardStages(t), [getWizardStages, t]);\n\n const onSsnStepFinished = useCallback(\n async (values: typeof initialValues) => {\n const cleanedValues = mapForSubmit(values);\n\n try {\n const [, res] = await submitSsnToGetGpid({ Ssn: cleanedValues.mainApplicant.nationalId });\n startTransition(() => setGpid(res.Gpid));\n trackEcommerceEvent(productType, country, 'begin_checkout', parseInt(cleanedValues.desiredCredit, 10), res.Gpid);\n } catch (err) {\n console.error(err);\n return;\n }\n },\n [mapForSubmit, country]\n );\n\n const onSubmit = useCallback(\n async (values: typeof initialValues, setSubmitState: (state: SubmitState) => void) => {\n if (isSubmitting) {\n return;\n }\n setIsSubmitting(true);\n const cleanedValues = mapForSubmit(values);\n setSubmitState('Submitted');\n try {\n startTransition(() => setSubmitState('Processing'));\n\n const loanAmountForTracking = parseInt(cleanedValues.desiredCredit?.replace(/\\s/g, ''));\n trackCoreBankEvent(productType, country, 'application_sent', undefined, undefined, undefined, loanAmountForTracking, gpid);\n const result = await postLoanApplication(cleanedValues);\n redirect(result, navigate);\n } catch (err) {\n const action = errorToAction(err, `${productType}-${country}`, undefined, undefined, 'O2');\n if (action) {\n setErrorMessage(action);\n } else {\n navigateToStep(ApplicationPaths.error, undefined, navigate, undefined);\n }\n startTransition(() => {\n setIsSubmitting(false);\n setSubmitState('Error');\n });\n return;\n }\n },\n [isSubmitting, mapForSubmit, country, gpid, navigate, setErrorMessage]\n );\n\n return (\n <>\n {t('application.headline')}\n \n ('application.description', {\n customerLoanUrl: new URL('/customer-loan/application', window.location.origin).href,\n linkClassName: style.link,\n })}\n />\n \n
\n \n
\n \n \n );\n};\n\nexport default WizardAppComponent;\n","import { createHashRouter, RouterProvider } from 'react-router-dom';\nimport { N2ApplicationStatus } from '../../common/serverGeneratedTypings/n2ApplicationStatus';\nimport { getLandingPageLoader } from '../../common/applicationPages';\nimport ErrorPage from '../../common/applicationPages/ErrorPage';\nimport WizardApp from './LoanApplicationWizard/LoanApplicationWizard';\nimport { ReactRouterErrorBoundary } from '../../common/applicationPages/ReactRouterErrorBoundary';\nimport { ApplicationPaths } from '../../common/applicationPages/ApplicationFormsHelpers';\nimport { PageLayout } from '../../common/applicationPages/AppBase/AppBase';\nimport Status from '@n2-common/applicationPages/Status';\nimport { getLinkKey } from '@n2-common/applicationPages/DeclinedWithLink';\n\n\nexport const App = ({ antiforgeryToken }: { antiforgeryToken: string | undefined }) => {\n const loanSeRouter = createHashRouter([\n {\n element: ,\n children: [\n {\n path: ApplicationPaths.wizard,\n element: ,\n },\n {\n path: ApplicationPaths.declined,\n loader: getLandingPageLoader('DeclinedWithLink' as N2ApplicationStatus),\n element: ,\n },\n {\n path: ApplicationPaths.canceled,\n loader: getLandingPageLoader('Canceled' as N2ApplicationStatus), //There is a spelling error in enumvalue :-(\n element: ,\n },\n {\n path: ApplicationPaths.error,\n element: ,\n },\n ],\n errorElement: ,\n },\n ]);\n\n return (\n <>\n \n \n );\n};\n","import './i18n';\nimport CookieConsent from '@n2-common/components/CookieConsent';\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nimport { App } from './App';\nimport { O2 } from '@n2-common/services/o2Service';\n\nconst rootEl = document.getElementById('root');\nif (!rootEl) {\n throw new Error(\"Missing root element with id='root' in DOM\");\n}\n\nconst applicationType: O2.ApplicationType = `SE-CL`;\nrootEl.dataset.product = applicationType;\n\n\nReactDOM.createRoot(rootEl as HTMLElement).render(\n \n \n \n \n);\n"],"names":["runtime","getRuntime","i18next","initReactI18next","HttpApi","postLoanApplication","values","application","getTracking","applicationId","o2ApiService","state","pollForApplicationState","s","getOutcome","status","OutcomeValues","productType","WizardAppComponent","t","useTranslation","initialValues","getWizardStages","mapForSubmit","useWizardFormManager","navigate","useNavigate","isSubmitting","setIsSubmitting","useState","setErrorMessage","ErrorOutput","useDismissableErrorMessage","country","gpid","setGpid","useEffect","trackCoreBankEvent","trackEcommerceEvent","stages","useMemo","onSsnStepFinished","useCallback","cleanedValues","res","submitSsnToGetGpid","startTransition","err","onSubmit","setSubmitState","loanAmountForTracking","_a","result","redirect","action","errorToAction","navigateToStep","ApplicationPaths","jsxs","Fragment","jsx","Headline","Paragraph","HtmlContainer","style","Wizard","App","antiforgeryToken","loanSeRouter","createHashRouter","PageLayout","WizardApp","getLandingPageLoader","Status","getLinkKey","ErrorPage","ReactRouterErrorBoundary","RouterProvider","rootEl","applicationType","ReactDOM","React","CookieConsent"],"mappings":"+5BAKA,MAAMA,GAAUC,EAAW,EAE3BC,EACK,IAAIC,CAAgB,EACpB,IAAIC,CAAO,EACX,KAAK,CACF,cAAe,CAAE,YAAa,EAAM,EACpC,IAAK,KACL,MAAO,GACP,GAAI,CAAC,SAAU,YAAY,EAC3B,QAAS,C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