{"version":3,"file":"Heading.module-6e4c5132.js","sources":["../../../client-app/src/common/services/cddservice/index.ts","../../../client-app/src/common/applicationPages/CddPage/cddSpec.ts","../../../client-app/src/common/components/FileUploadButton/index.tsx","../../../client-app/src/common/lib/useFootnotes.tsx","../../../client-app/src/common/components/UploadDocuments/DocumentItem.tsx","../../../client-app/src/common/components/UploadDocuments/Uploads.tsx"],"sourcesContent":["import { AnswerOption } from '@n2-common/serverGeneratedTypings/answerOption';\nimport { Question } from '@n2-common/serverGeneratedTypings/question';\nimport { RiskScoreViewModel } from '@n2-common/serverGeneratedTypings/riskScoreViewModel';\nimport { CddAnswer } from '../../serverGeneratedTypings/cddAnswer';\nimport { UpdateApplicationCddInputModel } from '../../serverGeneratedTypings/updateApplicationCddInputModel';\nimport { ServiceMock } from './mock';\nimport { throwIfNotSuccess } from '../errors';\nimport { default as fetch } from '@n2-common/lib/fetchProxy';\n\nexport type CddServiceInterface = Omit;\n\nclass CddService {\n static async fetchCountries() {\n const requestUrl = `/api/n2/duediligence/Countries`;\n const response = await fetch(requestUrl);\n return (await response.json()) as AnswerOption[];\n }\n /**\n * Fetch CDD questions\n *\n * @returns array List of years\n * @param signal Optional AbortSignal, to enable request abortion.\n */\n static async fetchQuestions(productParameters: string, signal?: AbortSignal) {\n const requestUrl = `/api/n2/duediligence/CDD/Questions?${productParameters}`;\n const response = await fetch(requestUrl, { signal });\n await throwIfNotSuccess(response, 'CddService.FetchQuestions');\n return (await response.json()) as Question[];\n }\n\n static async postToKompisApi(applicationId: string, customerGuid: string, payload: CddAnswer[], includesEnhanced: boolean) {\n const requestUrl = `/api/n2/duediligence/CDD/${applicationId}/${customerGuid}?includesEnhanced=${includesEnhanced}`;\n const model: UpdateApplicationCddInputModel = {\n CddQuestionsWithAnswers: payload,\n };\n const response = await fetch(requestUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n redirect: 'error',\n body: JSON.stringify(model),\n });\n\n await throwIfNotSuccess(response, 'CddService.PostToKompisApi');\n\n return (await response.json()) as RiskScoreViewModel;\n }\n}\n\nexport type DueDiligenceType = 'CustomerDueDiligence' | 'OngoingDueDiligence';\n\nconst runtimeService = process.env.NODE_ENV == 'production' ? CddService : ServiceMock;\n\nexport default runtimeService;\n","import { Question } from '@n2-common/serverGeneratedTypings/question';\n\nexport function filterExtendedQuestions(questions: Question[]) {\n return questions.filter((m) => m.ApplicableForEnhancedDueDiligence);\n}\n\nexport function getExtendedQuestions(questions: Question[]): string[] {\n const res = filterExtendedQuestions(questions);\n const questionCodes = res.map((m) => m.QuestionCode);\n return questionCodes;\n}\n\nexport function filterAmlQuestions(questions: Question[], isMainApplicant: boolean | null) {\n return questions.filter((m) => m.ApplicableForAml && (isMainApplicant ? true : m.ApplicableForCoSigner));\n}\n\nexport function getAmlQuestions(questions: Question[], isMainApplicant: boolean | null): string[] {\n const res = filterAmlQuestions(questions, isMainApplicant);\n const questionCodes = res.map((m) => m.QuestionCode);\n return questionCodes;\n}\nexport function getPepQuestions(questions: Question[]): string[] {\n const res = filterPepQuestions(questions);\n const questionCodes = res.map((m) => m.QuestionCode);\n return questionCodes;\n}\n\nexport function filterPepQuestions(questions: Question[]) {\n return questions.filter((m) => m.ApplicableForPep);\n}\n\nexport function getNumericFields(questions: Question[]): string[] {\n const res = questions.filter((m) => m.IsNumeric);\n const questionCodes = res.map((m) => m.QuestionCode);\n return questionCodes;\n}\n\nexport const isPepFieldName = 'IsPep_Customer';\n\ntype Comparrison = {\n questionCode: string;\n compareTo: string;\n message: string;\n validate: (value: string, other: string) => boolean;\n};\n\n/**\n * Array of compare validations. If some field validity depends on value from other field.\n */\nexport const CompareValidation: Comparrison[] = [\n {\n questionCode: 'SecondNationalityCountryCode',\n compareTo: 'NationalityCountryCode',\n message: 'validation:second-nationality.not-same-as-primary',\n validate: (value: string, other: string) => value != other,\n },\n];\n","import React, { ChangeEvent, useMemo, useState } from 'react';\nimport { Button } from '../../ui';\n\nimport style from './style.module.scss';\nimport buttonStyles from '../../ui/Button/style.module.scss';\n\nexport type UploadBoxProps = {\n uploadDocument: (data: FormData) => Promise;\n buttonLabel: string;\n uploadingLabel?: string;\n} & React.ButtonHTMLAttributes;\n\ntype CombinedProps = React.PropsWithChildren & UploadBoxProps;\n\nconst FileUploadButton = ({ children, uploadDocument, buttonLabel, uploadingLabel, disabled: forcedDisabled, ...props }: CombinedProps) => {\n const [uploading, setUploading] = useState(false);\n const disabled = useMemo(() => uploading || forcedDisabled, [forcedDisabled, uploading]);\n\n const hiddenFileInput = React.useRef(null);\n\n const handleClick = () => {\n if (disabled || !hiddenFileInput || hiddenFileInput?.current === null) {\n return;\n }\n hiddenFileInput.current.click();\n };\n\n const uploadFiles = (e: ChangeEvent) => {\n if (!e || !e.target || !e.target.files) {\n return;\n }\n const data = new FormData();\n for (const file of e.target.files) {\n data.append('uploadedFiles', file, file.name);\n }\n setUploading(true);\n uploadDocument(data).then(\n () => setUploading(false),\n () => setUploading(false)\n );\n };\n\n return (\n <>\n {children}\n \n \n {uploading ? uploadingLabel || `${buttonLabel}...` : buttonLabel}\n \n \n );\n};\n\nexport default FileUploadButton;\n","import { useMemo } from 'react';\nimport style from './useFootnotes.module.scss';\ntype SymbolNote = { symbol: string; description: string };\ntype ClassNote = { className: string; id?: string; description: string };\nexport type NoteInfo = SymbolNote | ClassNote;\nexport type Selector = (item: T) => NoteInfo | null;\n\nexport function useFootnotes(data: T[], select: Selector) {\n const distinct = useMemo(\n () => (data.map(select).filter((m, i, arr) => arr.findIndex((itm) => areEqual(itm, m)) == i) as NoteInfo[]).sort(bySymbol),\n [data, select]\n );\n const List = (\n
    \n {distinct.map((itm, i) => (\n
  • \n \n {itm.description}\n
  • \n ))}\n
\n );\n const symbols = distinct.map((itm) => (isSymbol(itm) ? itm.symbol : itm.className));\n\n return [List, symbols];\n}\n\nexport function StatusIcon({ note: info }: { note: NoteInfo | null }) {\n return info ? (\n isSymbol(info) ? (\n {info.symbol}\n ) : (\n
\n \n {info.id}\n
\n )\n ) : null;\n}\n\nfunction bySymbol(a: NoteInfo, b: NoteInfo) {\n const valA = isSymbol(a) ? a.symbol : a.className;\n const valB = isSymbol(b) ? b.symbol : b.className;\n if (valA < valB) {\n return -1;\n }\n if (valA > valB) {\n return 1;\n }\n return 0;\n}\n\nexport function isSymbol(info: NoteInfo | null): info is SymbolNote {\n return info != null && 'symbol' in info;\n}\nexport function isClass(info: NoteInfo | null): info is ClassNote {\n return info != null && 'className' in info;\n}\nfunction areEqual(a: NoteInfo | null, b: NoteInfo | null) {\n if (isSymbol(a) && isSymbol(b)) {\n return a.symbol == b.symbol;\n }\n if (isClass(a) && isClass(b)) {\n return a.className == b.className && a.id == b.id;\n }\n return false;\n}\n","import { useCallback } from 'react';\nimport style from './style.module.scss';\nimport icon from '../../icons/icons.module.scss';\nimport { StatusIcon, type Selector } from '@n2-common/lib/useFootnotes';\nimport { useTranslation } from 'react-i18next';\nimport { joinNames } from '@n2-common/ui/helpers';\n\nexport function DocumentItem({\n info,\n deleteDocumentHandler,\n selectFootnote,\n}: {\n info: DocumentInfo;\n deleteDocumentHandler: (documentId: string) => void;\n selectFootnote: Selector;\n}) {\n const { t } = useTranslation('common');\n // TODO: Prevent doubleclick!\n const onDeleteClick = useCallback(() => deleteDocumentHandler(info.id), [deleteDocumentHandler, info.id]);\n const isDeleteable = info.deleteable;\n return (\n isDeleteable && ['Enter', 'NumpadEnter'].includes(e.code) && onDeleteClick()}\n >\n \n
{info.filename}
\n {isDeleteable && (\n ('Sign.Documents.RemoveText')}\n >\n )}\n \n );\n}\n\nexport type DocumentInfo = {\n /** Id to use for deletion. */\n id: string;\n /** Reference id from upload */\n ref: string;\n status: string;\n error?: string;\n filename: string;\n /** Document is received via trusted third party - ex in Norway SBL */\n trusted: boolean;\n deleteable: boolean;\n};\n","import { type DocumentInfo, DocumentItem } from './DocumentItem';\nimport { joinNames } from '@n2-common/ui/helpers';\nimport style from './style.module.scss';\nimport { type Selector } from '@n2-common/lib/useFootnotes';\nimport { useMemo } from 'react';\n\nexport function Uploads({ documents, refreshing, deleteDocumentHandler, footnoteSelector }: UploadsProps) {\n const documentList = useMemo(\n () =>\n documents.map((elm, i) => (\n \n )),\n [deleteDocumentHandler, documents, footnoteSelector]\n );\n return documentList.length ?
{documentList}
: null;\n}\n\ntype UploadsProps = {\n documents: DocumentInfo[];\n refreshing: boolean;\n deleteDocumentHandler: (documentId: string) => void;\n footnoteSelector: Selector;\n};\n"],"names":["CddService","fetch","productParameters","signal","requestUrl","response","throwIfNotSuccess","applicationId","customerGuid","payload","includesEnhanced","runtimeService","filterExtendedQuestions","questions","m","getExtendedQuestions","filterAmlQuestions","isMainApplicant","getAmlQuestions","getPepQuestions","filterPepQuestions","isPepFieldName","CompareValidation","value","other","FileUploadButton","children","uploadDocument","buttonLabel","uploadingLabel","forcedDisabled","props","uploading","setUploading","useState","disabled","useMemo","hiddenFileInput","React","handleClick","uploadFiles","e","data","file","jsxs","Fragment","jsx","style","Button","buttonStyles","useFootnotes","select","distinct","i","arr","itm","areEqual","bySymbol","List","StatusIcon","symbols","isSymbol","info","a","b","valA","valB","isClass","DocumentItem","deleteDocumentHandler","selectFootnote","t","useTranslation","onDeleteClick","useCallback","isDeleteable","joinNames","icon","Uploads","documents","refreshing","footnoteSelector","documentList","elm"],"mappings":"gLAWA,MAAMA,CAAW,CACb,aAAa,gBAAiB,CAGlB,OAAA,MADS,MAAMC,EADJ,gCACoB,GAChB,MAC3B,CAOA,aAAa,eAAeC,EAA2BC,EAAsB,CACnE,MAAAC,EAAa,sCAAsCF,CAAiB,GACpEG,EAAW,MAAMJ,EAAMG,EAAY,CAAE,OAAAD,CAAQ,CAAA,EAC7C,aAAAG,EAAkBD,EAAU,2BAA2B,EACrD,MAAMA,EAAS,MAC3B,CAEA,aAAa,gBAAgBE,EAAuBC,EAAsBC,EAAsBC,EAA2B,CACvH,MAAMN,EAAa,4BAA4BG,CAAa,IAAIC,CAAY,qBAAqBE,CAAgB,GAI3GL,EAAW,MAAMJ,EAAMG,E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