{"version":3,"sources":["components/LoadingPage/styles.ts","components/LoadingPage/LoadingPage.tsx","components/LoadingPage/index.tsx","hooks/requests/virtualLookup.ts","features/prescreen/BatchPrescreenStart/LookupPrescreenId/index.tsx","features/prescreen/BatchPrescreenStart/LookupPrescreenId/LookupPrescreenId.tsx","features/prescreen/BatchPrescreenStart/FormPrescreenId/styles.ts","features/prescreen/BatchPrescreenStart/FormPrescreenId/FormPrescreenIdView.tsx","features/prescreen/BatchPrescreenStart/FormPrescreenId/FormPrescreenId.tsx","features/prescreen/BatchPrescreenStart/FormPrescreenId/index.tsx","features/prescreen/BatchPrescreenStart/BatchPrescreenStart.tsx"],"names":["styles","titleText","theme","css","LoadingPage","props","headerTitle","Box","mt","mb","PageContainer","Grid","container","alignItems","justify","item","my","CircularProgress","aria-label","size","VirtualLookupError","Error","useVirtualLookup","useState","error","setError","useFetchApi","status","fetch","dispatch","useDispatch","useQueryParameters","mockVL","location","channel","subchannel","handleExistingAccount","useHandleExistingAccount","creditApplication","useSelector","selectCreditApplication","tenant","selectTenant","setAnalyticsVariables","useAnalyticsVariables","useCallback","params","a","sharedParams","mockResponse","idParams","prescreenId","prequalificationId","method","body","response","ok","Promise","reject","json","searchResults","applicationId","accountId","trustedBrandPrefill","searchResultsKeys","keys","pick","pickBy","isPresent","hasExistingAccount","sendToSdk","mergeApplication","results","complement","isNil","firstName","lastName","address1","address2","city","state","zip","ssn","setPrescreenId","lockFields","Boolean","mergePrequalOffer","creditLimit","LookupPrescreenId","t","useTranslate","virtualLookupCall","fetched","useRef","useEffect","current","headingContainer","mui","spacing","idPrompt","subtitleText","formFields","submitButton","FormPrescreenIdView","isValid","isSubmitting","attempts","maxAttempts","tMd","useMarkdownTranslate","tMdMultiline","useMarkdownMultilineTranslate","pathAfter","useWorkflow","hasError","count","maxWidth","name","fieldProps","id","mask","prescreenIdMask","label","helperText","undefined","IovationButton","type","disabled","loading","Button","component","Link","to","Step","BATCH_PRESCREEN_START","variant","CancelButton","schema","Yup","shape","required","concat","isPrescreenId","FormPrescreenId","onSubmit","values","initialValues","FmcForm","validationSchema","initialTouched","initialDataKeys","BatchPrescreenStart","useLoadInitialData","useTrackApplicationStart","virtualLookup","push","useNavigationHelpers","setAttempts","successfulVirtualLookup","selectVirtualLookupSuccessful","makeVirtualLookupCall","prescreenIdInput","isExpired","setVirtualLookupSuccessful","NonClientError","console"],"mappings":"oSAGA,IAOeA,EAPA,CACbC,UAAW,SAACC,GAAD,OAAoCC,YAAnC,IACRF,YAAUC,MC4BDE,EArBiC,SAAAC,GAAU,IAChDC,EAAgBD,EAAhBC,YACR,OACE,YAACC,EAAA,EAAD,CAAKC,GAAI,GACP,YAACD,EAAA,EAAD,CAAKE,GAAI,GACP,kBAAIN,IAAKH,EAAOC,WAAYK,IAG9B,YAACI,EAAA,EAAD,KACE,YAACC,EAAA,EAAD,CAAMC,WAAS,EAACC,WAAW,SAASC,QAAQ,UAC1C,YAACH,EAAA,EAAD,CAAMI,MAAI,GACR,YAACR,EAAA,EAAD,CAAKS,GAAI,GACP,YAACC,EAAA,EAAD,CAAkBC,aAAW,WAAWC,KAAM,WCtB7Cf,O,yRCoEFgB,EAAb,wIAAwCC,QA6GzBC,IA/F6B,WAAO,IAAD,EACtBC,oBAAkB,GADI,mBACzCC,EADyC,KAClCC,EADkC,OAExBC,cAFwB,mBAEzCC,EAFyC,KAEjCC,EAFiC,KAG1CC,EAAWC,cAH+B,EAIEC,cAA1CC,EAJwC,EAIxCA,OAAQC,EAJgC,EAIhCA,SAAUC,EAJsB,EAItBA,QAASC,EAJa,EAIbA,WAC7BC,EAAwBC,cACxBC,EAAoBC,YAAYC,KAChCC,EAASF,YAAYG,KACnBC,EAA0BC,cAA1BD,sBAoFR,MAAO,CAlFeE,sBAAW,uCAC/B,WAAOC,GAAP,uBAAAC,EAAA,6DACEtB,GAAS,GACHuB,EAAe,CACnBC,aAAcjB,EACdC,WACAC,UACAC,cAEIe,EACJ,gBAAiBJ,EACb,CAAEK,YAAaL,EAAO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5BtG,EAAgBpB,cAAhBoB,YAH4B,EAIZ7B,cAAjBoI,EAJ6B,oBAK5BC,EAASC,cAATD,KAEA3C,EAAcC,cAAdD,UAP4B,EAQJzF,mBAAiB,GARb,mBAQ7BmF,EAR6B,KAQnBmD,EARmB,KAS9BhI,EAAWC,cACXgI,EAA0BvH,YAAYwH,KAEtCC,EAAwBnH,sBAAW,uCACvC,WAAOoH,GAAP,eAAAlH,EAAA,+EAE2B2G,EAAc,CAAEvG,YAAa8G,IAFxD,OAEU1G,EAFV,OAGIsG,GAAY,SAAAnD,GAAQ,OAAIA,EAAW,KAC/BnD,EAASc,mBACXsF,EAAK,qBACIpG,EAAS2G,UAClBP,EAAK,4BASL9H,EAASsI,aAA2B,IAhB1C,gDAmBU,gBAAa/I,KAAsB,gBAAagJ,KACpDC,QAAQ7I,MAAR,MAEE2B,EACFwG,EAAK,0BAELE,GAAY,SAAAnD,GAAQ,OAAIA,EAAW,KAzBzC,yDADuC,sDA8BvC,CAAC7E,EAAUgI,EAAaH,EAAevG,EAAawG,IAWtD,OARA7D,qBAAU,WACJY,GA5Ea,EA6EfiD,EAAK,0BACIG,GACTH,EAAK3C,EAAUqB,IAAKC,0BAErB,CAACqB,EAAM3C,EAAW8C,EAAyBpD,IAE1CA,GAnFe,GAmFaoD,EAKvB,KACE3G,GAA4B,IAAbuD,EAGjB,kBAAC,EAAD,CAAmBf,kBAAmBqE,IAG3C,kBAAC,EAAD,CACErE,kBAAmBqE,EACnBtD,SAAUA,EACVC,YAlGa","file":"static/js/BatchPrescreenStart.ed6f7287.chunk.js","sourcesContent":["import { css, SerializedStyles } from '@emotion/core';\nimport { Theme, titleText } from 'features/Theme';\n\nconst styles = {\n titleText: (theme: Theme): SerializedStyles => css`\n ${titleText(theme)}\n text-align: center;\n `,\n};\n\nexport default styles;\n","/** @jsx jsx */\nimport React from 'react';\nimport { jsx } from '@emotion/core';\n\nimport { Box, CircularProgress, Grid } from '@material-ui/core';\nimport PageContainer from 'components/PageContainer';\n\nimport styles from './styles';\ninterface LoadingViewProps {\n headerTitle: string;\n}\n\nconst LoadingPage: React.FC = props => {\n const { headerTitle } = props;\n return (\n \n \n

{headerTitle}

\n
\n\n \n \n \n \n \n \n \n \n \n
\n );\n};\n\nexport default LoadingPage;\n","import LoadingPage from './LoadingPage';\n\nexport default LoadingPage;\n","/* eslint-disable @typescript-eslint/camelcase */\n\nimport { useState, useCallback } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\nimport useHandleExistingAccount from './handleExistingAccount';\nimport { Status } from 'hooks/requests/fetchUtils';\nimport useFetchApi from 'hooks/useFetchApi';\nimport useQueryParameters from 'hooks/useQueryParameters';\nimport {\n CreditApplication,\n mergeApplication,\n lockFields,\n selectCreditApplication,\n} from 'state/creditApplication';\nimport { InstantCredit } from 'state/instantCredit';\nimport { selectTenant } from 'state/tenant';\nimport { keys, pick, pickBy, isNil, complement } from 'ramda';\nimport isPresent from 'utils/isPresent';\nimport { setPrescreenId } from 'state/prescreen';\nimport { mergePrequalOffer } from 'state/prequalOffer';\nimport useAnalyticsVariables from 'hooks/useAnalyticVariables';\n\nconst PATH = '/api/virtual_lookup';\n\nexport type VirtualLookupSearchParams =\n | {\n prescreenId: string;\n }\n | {\n prequalificationId: string;\n };\n\ninterface SearchResults {\n returnCode: string | undefined;\n errorMessage: string | undefined;\n errorCode: string | undefined;\n address1: string | undefined;\n address2: string | undefined;\n city: string | undefined;\n state: string | undefined;\n zip: string | undefined;\n ssn: string | undefined;\n dateOfBirth: string | undefined;\n firstName: string | undefined;\n middleInitial: string | undefined;\n lastName: string | undefined;\n hasExistingAccount: false;\n isExpired: boolean | undefined;\n // Perhaps discriminated type is better here.\n prescreenId: string | undefined;\n prequalificationId: string | undefined;\n creditLimit: number | undefined;\n // The prescreen case appears to be able to return these elements\n // without an existing account\n applicationId: string | undefined;\n accountId: string | undefined;\n}\n\ninterface ExistingAccountResult extends InstantCredit {\n hasExistingAccount: true;\n}\n\ntype VirtualLookupResult = SearchResults | ExistingAccountResult;\n\ntype VirtualLookupHook = () => [\n (params: VirtualLookupSearchParams) => Promise,\n Status,\n boolean,\n];\n\nexport class VirtualLookupError extends Error {}\n\nconst prefillValues = (results: SearchResults): Partial =>\n pickBy(complement(isNil), {\n firstName: results.firstName,\n lastName: results.lastName,\n address1: results.address1,\n address2: results.address2,\n city: results.city,\n state: results.state,\n zip: results.zip,\n ssn: results.ssn,\n });\n\nconst useVirtualLookup: VirtualLookupHook = () => {\n const [error, setError] = useState(false);\n const [status, fetch] = useFetchApi();\n const dispatch = useDispatch();\n const { mockVL, location, channel, subchannel } = useQueryParameters();\n const handleExistingAccount = useHandleExistingAccount();\n const creditApplication = useSelector(selectCreditApplication);\n const tenant = useSelector(selectTenant);\n const { setAnalyticsVariables } = useAnalyticsVariables();\n\n const lookupVirtual = useCallback(\n async (params: VirtualLookupSearchParams): Promise => {\n setError(false);\n const sharedParams = {\n mockResponse: mockVL,\n location,\n channel,\n subchannel,\n };\n const idParams =\n 'prescreenId' in params\n ? { prescreenId: params.prescreenId }\n : { prequalificationId: params.prequalificationId };\n\n const response = await fetch(PATH, {\n method: 'POST',\n body: {\n ...sharedParams,\n ...idParams,\n },\n });\n if (!response.ok) {\n setError(true);\n return Promise.reject(new VirtualLookupError());\n }\n\n let searchResults: VirtualLookupResult = await response.json();\n\n setAnalyticsVariables({\n applicationId: searchResults.applicationId,\n accountId: searchResults.accountId,\n });\n\n if (tenant.trustedBrandPrefill) {\n const searchResultsKeys = (keys(\n searchResults,\n ) as unknown) as (keyof SearchResults)[];\n\n searchResults = pick(searchResultsKeys, {\n ...searchResults,\n ...(pickBy(isPresent, creditApplication) as object),\n }) as SearchResults;\n }\n\n if (searchResults.hasExistingAccount) {\n handleExistingAccount(searchResults, { sendToSdk: true });\n } else {\n dispatch(mergeApplication(prefillValues(searchResults)));\n\n if (searchResults.prescreenId) {\n dispatch(setPrescreenId(searchResults.prescreenId));\n } else if (searchResults.prequalificationId) {\n dispatch(\n lockFields({\n ssn: Boolean(searchResults.ssn),\n }),\n );\n dispatch(\n mergePrequalOffer({\n prequalificationId: searchResults.prequalificationId,\n creditLimit: searchResults.creditLimit,\n }),\n );\n }\n }\n\n return searchResults;\n },\n [\n mockVL,\n location,\n channel,\n subchannel,\n fetch,\n setAnalyticsVariables,\n tenant.trustedBrandPrefill,\n creditApplication,\n handleExistingAccount,\n dispatch,\n ],\n );\n\n return [lookupVirtual, status, error];\n};\n\nexport default useVirtualLookup;\n","import LookupPrescreenId from './LookupPrescreenId';\n\nexport default LookupPrescreenId;\n","import React, { FC, useEffect, useRef } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\nimport useQueryParameters from 'hooks/useQueryParameters';\nimport LoadingPage from 'components/LoadingPage';\n\nimport { selectCreditApplication } from 'state/creditApplication';\nimport useTranslate from 'hooks/useTranslate';\nimport { setPrescreenId } from 'state/prescreen';\n\ninterface PropTypes {\n virtualLookupCall: (id: string) => Promise;\n}\n\nconst LookupPrescreenId: FC = props => {\n const t = useTranslate();\n const { prescreenId } = useQueryParameters();\n const { virtualLookupCall } = props;\n const fetched = useRef(false);\n const { firstName } = useSelector(selectCreditApplication);\n const dispatch = useDispatch();\n\n if (prescreenId) {\n dispatch(setPrescreenId(prescreenId));\n }\n\n useEffect(() => {\n if (!prescreenId) {\n throw new Error('prescreenId required for virtual lookup.');\n }\n // Ensure we only fetched once.\n if (!fetched.current) {\n fetched.current = true;\n virtualLookupCall(prescreenId);\n }\n }, [prescreenId, virtualLookupCall]);\n\n const headerTitle = firstName\n ? t('batchPrescreen.prescreenLookup.welcome', { firstName: firstName })\n : t('batchPrescreen.prescreenLookup.loading');\n\n return ;\n};\n\nexport default LookupPrescreenId;\n","import { css } from '@emotion/core';\n\nimport { Theme, titleText, subtitleText } from 'features/Theme';\n\nexport default {\n headingContainer: (theme: Theme) => css`\n text-align: center;\n margin-bottom: ${theme.mui.spacing(3)}px;\n `,\n titleText: (theme: Theme) => css`\n ${titleText(theme)}\n margin-bottom: ${theme.mui.spacing(2)}px;\n `,\n idPrompt: (theme: Theme) => css`\n p {\n ${subtitleText(theme)}\n margin-bottom: ${theme.mui.spacing(2)}px;\n }\n `,\n formFields: (theme: Theme) => css`\n margin-bottom: ${theme.mui.spacing(3)}px;\n `,\n submitButton: (theme: Theme) => css`\n &.MuiButton-root {\n margin-bottom: ${theme.mui.spacing(2)}px;\n }\n `,\n};\n","/** @jsx jsx */\nimport { jsx } from '@emotion/core';\nimport React, { Fragment } from 'react';\nimport { Box } from '@material-ui/core';\nimport { Field, FieldProps, Form, FormikProps } from 'formik';\nimport useTranslate from 'hooks/useTranslate';\nimport {\n useMarkdownTranslate,\n useMarkdownMultilineTranslate,\n} from 'hooks/useTranslate/useTranslate';\nimport Link from 'components/Link';\nimport Button from 'components/Button';\nimport IovationButton from 'features/IovationButton';\n\nimport PageContainer from 'components/PageContainer';\nimport { FormTextField } from 'components/TextField';\n\nimport { FormValues } from './FormPrescreenId';\n\nimport styles from './styles';\nimport useWorkflow, { Step } from 'hooks/useWorkflow';\nimport ActionButtonContainer from 'components/ActionButtonsContainer';\n\nimport { prescreenIdMask } from 'utils/masks';\nimport CancelButton from 'features/CancelButton';\n\ninterface PropTypes extends FormikProps {\n attempts: number;\n maxAttempts: number;\n}\n\nconst FormPrescreenIdView: React.FC = props => {\n const { isValid, isSubmitting, attempts, maxAttempts } = props;\n const t = useTranslate();\n const tMd = useMarkdownTranslate();\n const tMdMultiline = useMarkdownMultilineTranslate();\n const { pathAfter } = useWorkflow();\n\n const hasError = attempts > 0;\n const error = tMd('batchPrescreen.formPrescreen.error', {\n count: maxAttempts - attempts,\n });\n\n return (\n \n \n
\n \n
\n

\n {tMd('batchPrescreen.formPrescreen.title')}\n

\n
\n {tMdMultiline('batchPrescreen.formPrescreen.idPrompt')}\n
\n
\n
\n \n {(fieldProps: FieldProps) => (\n \n )}\n \n
\n
\n \n \n {t('batchPrescreen.formPrescreen.submit')}\n \n {attempts > 0 ? (\n \n {t('batchPrescreen.formPrescreen.secondarySubmit')}\n \n ) : null}\n \n \n
\n
\n
\n );\n};\n\nexport default FormPrescreenIdView;\n","import React, { useCallback } from 'react';\nimport * as Yup from 'yup';\n\nimport FmcForm from 'components/FmcForm';\nimport FormPrescreenIdView from './FormPrescreenIdView';\nimport useQueryParameters from 'hooks/useQueryParameters';\n\nimport { isPrescreenId } from 'utils/validations';\n\nconst schema = Yup.object().shape({\n prescreenId: Yup.string()\n .required('Required')\n .concat(isPrescreenId),\n});\n\nexport type FormValues = ReturnType;\n\ninterface PropTypes {\n virtualLookupCall: (id: string) => Promise;\n attempts: number;\n maxAttempts: number;\n}\n\nconst FormPrescreenId: React.FC = props => {\n const { virtualLookupCall, attempts, maxAttempts } = props;\n const { prescreenId } = useQueryParameters();\n\n const onSubmit = useCallback(\n async (values: FormValues) => {\n virtualLookupCall(values.prescreenId);\n },\n [virtualLookupCall],\n );\n\n const initialValues: FormValues = {\n prescreenId: prescreenId || '',\n };\n\n return (\n \n {props => (\n \n )}\n \n );\n};\n\nexport default FormPrescreenId;\n","import FormPrescreenId from './FormPrescreenId';\n\nexport default FormPrescreenId;\n","import React, { FC, useState, useCallback, useEffect } from 'react';\nimport useQueryParameters from 'hooks/useQueryParameters';\nimport useLoadInitialData from 'hooks/useLoadInitialData';\nimport LookupPrescreenId from './LookupPrescreenId';\nimport FormPrescreenId from './FormPrescreenId';\n\nimport useVirtualLookup, {\n VirtualLookupError,\n} from 'hooks/requests/virtualLookup';\nimport useWorkflow, { Step } from 'hooks/useWorkflow';\nimport useNavigationHelpers from 'hooks/useNavigationHelpers';\nimport { useTrackApplicationStart } from 'hooks/useAnalytics';\nimport { useDispatch, useSelector } from 'react-redux';\nimport {\n setVirtualLookupSuccessful,\n selectVirtualLookupSuccessful,\n} from 'state/prescreen';\nimport { NonClientError } from 'hooks/requests/fetchUtils';\n\n/**\n * Maxmimum number of times the user can try the Virtual Lookup\n */\nconst MAX_ATTEMPTS = 3;\n\nconst initialDataKeys = [\n 'firstName',\n 'lastName',\n 'address1',\n 'address2',\n 'city',\n 'state',\n 'zip',\n 'emailAddress',\n 'mobilePhone',\n 'alternativePhone',\n 'storeNumber',\n 'category',\n 'cardType',\n 'cartAmount',\n 'checkoutAmount',\n 'correlationData',\n 'customerNumber',\n 'loyaltyNumber',\n 'productAmount',\n 'sku',\n 'clientVariable1',\n 'clientVariable2',\n 'clientVariable3',\n 'clientVariable4',\n 'associateId',\n];\n\nconst BatchPrescreenStart: FC = () => {\n useLoadInitialData(initialDataKeys);\n useTrackApplicationStart();\n const { prescreenId } = useQueryParameters();\n const [virtualLookup] = useVirtualLookup();\n const { push } = useNavigationHelpers();\n\n const { pathAfter } = useWorkflow();\n const [attempts, setAttempts] = useState(0);\n const dispatch = useDispatch();\n const successfulVirtualLookup = useSelector(selectVirtualLookupSuccessful);\n\n const makeVirtualLookupCall = useCallback(\n async (prescreenIdInput: string) => {\n try {\n const response = await virtualLookup({ prescreenId: prescreenIdInput });\n setAttempts(attempts => attempts + 1);\n if (response.hasExistingAccount) {\n push('/existing-account');\n } else if (response.isExpired) {\n push('/batch-prescreen/expired');\n } else {\n // The new value for virtualLookupSuccessful is only propagated to the\n // components and hooks on the next render cycle. So looking up the\n // next step immediately here may return the incorrect step.\n //\n // We work around this by only setting the state, and on the next\n // render cycle (when the workflow hooks has the correct value for\n // virtualLookupSuccessful), lookup the next step and navigate.\n dispatch(setVirtualLookupSuccessful(true));\n }\n } catch (e) {\n if (!(e instanceof VirtualLookupError || e instanceof NonClientError)) {\n console.error(e);\n }\n if (prescreenId) {\n push('/batch-prescreen/error');\n } else {\n setAttempts(attempts => attempts + 1);\n }\n }\n },\n [dispatch, setAttempts, virtualLookup, prescreenId, push],\n );\n\n useEffect(() => {\n if (attempts >= MAX_ATTEMPTS) {\n push('/batch-prescreen/error');\n } else if (successfulVirtualLookup) {\n push(pathAfter(Step.BATCH_PRESCREEN_START));\n }\n }, [push, pathAfter, successfulVirtualLookup, attempts]);\n\n if (attempts >= MAX_ATTEMPTS || successfulVirtualLookup) {\n // Nothing to render in this cycle.\n // After mount, the effect above will run and perform a push.\n // If we don't render null here, there will be a flash of the components\n // rendered below.\n return null;\n } else if (prescreenId && attempts === 0) {\n // If prescreenId is present with an error, we don't increment attemps.\n // If attempts are incremented for some reason, there will be a flash of FormPrescreenId\n return ;\n } else {\n return (\n \n );\n }\n};\n\nexport default BatchPrescreenStart;\n"],"sourceRoot":""}