diff --git a/libs/application/templates/financial-aid/src/fields/Summary/FileList.tsx b/libs/application/templates/financial-aid/src/fields/Summary/FileList.tsx index 8706ccce4976..5a637f8a87d6 100644 --- a/libs/application/templates/financial-aid/src/fields/Summary/FileList.tsx +++ b/libs/application/templates/financial-aid/src/fields/Summary/FileList.tsx @@ -1,17 +1,24 @@ import React from 'react' +import { useIntl } from 'react-intl' +import cn from 'classnames' import { Text, Box, UploadFile } from '@island.is/island-ui/core' -import { getFileType } from '@island.is/financial-aid/shared/lib' +import { + getFileSizeInKilo, + getFileType, +} from '@island.is/financial-aid/shared/lib' import { useFileUpload } from '../../lib/hooks/useFileUpload' -import cn from 'classnames' - +import { missingFiles } from '../../lib/messages' import * as styles from './FileList.css' -type Props = { +interface Props { applicationSystemId: string files?: UploadFile[] } -const FileList = ({ files }: Props) => { +const FileList = ({ files, applicationSystemId }: Props) => { + const { formatMessage } = useIntl() + const { openFileById } = useFileUpload(files ?? [], applicationSystemId) + if (files === undefined || files.length === 0) { return null } @@ -19,13 +26,17 @@ const FileList = ({ files }: Props) => { return ( {files.map((file, i) => { - return file.key ? ( -
{ + e.preventDefault() + openFileById(file.id as string) + }} >
@@ -36,12 +47,14 @@ const FileList = ({ files }: Props) => {
{file.name}
+ {`${formatMessage( + missingFiles.confirmation.file, + )} • ${getFileSizeInKilo(file)} KB`}
-
+ ) : null })} ) } - export default FileList diff --git a/libs/application/templates/financial-aid/src/fields/childrenFilesForm/ChildrenFilesForm.tsx b/libs/application/templates/financial-aid/src/fields/childrenFilesForm/ChildrenFilesForm.tsx new file mode 100644 index 000000000000..4e8c901d9749 --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/childrenFilesForm/ChildrenFilesForm.tsx @@ -0,0 +1,25 @@ +import React from 'react' +import { useIntl } from 'react-intl' +import { Text, UploadFile } from '@island.is/island-ui/core' +import { childrenFilesForm } from '../../lib/messages' +import { UploadFileType } from '../..' +import Files from '../files/Files' +import { FieldBaseProps } from '@island.is/application/types' + +export const ChildrenFilesForm = ({ field, application }: FieldBaseProps) => { + const { formatMessage } = useIntl() + const { id, answers } = application + + return ( + <> + + {formatMessage(childrenFilesForm.general.description)} + + + + ) +} diff --git a/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadControler.tsx b/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadControler.tsx new file mode 100644 index 000000000000..297bbefe6d7a --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadControler.tsx @@ -0,0 +1,36 @@ +import React, { ReactNode } from 'react' +import { useIntl } from 'react-intl' +import { Text, Box, GridRow, GridColumn } from '@island.is/island-ui/core' +import { filesText } from '../../lib/messages' +import cn from 'classnames' +import * as styles from './FileUploadController.css' +interface Props { + children: ReactNode + hasError?: boolean +} + +const FileUploadContainer = ({ children, hasError = false }: Props) => { + const { formatMessage } = useIntl() + + return ( + + + {children} +
+ + {formatMessage(filesText.errorMessage)} + +
+
+
+ ) +} + +export default FileUploadContainer diff --git a/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadController.css.ts b/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadController.css.ts new file mode 100644 index 000000000000..f3d55639bad4 --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/fileUploadController/FileUploadController.css.ts @@ -0,0 +1,11 @@ +import { style } from '@vanilla-extract/css' +import { theme } from '@island.is/island-ui/theme' + +export const errorMessage = style({ + overflow: 'hidden', + maxHeight: '0', + transition: 'max-height 250ms ease', +}) +export const showErrorMessage = style({ + maxHeight: theme.spacing[5], +}) diff --git a/libs/application/templates/financial-aid/src/fields/files/Files.tsx b/libs/application/templates/financial-aid/src/fields/files/Files.tsx new file mode 100644 index 000000000000..e1077c1412d5 --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/files/Files.tsx @@ -0,0 +1,71 @@ +import React, { useEffect } from 'react' +import { InputFileUpload, UploadFile } from '@island.is/island-ui/core' + +import { useIntl } from 'react-intl' +import { filesText } from '../../lib/messages' +import { UploadFileType } from '../../lib/types' +import { useFormContext } from 'react-hook-form' +import { useFileUpload } from '../../lib/hooks/useFileUpload' +import { FILE_SIZE_LIMIT, UPLOAD_ACCEPT } from '../../lib/constants' +import FileUploadContainer from '../fileUploadController/FileUploadControler' + +interface Props { + uploadFiles: UploadFile[] + fileKey: UploadFileType + folderId: string + hasError?: boolean +} + +const Files = ({ uploadFiles, fileKey, folderId, hasError = false }: Props) => { + const { formatMessage } = useIntl() + const { setValue } = useFormContext() + + const { + files, + uploadErrorMessage, + onChange, + onRemove, + onRetry, + onUploadRejection, + } = useFileUpload(uploadFiles, folderId) + + const fileToObject = (file: UploadFile) => { + return { + key: file.key, + name: file.name, + size: file.size, + status: file.status, + percent: file?.percent, + } + } + + useEffect(() => { + const formFiles = files + .filter((f) => f.status === 'done') + .map((f) => { + return fileToObject(f) + }) + setValue(fileKey, formFiles) + }, [files]) + + return ( + + + + ) +} + +export default Files diff --git a/libs/application/templates/financial-aid/src/fields/incomeFilesForm/IncomeFilesForm.tsx b/libs/application/templates/financial-aid/src/fields/incomeFilesForm/IncomeFilesForm.tsx new file mode 100644 index 000000000000..c69fabaa0f5b --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/incomeFilesForm/IncomeFilesForm.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import { useIntl } from 'react-intl' +import { Text, UploadFile } from '@island.is/island-ui/core' +import { incomeFilesForm } from '../../lib/messages' +import { UploadFileType } from '../..' +import { FieldBaseProps } from '@island.is/application/types' +import { getValueViaPath } from '@island.is/application/core' +import Files from '../files/Files' + +export const IncomeFilesForm = ({ field, application }: FieldBaseProps) => { + const { formatMessage } = useIntl() + const { id, answers, externalData } = application + const success = getValueViaPath( + externalData, + 'taxData.data.municipalitiesDirectTaxPayments.success', + ) + return ( + <> + + {formatMessage( + success + ? incomeFilesForm.general.descriptionTaxSuccess + : incomeFilesForm.general.description, + )} + + + + ) +} diff --git a/libs/application/templates/financial-aid/src/fields/index.ts b/libs/application/templates/financial-aid/src/fields/index.ts index 39e0c44bdc48..de41cb87c6bf 100644 --- a/libs/application/templates/financial-aid/src/fields/index.ts +++ b/libs/application/templates/financial-aid/src/fields/index.ts @@ -5,3 +5,7 @@ export { SpouseSummaryForm } from './Summary/SpouseSummaryForm' export { ApplicantStatus } from './Status/ApplicantStatus' export { SpouseStatus } from './Status/SpouseStatus' export { MissingFilesConfirmation } from './Summary/MissingFilesConfirmation' +export { ChildrenFilesForm } from './childrenFilesForm/ChildrenFilesForm' +export { IncomeFilesForm } from './incomeFilesForm/IncomeFilesForm' +export { TaxReturnFilesForm } from './taxReturnFilesForm/TaxReturnFilesForm' +export { MissingFiles } from './missingFiles/MissingFiles' diff --git a/libs/application/templates/financial-aid/src/fields/missingFiles/MissingFiles.tsx b/libs/application/templates/financial-aid/src/fields/missingFiles/MissingFiles.tsx new file mode 100644 index 000000000000..4b0edab8d80d --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/missingFiles/MissingFiles.tsx @@ -0,0 +1,181 @@ +import React, { useEffect, useMemo, useState } from 'react' +import { useIntl } from 'react-intl' +import { + Text, + Box, + AlertMessage, + Input, + LoadingDots, +} from '@island.is/island-ui/core' +import { + ApplicationEventType, + ApplicationState, + FileType, + getCommentFromLatestEvent, +} from '@island.is/financial-aid/shared/lib' +import { getValueViaPath } from '@island.is/application/core' +import { FieldBaseProps, RecordObject } from '@island.is/application/types' +import { filesText, missingFiles } from '../../lib/messages' +import { UploadFileType } from '../../lib/types' +import useApplication from '../../lib/hooks/useApplication' +import { Controller, useFormContext } from 'react-hook-form' +import { useFileUpload } from '../../lib/hooks/useFileUpload' +import Files from '../files/Files' +import DescriptionText from '../../components/DescriptionText/DescriptionText' + +export const MissingFiles = ({ + application, + setBeforeSubmitCallback, + field, +}: FieldBaseProps) => { + const currentApplicationId = getValueViaPath( + application.externalData, + 'currentApplication.data.currentApplicationId', + ) + const email = getValueViaPath( + application.externalData, + 'municipality.data.email', + ) + const { currentApplication, updateApplication, loading } = + useApplication(currentApplicationId) + const isSpouse = getValueViaPath(field as RecordObject, 'props.isSpouse') + + const { formatMessage } = useIntl() + const { setValue, getValues } = useFormContext() + const fileType: UploadFileType = 'otherFiles' + const commentType = 'fileUploadComment' + const files = getValues(fileType) + + const { uploadFiles } = useFileUpload(files, application.id) + + const [error, setError] = useState(false) + const [filesError, setFilesError] = useState(false) + + const fileComment = useMemo(() => { + if (currentApplication?.applicationEvents) { + return getCommentFromLatestEvent( + currentApplication?.applicationEvents, + ApplicationEventType.DATANEEDED, + ) + } + }, [currentApplication]) + + useEffect(() => { + if (filesError) { + setFilesError(false) + } + }, [files]) + + setBeforeSubmitCallback && + setBeforeSubmitCallback(async () => { + setError(false) + if (files.length <= 0) { + setFilesError(true) + return [false, formatMessage(filesText.errorMessage)] + } + + try { + if (!currentApplicationId) { + throw new Error() + } + + const uploadedFiles = await uploadFiles( + currentApplicationId, + FileType.OTHER, + files, + ) + setValue(fileType, uploadedFiles) + + await updateApplication( + ApplicationState.INPROGRESS, + isSpouse + ? ApplicationEventType.SPOUSEFILEUPLOAD + : ApplicationEventType.FILEUPLOAD, + getValues(commentType), + ) + } catch (e) { + setError(true) + return [false, formatMessage(missingFiles.error.title)] + } + return [true, null] + }) + + if (loading) { + return + } + + return ( + <> + + {formatMessage(missingFiles.general.description)} + + + {fileComment?.comment && ( + + + } + /> + + )} + + + + + + + + {formatMessage(missingFiles.comment.title)} + + + { + return ( + { + onChange(e.target.value) + setValue(commentType, e.target.value) + }} + /> + ) + }} + /> + + + + {error && ( + <> + + {formatMessage(missingFiles.error.title)} + + + + )} + + ) +} diff --git a/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxFormContent.tsx b/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxFormContent.tsx new file mode 100644 index 000000000000..b24399cae3e2 --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxFormContent.tsx @@ -0,0 +1,77 @@ +import React from 'react' +import { useIntl } from 'react-intl' +import { Text, Box } from '@island.is/island-ui/core' +import { taxReturnForm } from '../../lib/messages' +import DescriptionText from '../../components/DescriptionText/DescriptionText' + +const DirectTaxPaymentsInfo = () => { + const { formatMessage } = useIntl() + return ( + <> + + {formatMessage(taxReturnForm.instructions.findDirectTaxPaymentsTitle)} + + + + {formatMessage(taxReturnForm.instructions.findDirectTaxPayments)} + + + ) +} + +const TaxReturnInfo = () => { + const { formatMessage } = useIntl() + return ( + <> + + {formatMessage(taxReturnForm.instructions.findTaxReturnTitle)} + + + + ) +} + +export const getTaxFormContent = ( + taxReturnFailed: boolean, + directTaxPaymentsFailed: boolean, +) => { + switch (true) { + case taxReturnFailed && !directTaxPaymentsFailed: + return { + data: ( + + + + ), + info: , + } + case directTaxPaymentsFailed && !taxReturnFailed: + return { + data: ( + + + + ), + info: , + } + + default: + return { + data: ( + <> + + + + + ), + info: ( + <> + + + + ), + } + } +} diff --git a/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxReturnFilesForm.tsx b/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxReturnFilesForm.tsx new file mode 100644 index 000000000000..71480d5c5aa0 --- /dev/null +++ b/libs/application/templates/financial-aid/src/fields/taxReturnFilesForm/TaxReturnFilesForm.tsx @@ -0,0 +1,72 @@ +import React from 'react' +import { useIntl } from 'react-intl' +import { UploadFile, Box, AlertMessage } from '@island.is/island-ui/core' +import { taxReturnForm } from '../../lib/messages' +import { TaxData, UploadFileType } from '../..' +import { FieldBaseProps } from '@island.is/application/types' +import Files from '../files/Files' +import { getValueViaPath } from '@island.is/application/core' +import { getTaxFormContent } from './TaxFormContent' + +export const TaxReturnFilesForm = ({ field, application }: FieldBaseProps) => { + const { formatMessage } = useIntl() + const { id, answers, externalData, assignees } = application + const nationalId = getValueViaPath( + externalData, + 'nationalRegistry.data.nationalId', + ) + const taxData = getValueViaPath(externalData, 'taxData.data') + const spouseTaxData = getValueViaPath( + externalData, + 'taxDataSpouse.data', + ) + + const taxDataToUse = + assignees.includes(nationalId ?? '') && spouseTaxData + ? spouseTaxData + : taxData + + if (!taxDataToUse) { + return null + } + + const { municipalitiesDirectTaxPayments, municipalitiesPersonalTaxReturn } = + taxDataToUse + + const taxReturnFetchFailed = + municipalitiesPersonalTaxReturn?.personalTaxReturn === null + const directTaxPaymentsFetchedFailed = + municipalitiesDirectTaxPayments.directTaxPayments.length === 0 && + !municipalitiesDirectTaxPayments.success + const taxDataGatheringFailed = + taxReturnFetchFailed && directTaxPaymentsFetchedFailed + + const content = getTaxFormContent( + taxReturnFetchFailed, + directTaxPaymentsFetchedFailed, + ) + + return ( + <> + {taxDataGatheringFailed && ( + + + + )} + + {content.data} + + + + {content.info} + + ) +} diff --git a/libs/application/templates/financial-aid/src/forms/ApplicantSubmittedForm/MissingFiles.ts b/libs/application/templates/financial-aid/src/forms/ApplicantSubmittedForm/MissingFiles.ts index 2d829cec7d3a..cfe796a5429b 100644 --- a/libs/application/templates/financial-aid/src/forms/ApplicantSubmittedForm/MissingFiles.ts +++ b/libs/application/templates/financial-aid/src/forms/ApplicantSubmittedForm/MissingFiles.ts @@ -1,12 +1,10 @@ import { - buildDescriptionField, - buildFileUploadField, + buildCustomField, buildMultiField, buildSection, buildSubmitField, - buildTextField, } from '@island.is/application/core' -import { FILE_SIZE_LIMIT, Routes, UPLOAD_ACCEPT } from '../../lib/constants' +import { Routes } from '../../lib/constants' import { DefaultEvents } from '@island.is/application/types' import * as m from '../../lib/messages' @@ -19,26 +17,14 @@ export const MissingFiles = buildSection({ title: m.missingFiles.general.pageTitle, description: m.missingFiles.general.description, children: [ - buildFileUploadField({ - id: `${Routes.MISSINGFILES}`, - title: m.missingFiles.general.pageTitle, - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - }), - buildDescriptionField({ - id: `${Routes.MISSINGFILES}.description`, - title: m.missingFiles.comment.title, - marginTop: 4, - titleVariant: 'h3', - }), - buildTextField({ - id: 'fileUploadComment', - title: m.missingFiles.comment.inputTitle, - placeholder: m.missingFiles.comment.inputPlaceholder, - variant: 'textarea', - rows: 6, - }), + buildCustomField( + { + id: Routes.MISSINGFILES, + title: m.missingFiles.general.pageTitle, + component: 'MissingFiles', + }, + { isSpouse: false }, + ), buildSubmitField({ id: 'missingFilesSubmit', title: '', diff --git a/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/incomeFileSubSection.ts b/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/incomeFileSubSection.ts index 8ad68a5fda79..4648c58268e2 100644 --- a/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/incomeFileSubSection.ts +++ b/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/incomeFileSubSection.ts @@ -1,4 +1,5 @@ import { + buildCustomField, buildFileUploadField, buildMultiField, buildSubSection, @@ -22,12 +23,10 @@ export const incomeFilesSubSection = buildSubSection({ title: m.incomeFilesForm.general.pageTitle, description: m.incomeFilesForm.general.descriptionTaxSuccess, children: [ - buildFileUploadField({ + buildCustomField({ id: Routes.INCOMEFILES, - title: '', - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, + title: m.incomeFilesForm.general.pageTitle, + component: 'IncomeFilesForm', }), ], }), diff --git a/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/taxReturnFilesSubSection.ts b/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/taxReturnFilesSubSection.ts index 8bca3236f2cf..b5e179eacb52 100644 --- a/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/taxReturnFilesSubSection.ts +++ b/libs/application/templates/financial-aid/src/forms/ApplicationForm/financesSection/taxReturnFilesSubSection.ts @@ -1,11 +1,9 @@ import { - buildDescriptionField, - buildFileUploadField, - buildMultiField, + buildCustomField, buildSubSection, getValueViaPath, } from '@island.is/application/core' -import { FILE_SIZE_LIMIT, Routes, UPLOAD_ACCEPT } from '../../../lib/constants' +import { Routes } from '../../../lib/constants' import * as m from '../../../lib/messages' export const taxReturnFilesSubSection = buildSubSection({ @@ -23,33 +21,10 @@ export const taxReturnFilesSubSection = buildSubSection({ return personalTaxSuccess === false || personalTaxReturn == null }, children: [ - buildMultiField({ + buildCustomField({ id: Routes.TAXRETURNFILES, title: m.taxReturnForm.general.pageTitle, - description: m.taxReturnForm.general.description, - children: [ - buildFileUploadField({ - id: Routes.TAXRETURNFILES, - title: '', - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - }), - buildDescriptionField({ - id: `${Routes.TAXRETURNFILES}.findTaxReturn`, - title: m.taxReturnForm.instructions.findTaxReturnTitle, - titleVariant: 'h3', - marginTop: 3, - description: m.taxReturnForm.instructions.findTaxReturn, - }), - buildDescriptionField({ - id: `${Routes.TAXRETURNFILES}.findTaxReturn2`, - title: m.taxReturnForm.instructions.findDirectTaxPaymentsTitle, - titleVariant: 'h3', - marginTop: 3, - description: m.taxReturnForm.instructions.findDirectTaxPayments, - }), - ], + component: 'TaxReturnFilesForm', }), ], }) diff --git a/libs/application/templates/financial-aid/src/forms/ApplicationForm/personalInterestSection/childrenFilesSubSection.ts b/libs/application/templates/financial-aid/src/forms/ApplicationForm/personalInterestSection/childrenFilesSubSection.ts index a932f53022fb..709c9f211acd 100644 --- a/libs/application/templates/financial-aid/src/forms/ApplicationForm/personalInterestSection/childrenFilesSubSection.ts +++ b/libs/application/templates/financial-aid/src/forms/ApplicationForm/personalInterestSection/childrenFilesSubSection.ts @@ -1,10 +1,10 @@ import { - buildFileUploadField, + buildCustomField, buildMultiField, buildSubSection, getValueViaPath, } from '@island.is/application/core' -import { FILE_SIZE_LIMIT, Routes, UPLOAD_ACCEPT } from '../../../lib/constants' +import { Routes } from '../../../lib/constants' import * as m from '../../../lib/messages' import { ApplicantChildCustodyInformation } from '@island.is/application/types' @@ -23,12 +23,10 @@ export const childrenFilesSubSection = buildSubSection({ title: m.childrenFilesForm.general.pageTitle, description: m.childrenFilesForm.general.description, children: [ - buildFileUploadField({ + buildCustomField({ id: Routes.CHILDRENFILES, - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - title: '', + title: m.childrenFilesForm.general.pageTitle, + component: 'ChildrenFilesForm', }), ], }), diff --git a/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseIncomeFilesSection.ts b/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseIncomeFilesSection.ts index 981e0dcef73d..c595cce82ef0 100644 --- a/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseIncomeFilesSection.ts +++ b/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseIncomeFilesSection.ts @@ -1,11 +1,10 @@ import { - buildFileUploadField, - buildMultiField, + buildCustomField, buildSection, getValueViaPath, } from '@island.is/application/core' import { ApproveOptions } from '../../lib/types' -import { FILE_SIZE_LIMIT, Routes, UPLOAD_ACCEPT } from '../../lib/constants' +import { Routes } from '../../lib/constants' import * as m from '../../lib/messages' export const spouseIncomeFilesSection = buildSection({ @@ -16,18 +15,10 @@ export const spouseIncomeFilesSection = buildSection({ id: Routes.SPOUSEINCOMEFILES, title: m.incomeFilesForm.general.sectionTitle, children: [ - buildMultiField({ + buildCustomField({ id: Routes.SPOUSEINCOMEFILES, title: m.incomeFilesForm.general.pageTitle, - description: m.incomeFilesForm.general.description, - children: [ - buildFileUploadField({ - id: Routes.SPOUSEINCOMEFILES, - title: '', - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - }), - ], + component: 'IncomeFilesForm', }), ], }) diff --git a/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseTaxReturnFilesSection.ts b/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseTaxReturnFilesSection.ts index 8ee2894ae18d..20a6b88a1273 100644 --- a/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseTaxReturnFilesSection.ts +++ b/libs/application/templates/financial-aid/src/forms/SpouseForm/spouseTaxReturnFilesSection.ts @@ -1,4 +1,5 @@ import { + buildCustomField, buildDescriptionField, buildFileUploadField, buildMultiField, @@ -7,6 +8,7 @@ import { } from '@island.is/application/core' import { FILE_SIZE_LIMIT, Routes, UPLOAD_ACCEPT } from '../../lib/constants' import * as m from '../../lib/messages' +import { ExternalData } from '@island.is/application/types' export const spouseTaxReturnFilesSection = buildSection({ condition: (_, externalData) => { @@ -23,38 +25,10 @@ export const spouseTaxReturnFilesSection = buildSection({ id: Routes.SPOUSETAXRETURNFILES, title: m.taxReturnForm.general.sectionTitle, children: [ - buildMultiField({ + buildCustomField({ id: Routes.SPOUSETAXRETURNFILES, title: m.taxReturnForm.general.pageTitle, - children: [ - buildDescriptionField({ - id: `${Routes.SPOUSETAXRETURNFILES}-description`, - title: '', - description: m.taxReturnForm.general.description, - marginBottom: 3, - }), - buildFileUploadField({ - id: Routes.SPOUSETAXRETURNFILES, - title: '', - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - }), - buildDescriptionField({ - id: `${Routes.SPOUSETAXRETURNFILES}.findTaxReturn`, - title: m.taxReturnForm.instructions.findTaxReturnTitle, - titleVariant: 'h3', - marginTop: 3, - description: m.taxReturnForm.instructions.findTaxReturn, - }), - buildDescriptionField({ - id: `${Routes.SPOUSETAXRETURNFILES}.findTaxReturn2`, - title: m.taxReturnForm.instructions.findDirectTaxPaymentsTitle, - titleVariant: 'h3', - marginTop: 3, - description: m.taxReturnForm.instructions.findDirectTaxPayments, - }), - ], + component: 'TaxReturnFilesForm', }), ], }) diff --git a/libs/application/templates/financial-aid/src/forms/SpouseSubmittedForm/MissingFiles.ts b/libs/application/templates/financial-aid/src/forms/SpouseSubmittedForm/MissingFiles.ts index 5aaf6f46699c..7fc1b6835e58 100644 --- a/libs/application/templates/financial-aid/src/forms/SpouseSubmittedForm/MissingFiles.ts +++ b/libs/application/templates/financial-aid/src/forms/SpouseSubmittedForm/MissingFiles.ts @@ -1,4 +1,5 @@ import { + buildCustomField, buildDescriptionField, buildFileUploadField, buildMultiField, @@ -19,26 +20,14 @@ export const MissingFiles = buildSection({ title: m.missingFiles.general.pageTitle, description: m.missingFiles.general.description, children: [ - buildFileUploadField({ - id: Routes.MISSINGFILESSPOUSE, - title: m.missingFiles.general.pageTitle, - uploadMultiple: true, - maxSize: FILE_SIZE_LIMIT, - uploadAccept: UPLOAD_ACCEPT, - }), - buildDescriptionField({ - id: `${Routes.MISSINGFILESSPOUSE}.description`, - title: m.missingFiles.comment.title, - marginTop: 4, - titleVariant: 'h3', - }), - buildTextField({ - id: 'fileUploadComment', - title: m.missingFiles.comment.inputTitle, - placeholder: m.missingFiles.comment.inputPlaceholder, - variant: 'textarea', - rows: 6, - }), + buildCustomField( + { + id: Routes.MISSINGFILES, + title: m.missingFiles.general.pageTitle, + component: 'MissingFiles', + }, + { isSpouse: true }, + ), buildSubmitField({ id: 'missingFilesSubmit', title: '', diff --git a/libs/application/templates/financial-aid/src/lib/FinancialAidTemplate.ts b/libs/application/templates/financial-aid/src/lib/FinancialAidTemplate.ts index 24cfc382cd6d..0c19192d553d 100644 --- a/libs/application/templates/financial-aid/src/lib/FinancialAidTemplate.ts +++ b/libs/application/templates/financial-aid/src/lib/FinancialAidTemplate.ts @@ -163,8 +163,8 @@ const FinancialAidTemplate: ApplicationTemplate< target: ApplicationStates.SUBMITTED, cond: hasActiveCurrentApplication, }, - { target: ApplicationStates.SPOUSE }, ], + EDIT: { target: ApplicationStates.SPOUSE }, }, }, [ApplicationStates.SPOUSE]: { diff --git a/libs/application/templates/financial-aid/src/lib/types.ts b/libs/application/templates/financial-aid/src/lib/types.ts index b344216b94ff..48f62d65f3ee 100644 --- a/libs/application/templates/financial-aid/src/lib/types.ts +++ b/libs/application/templates/financial-aid/src/lib/types.ts @@ -1,5 +1,6 @@ import { ApplicantChildCustodyInformation, + ApplicationAnswerFile, NationalRegistryIndividual, NationalRegistrySpouse, } from '@island.is/application/types' @@ -118,3 +119,13 @@ export enum SchoolType { ELEMENTARY = 'elementary', HIGHSCHOOL = 'highSchool', } + +export interface TaxData { + municipalitiesPersonalTaxReturn: { + personalTaxReturn: PersonalTaxReturn | null + } + municipalitiesDirectTaxPayments: { + directTaxPayments: DirectTaxPayment[] + success: boolean + } +} diff --git a/libs/application/templates/financial-aid/src/lib/utils.ts b/libs/application/templates/financial-aid/src/lib/utils.ts index 87d6eaf3d853..c4e3afe6080d 100644 --- a/libs/application/templates/financial-aid/src/lib/utils.ts +++ b/libs/application/templates/financial-aid/src/lib/utils.ts @@ -19,6 +19,7 @@ import { ApplicationStates } from './constants' import sortBy from 'lodash/sortBy' import * as m from '../lib/messages' import { AnswersSchema } from './dataSchema' +import { isRunningOnEnvironment } from '@island.is/shared/utils' const emailRegex = /^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%&'*+/=?`{|}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$/i @@ -79,6 +80,13 @@ export function findFamilyStatus( } export function hasActiveCurrentApplication(context: ApplicationContext) { + // On prod there should only be one active application per user + // When working with gervimaður we might need to have many active applications + const isProd = isRunningOnEnvironment('production') + if (!isProd) { + return false + } + const { externalData } = context.application const currentApplication = getValueViaPath( externalData,