diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts deleted file mode 100644 index ccf45395f1b9..000000000000 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts +++ /dev/null @@ -1,1420 +0,0 @@ -import { - buildAlertMessageField, - buildCustomField, - buildDescriptionField, - buildFileUploadField, - buildMultiField, - buildRadioField, - buildSection, - buildSubSection, - buildTextField, - getValueViaPath, -} from '@island.is/application/core' -import { NO, UPLOAD_ACCEPT, YES, FILE_SIZE_LIMIT } from '../../constants' -import { - accidentDetails, - accidentLocation, - accidentType, - application, - companyInfo, - fatalAccident, - fatalAccidentAttachment, - fishingCompanyInfo, - injuredPersonInformation, - locationAndPurpose, - rescueSquadInfo, - schoolInfo, - sportsClubInfo, - workMachine, - representativeInfo, - addDocuments, - attachments, - error, -} from '../../lib/messages' -import { - AgricultureAccidentLocationEnum, - AttachmentsEnum, - FishermanWorkplaceAccidentLocationEnum, - FishermanWorkplaceAccidentShipLocationEnum, - GeneralWorkplaceAccidentLocationEnum, - ProfessionalAthleteAccidentLocationEnum, - RescueWorkAccidentLocationEnum, - StudiesAccidentLocationEnum, - StudiesAccidentTypeEnum, - WorkAccidentTypeEnum, -} from '../../types' -import { - getAccidentTypeOptions, - hideLocationAndPurpose, - isAgricultureAccident, - isDateOlderThanAYear, - isFatalAccident, - isFishermanAccident, - isGeneralWorkplaceAccident, - isHomeActivitiesAccident, - isInjuredAndRepresentativeOfCompanyOrInstitute, - isInternshipStudiesAccident, - isProfessionalAthleteAccident, - isReportingOnBehalfOfEmployee, - isReportingOnBehalfOfInjured, - isReportingOnBehalfSelf, - isRepresentativeOfCompanyOrInstitute, - isRescueWorkAccident, - isStudiesAccident, - isWorkAccident, -} from '../../utils' -import { isHealthInsured } from '../../utils/isHealthInsured' -import { isSportAccidentAndEmployee } from '../../utils/isSportAccidentAndEmployee' - -export const aboutTheAccidentSection = buildSection({ - id: 'accidentType.section', - title: accidentType.general.sectionTitle, - children: [ - buildSubSection({ - id: 'accidentType.section', - title: accidentType.general.subsectionTitle, - children: [ - buildRadioField({ - id: 'accidentType.radioButton', - width: 'half', - title: accidentType.general.heading, - description: accidentType.general.description, - options: (formValue) => getAccidentTypeOptions(formValue.answers), - }), - ], - }), - buildSubSection({ - id: 'workAccident.subSection', - title: accidentType.workAccidentType.subSectionTitle, - condition: (formValue) => isWorkAccident(formValue), - children: [ - buildMultiField({ - id: 'workAccident.section', - title: accidentType.workAccidentType.heading, - description: accidentType.workAccidentType.description, - children: [ - buildRadioField({ - id: 'workAccident.type', - width: 'half', - title: '', - options: [ - { - value: WorkAccidentTypeEnum.GENERAL, - label: accidentType.workAccidentType.generalWorkAccident, - }, - { - value: WorkAccidentTypeEnum.FISHERMAN, - label: accidentType.workAccidentType.fishermanAccident, - }, - { - value: WorkAccidentTypeEnum.PROFESSIONALATHLETE, - label: accidentType.workAccidentType.professionalAthlete, - }, - { - value: WorkAccidentTypeEnum.AGRICULTURE, - label: accidentType.workAccidentType.agricultureAccident, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert2', - title: attachments.labels.alertMessage, - description: accidentType.warning.agricultureAccidentWarning, - doesNotRequireAnswer: true, - message: accidentType.warning.agricultureAccidentWarning, - alertType: 'warning', - condition: (formValue) => isAgricultureAccident(formValue), - marginBottom: 5, - }), - buildDescriptionField({ - id: 'accidentDetails.descriptionField', - space: 'containerGutter', - title: injuredPersonInformation.general.jobTitle, - description: injuredPersonInformation.general.jobTitleDescription, - width: 'full', - marginBottom: 2, - condition: (formValue) => isReportingOnBehalfSelf(formValue), - }), - buildTextField({ - id: 'injuredPersonInformation.jobTitle', - title: injuredPersonInformation.labels.jobTitle, - backgroundColor: 'white', - width: 'full', - maxLength: 100, - condition: (formValue) => isReportingOnBehalfSelf(formValue), - }), - ], - }), - ], - }), - buildSubSection({ - id: 'studiesAccident.subSection', - title: accidentType.workAccidentType.subSectionTitle, - condition: (formValue) => isStudiesAccident(formValue), - children: [ - buildMultiField({ - id: 'studiesAccident.section', - title: accidentType.studiesAccidentType.heading, - description: accidentType.studiesAccidentType.description, - children: [ - buildRadioField({ - id: 'studiesAccident.type', - title: '', - options: [ - { - value: StudiesAccidentTypeEnum.INTERNSHIP, - label: accidentType.studiesAccidentType.internship, - }, - { - value: StudiesAccidentTypeEnum.APPRENTICESHIP, - label: accidentType.studiesAccidentType.apprenticeship, - }, - { - value: StudiesAccidentTypeEnum.VOCATIONALEDUCATION, - label: accidentType.studiesAccidentType.vocationalEducation, - }, - ], - }), - ], - }), - ], - }), - // Location Subsection - buildSubSection({ - id: 'location.subSection', - title: 'Staðsetning', - children: [ - buildMultiField({ - id: 'sportsClubInfo.employee.field', - title: sportsClubInfo.employee.title, - condition: (formValue) => isProfessionalAthleteAccident(formValue), - children: [ - buildRadioField({ - id: 'onPayRoll.answer', - width: 'half', - title: '', - options: [ - { - value: YES, - label: application.general.yesOptionLabel, - }, - { - value: NO, - label: application.general.noOptionLabel, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert', - title: application.labels.warningTitle, - message: application.labels.warningMessage, - alertType: 'info', - doesNotRequireAnswer: true, - condition: (formValue) => isSportAccidentAndEmployee(formValue), - }), - ], - }), - - // Accident location section - // location of home related accident - buildMultiField({ - id: 'accidentLocation.homeAccident', - title: accidentLocation.homeAccidentLocation.title, - description: accidentLocation.homeAccidentLocation.description, - condition: (formValue) => isHomeActivitiesAccident(formValue), - children: [ - buildTextField({ - id: 'homeAccident.address', - title: accidentLocation.homeAccidentLocation.address, - backgroundColor: 'blue', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'homeAccident.postalCode', - title: accidentLocation.homeAccidentLocation.postalCode, - backgroundColor: 'blue', - width: 'half', - format: '###', - required: true, - }), - buildTextField({ - id: 'homeAccident.community', - title: accidentLocation.homeAccidentLocation.community, - backgroundColor: 'blue', - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'homeAccident.moreDetails', - title: accidentLocation.homeAccidentLocation.moreDetails, - placeholder: - accidentLocation.homeAccidentLocation.moreDetailsPlaceholder, - backgroundColor: 'blue', - rows: 4, - variant: 'textarea', - maxLength: 2000, - }), - ], - }), - // location of general work related accident - buildMultiField({ - id: 'accidentLocation.generalWorkAccident', - title: accidentLocation.general.heading, - description: accidentLocation.general.description, - condition: (formValue) => - isGeneralWorkplaceAccident(formValue) || - isSportAccidentAndEmployee(formValue), - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: GeneralWorkplaceAccidentLocationEnum.ATTHEWORKPLACE, - label: accidentLocation.generalWorkAccident.atTheWorkplace, - }, - { - value: - GeneralWorkplaceAccidentLocationEnum.TOORFROMTHEWORKPLACE, - label: - accidentLocation.generalWorkAccident.toOrFromTheWorkplace, - }, - { - value: GeneralWorkplaceAccidentLocationEnum.OTHER, - label: accidentLocation.generalWorkAccident.other, - }, - ], - }), - ], - }), - // location of rescue work related accident - buildMultiField({ - id: 'accidentLocation.rescueWorkAccident', - title: accidentLocation.general.heading, - description: accidentLocation.rescueWorkAccident.description, - condition: (formValue) => { - return isRescueWorkAccident(formValue) - }, - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: RescueWorkAccidentLocationEnum.DURINGRESCUE, - label: accidentLocation.rescueWorkAccident.duringRescue, - }, - { - value: RescueWorkAccidentLocationEnum.TOORFROMRESCUE, - label: accidentLocation.rescueWorkAccident.toOrFromRescue, - }, - { - value: RescueWorkAccidentLocationEnum.OTHER, - label: accidentLocation.rescueWorkAccident.other, - }, - ], - }), - ], - }), - // location of studies related accident - buildMultiField({ - id: 'accidentLocation.studiesAccident', - title: accidentLocation.studiesAccidentLocation.heading, - description: accidentLocation.studiesAccidentLocation.description, - condition: (formValue) => - isStudiesAccident(formValue) && - !isInternshipStudiesAccident(formValue), - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: StudiesAccidentLocationEnum.ATTHESCHOOL, - label: accidentLocation.studiesAccidentLocation.atTheSchool, - }, - { - value: StudiesAccidentLocationEnum.OTHER, - label: accidentLocation.studiesAccidentLocation.other, - }, - ], - }), - ], - }), - // location of fisherman related accident - buildMultiField({ - id: 'accidentLocation.fishermanAccident', - title: accidentLocation.general.heading, - description: accidentLocation.general.description, - condition: (formValue) => isFishermanAccident(formValue), - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: FishermanWorkplaceAccidentLocationEnum.ONTHESHIP, - label: accidentLocation.fishermanAccident.onTheShip, - }, - { - value: - FishermanWorkplaceAccidentLocationEnum.TOORFROMTHEWORKPLACE, - label: - accidentLocation.fishermanAccident.toOrFromTheWorkplace, - }, - { - value: FishermanWorkplaceAccidentLocationEnum.OTHER, - label: accidentLocation.fishermanAccident.other, - }, - ], - }), - ], - }), - // location of sports related accident - buildMultiField({ - id: 'accidentLocation.professionalAthleteAccident', - title: accidentLocation.general.heading, - description: accidentLocation.general.description, - condition: (formValue) => - isProfessionalAthleteAccident(formValue) && - !isSportAccidentAndEmployee(formValue), - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: - ProfessionalAthleteAccidentLocationEnum.SPORTCLUBSFACILITES, - label: - accidentLocation.professionalAthleteAccident - .atTheClubsSportsFacilites, - }, - { - value: - ProfessionalAthleteAccidentLocationEnum.TOORFROMTHESPORTCLUBSFACILITES, - label: - accidentLocation.professionalAthleteAccident - .toOrFromTheSportsFacilites, - }, - { - value: ProfessionalAthleteAccidentLocationEnum.OTHER, - label: accidentLocation.professionalAthleteAccident.other, - }, - ], - }), - ], - }), - // location of agriculture related accident - buildMultiField({ - id: 'accidentLocation.agricultureAccident', - title: accidentLocation.general.heading, - description: accidentLocation.general.description, - condition: (formValue) => isAgricultureAccident(formValue), - children: [ - buildRadioField({ - id: 'accidentLocation.answer', - title: '', - options: [ - { - value: AgricultureAccidentLocationEnum.ATTHEWORKPLACE, - label: accidentLocation.agricultureAccident.atTheWorkplace, - }, - { - value: AgricultureAccidentLocationEnum.TOORFROMTHEWORKPLACE, - label: - accidentLocation.agricultureAccident.toOrFromTheWorkplace, - }, - { - value: AgricultureAccidentLocationEnum.OTHER, - label: accidentLocation.agricultureAccident.other, - }, - ], - }), - ], - }), - // Fisherman information only applicable to fisherman workplace accidents - buildMultiField({ - id: 'shipLocation.multifield', - title: accidentLocation.fishermanAccidentLocation.heading, - description: accidentLocation.fishermanAccidentLocation.description, - condition: (formValue) => isFishermanAccident(formValue), - children: [ - buildRadioField({ - id: 'shipLocation.answer', - title: '', - backgroundColor: 'blue', - options: [ - { - value: - FishermanWorkplaceAccidentShipLocationEnum.SAILINGORFISHING, - label: - accidentLocation.fishermanAccidentLocation.whileSailing, - }, - { - value: FishermanWorkplaceAccidentShipLocationEnum.HARBOR, - label: accidentLocation.fishermanAccidentLocation.inTheHarbor, - }, - { - value: FishermanWorkplaceAccidentShipLocationEnum.OTHER, - label: accidentLocation.fishermanAccidentLocation.other, - }, - ], - }), - ], - }), - buildMultiField({ - id: 'locationAndPurpose', - title: locationAndPurpose.general.title, - description: locationAndPurpose.general.description, - condition: (formValue) => - !isFishermanAccident(formValue) && - !hideLocationAndPurpose(formValue), - children: [ - buildTextField({ - id: 'locationAndPurpose.location', - title: locationAndPurpose.labels.location, - backgroundColor: 'blue', - variant: 'textarea', - required: true, - rows: 4, - maxLength: 2000, - }), - ], - }), - ], - }), - // Workmachine information only applicable to generic workplace accidents - buildSubSection({ - id: 'workMachine.section', - title: workMachine.general.sectionTitle, - condition: (formValue) => - isGeneralWorkplaceAccident(formValue) || - isAgricultureAccident(formValue) || - isSportAccidentAndEmployee(formValue), - children: [ - buildMultiField({ - id: 'workMachine', - title: workMachine.general.workMachineRadioTitle, - description: '', - children: [ - buildRadioField({ - id: 'workMachineRadio', - title: '', - backgroundColor: 'blue', - width: 'half', - required: true, - options: [ - { value: YES, label: application.general.yesOptionLabel }, - { value: NO, label: application.general.noOptionLabel }, - ], - }), - ], - }), - buildMultiField({ - id: 'workMachine.description', - title: workMachine.general.subSectionTitle, - condition: (formValue) => formValue.workMachineRadio === YES, - children: [ - buildTextField({ - id: 'workMachine.desriptionOfMachine', - title: workMachine.labels.desriptionOfMachine, - placeholder: workMachine.placeholder.desriptionOfMachine, - backgroundColor: 'blue', - rows: 4, - variant: 'textarea', - required: true, - maxLength: 2000, - }), - ], - }), - ], - }), - // Details of the accident - buildSubSection({ - id: 'accidentDetails.section', - title: accidentDetails.general.sectionTitle, - children: [ - buildMultiField({ - id: 'accidentDetails', - title: accidentDetails.general.sectionTitle, - description: accidentDetails.general.description, - children: [ - buildCustomField({ - id: 'accidentDetails.dateOfAccident', - title: accidentDetails.labels.date, - component: 'DateOfAccident', - width: 'half', - }), - buildTextField({ - id: 'accidentDetails.timeOfAccident', - title: accidentDetails.labels.time, - placeholder: accidentDetails.placeholder.time, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '##:##', - }), - buildAlertMessageField({ - id: 'accidentDetails.moreThanAYearAlertMessage', - title: accidentDetails.general.moreThanAYearAlertTitle, - message: accidentDetails.general.moreThanAYearAlertMessage, - width: 'full', - alertType: 'warning', - condition: (formValue) => isDateOlderThanAYear(formValue), - marginBottom: 0, - }), - buildAlertMessageField({ - id: 'accidentDetails.notHealthInsuredAlertMessage', - title: accidentDetails.general.insuranceAlertTitle, - message: accidentDetails.general.insuranceAlertText, - width: 'full', - alertType: 'warning', - condition: (formValue) => !isHealthInsured(formValue), - marginBottom: 0, - }), - buildTextField({ - id: 'accidentDetails.descriptionOfAccident', - title: accidentDetails.labels.description, - placeholder: accidentDetails.placeholder.description, - backgroundColor: 'blue', - required: true, - rows: 10, - variant: 'textarea', - maxLength: 2000, - }), - buildTextField({ - id: 'accidentDetails.accidentSymptoms', - title: accidentDetails.labels.symptoms, - placeholder: accidentDetails.placeholder.symptoms, - backgroundColor: 'blue', - required: true, - rows: 10, - variant: 'textarea', - maxLength: 2000, - }), - buildDescriptionField({ - id: 'accidentDetails.descriptionField', - space: 'containerGutter', - titleVariant: 'h5', - title: accidentDetails.labels.doctorVisit, - width: 'full', - }), - buildCustomField({ - id: 'accidentDetails.dateOfDoctorVisit', - title: accidentDetails.labels.date, - component: 'DateOfAccident', - width: 'half', - }), - buildTextField({ - id: 'accidentDetails.timeOfDoctorVisit', - title: accidentDetails.labels.time, - placeholder: accidentDetails.placeholder.doctorVisitTime, - backgroundColor: 'blue', - width: 'half', - format: '##:##', - }), - ], - }), - ], - }), - - // Injury Certificate and Fatal accident section - buildSubSection({ - id: 'attachments.section', - title: attachments.general.sectionTitle, - children: [ - buildMultiField({ - id: 'attachments', - title: attachments.general.heading, - children: [ - buildRadioField({ - id: 'injuryCertificate.answer', - title: '', - description: attachments.general.description, - required: true, - options: (application) => - isRepresentativeOfCompanyOrInstitute(application.answers) - ? [ - { - value: AttachmentsEnum.INJURYCERTIFICATE, - label: attachments.labels.injuryCertificate, - }, - { - value: AttachmentsEnum.SENDCERTIFICATELATER, - label: attachments.labels.sendCertificateLater, - }, - ] - : [ - { - value: AttachmentsEnum.INJURYCERTIFICATE, - label: attachments.labels.injuryCertificate, - }, - { - value: AttachmentsEnum.HOSPITALSENDSCERTIFICATE, - label: attachments.labels.hospitalSendsCertificate, - }, - { - value: AttachmentsEnum.SENDCERTIFICATELATER, - label: attachments.labels.sendCertificateLater, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert', - title: attachments.labels.alertMessage, - message: attachments.general.alertMessage, - doesNotRequireAnswer: true, - condition: (formValue) => - getValueViaPath(formValue, 'injuryCertificate.answer') === - AttachmentsEnum.SENDCERTIFICATELATER, - alertType: 'warning', - }), - ], - }), - buildMultiField({ - id: 'attachments.injuryCertificateFile.subSection', - title: attachments.general.heading, - children: [ - buildFileUploadField({ - id: 'attachments.injuryCertificateFile.file', - title: attachments.general.heading, - maxSize: FILE_SIZE_LIMIT, - maxSizeErrorText: error.attachmentMaxSizeError, - uploadAccept: UPLOAD_ACCEPT, - uploadHeader: injuredPersonInformation.upload.uploadHeader, - uploadDescription: attachments.general.uploadDescription, - uploadButtonLabel: attachments.general.uploadButtonLabel, - introduction: attachments.general.uploadIntroduction, - }), - ], - condition: (formValue) => - getValueViaPath(formValue, 'injuryCertificate.answer') === - AttachmentsEnum.INJURYCERTIFICATE, - }), - buildMultiField({ - id: 'fatalAccidentMulti.section', - title: fatalAccident.general.sectionTitle, - condition: (formValue) => isReportingOnBehalfOfInjured(formValue), - children: [ - buildRadioField({ - id: 'wasTheAccidentFatal', - title: '', - backgroundColor: 'blue', - width: 'half', - required: true, - options: [ - { value: YES, label: application.general.yesOptionLabel }, - { value: NO, label: application.general.noOptionLabel }, - ], - }), - ], - }), - buildMultiField({ - id: 'fatalAccidentUploadDeathCertificateNowMulti', - title: fatalAccidentAttachment.labels.title, - description: fatalAccidentAttachment.labels.description, - condition: (formValue) => - isReportingOnBehalfOfInjured(formValue) && - formValue.wasTheAccidentFatal === YES, - children: [ - buildRadioField({ - id: 'fatalAccidentUploadDeathCertificateNow', - title: '', - backgroundColor: 'blue', - required: true, - options: [ - { - value: YES, - label: fatalAccidentAttachment.options.addAttachmentsNow, - }, - { - value: NO, - label: fatalAccidentAttachment.options.addAttachmentsLater, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert', - title: fatalAccident.alertMessage.title, - message: fatalAccident.alertMessage.description, - doesNotRequireAnswer: true, - alertType: 'warning', - condition: (formValue) => - getValueViaPath( - formValue, - 'fatalAccidentUploadDeathCertificateNow', - ) === NO, - }), - ], - }), - - buildMultiField({ - id: 'attachments.deathCertificateFile.subSection', - title: attachments.general.uploadTitle, - condition: (formValue) => - isReportingOnBehalfOfInjured(formValue) && - isFatalAccident(formValue) && - formValue.fatalAccidentUploadDeathCertificateNow === YES, - children: [ - buildFileUploadField({ - id: 'attachments.deathCertificateFile.file', - title: attachments.general.uploadHeader, - maxSize: FILE_SIZE_LIMIT, - maxSizeErrorText: error.attachmentMaxSizeError, - uploadAccept: UPLOAD_ACCEPT, - uploadHeader: attachments.general.uploadHeader, - uploadDescription: attachments.general.uploadDescription, - uploadButtonLabel: attachments.general.uploadButtonLabel, - introduction: attachments.general.uploadIntroduction, - }), - ], - }), - buildMultiField({ - id: 'attachments.additionalFilesMulti', - title: attachments.general.heading, - children: [ - buildRadioField({ - id: 'additionalAttachments.answer', - title: '', - description: attachments.general.additionalAttachmentDescription, - required: true, - options: () => [ - { - value: AttachmentsEnum.ADDITIONALNOW, - label: attachments.labels.additionalNow, - }, - { - value: AttachmentsEnum.ADDITIONALLATER, - label: attachments.labels.additionalLater, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert', - title: attachments.labels.alertMessage, - message: attachments.general.alertMessage, - alertType: 'warning', - doesNotRequireAnswer: true, - condition: (formValue) => - getValueViaPath(formValue, 'additionalAttachments.answer') === - AttachmentsEnum.ADDITIONALLATER, - }), - ], - }), - buildMultiField({ - id: 'attachments.additionalAttachments.subSection', - title: attachments.general.heading, - condition: (formValue) => - getValueViaPath(formValue, 'additionalAttachments.answer') === - AttachmentsEnum.ADDITIONALNOW, - children: [ - buildFileUploadField({ - id: 'attachments.additionalFiles.file', - title: attachments.general.heading, - maxSize: FILE_SIZE_LIMIT, - maxSizeErrorText: error.attachmentMaxSizeError, - uploadAccept: UPLOAD_ACCEPT, - uploadHeader: addDocuments.general.uploadHeader, - uploadDescription: addDocuments.general.uploadDescription, - uploadButtonLabel: addDocuments.general.uploadButtonLabel, - introduction: addDocuments.general.additionalDocumentsDescription, - }), - ], - }), - ], - }), - - // Company information if work accident without the injured being a fisherman or in agriculture - buildSubSection({ - id: 'companyInfo.subSection', - title: companyInfo.general.title, - condition: (formValue) => - !isAgricultureAccident(formValue) && - !isReportingOnBehalfOfEmployee(formValue) && - !isHomeActivitiesAccident(formValue) && - (isGeneralWorkplaceAccident(formValue) || - isInternshipStudiesAccident(formValue)), - children: [ - buildMultiField({ - id: 'companyInfo', - title: companyInfo.general.title, - description: companyInfo.general.description, - children: [ - buildTextField({ - id: 'companyInfo.name', - title: companyInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - }), - buildTextField({ - id: 'companyInfo.nationalRegistrationId', - title: companyInfo.labels.nationalId, - backgroundColor: 'blue', - width: 'half', - format: '######-####', - required: true, - }), - // buildCheckboxField({ - // id: 'isRepresentativeOfCompanyOrInstitue', - // title: '', - // defaultValue: [], - // large: false, - // backgroundColor: 'white', - // options: [ - // { - // value: YES, - // label: companyInfo.labels.checkBox, - // }, - // ], - // }), - buildDescriptionField({ - id: 'companyInfo.descriptionField', - description: companyInfo.labels.subDescription, - space: 'containerGutter', - titleVariant: 'h5', - title: companyInfo.labels.descriptionField, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - - // These should all be required if the user is not the representative of the company. - // Should look into if we can require conditionally - buildTextField({ - id: 'representative.name', - title: representativeInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.nationalId', - title: representativeInfo.labels.nationalId, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '######-####', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.email', - title: representativeInfo.labels.email, - backgroundColor: 'blue', - variant: 'email', - width: 'half', - required: true, - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.phoneNumber', - title: representativeInfo.labels.tel, - backgroundColor: 'blue', - format: '###-####', - variant: 'tel', - width: 'half', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildCustomField( - { - id: 'representativeInfo.custom', - title: '', - doesNotRequireAnswer: true, - component: 'HiddenInformation', - }, - { - id: 'representativeInfo', - }, - ), - ], - }), - ], - }), - // School information if school accident - buildSubSection({ - id: 'schoolInfo.subSection', - title: schoolInfo.general.title, - condition: (formValue) => - isStudiesAccident(formValue) && - !isInternshipStudiesAccident(formValue) && - !isReportingOnBehalfOfEmployee(formValue), - children: [ - buildMultiField({ - id: 'schoolInfo', - title: schoolInfo.general.title, - description: schoolInfo.general.description, - children: [ - buildTextField({ - id: 'companyInfo.name', - title: schoolInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - }), - buildTextField({ - id: 'companyInfo.nationalRegistrationId', - title: schoolInfo.labels.nationalId, - backgroundColor: 'blue', - format: '######-####', - required: true, - width: 'half', - }), - // buildCheckboxField({ - // id: 'isRepresentativeOfCompanyOrInstitue', - // title: '', - // defaultValue: [], - // large: false, - // backgroundColor: 'white', - // options: [ - // { - // value: YES, - // label: schoolInfo.labels.checkBox, - // }, - // ], - // }), - buildDescriptionField({ - id: 'schoolInfo.descriptionField', - description: schoolInfo.labels.subDescription, - space: 'containerGutter', - titleVariant: 'h5', - title: schoolInfo.labels.descriptionField, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - // These should all be required if the user is not the representative of the company. - // Should look into if we can require conditionally - buildTextField({ - id: 'representative.name', - title: representativeInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.nationalId', - title: representativeInfo.labels.nationalId, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '######-####', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.email', - title: representativeInfo.labels.email, - backgroundColor: 'blue', - variant: 'email', - width: 'half', - maxLength: 100, - required: true, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.phoneNumber', - title: representativeInfo.labels.tel, - backgroundColor: 'blue', - format: '###-####', - variant: 'tel', - width: 'half', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildCustomField( - { - id: 'schoolInfo.custom', - title: '', - doesNotRequireAnswer: true, - component: 'HiddenInformation', - }, - { - id: 'representativeInfo', - }, - ), - ], - }), - ], - }), - // fishery information if fisherman - buildSubSection({ - id: 'fishingCompanyInfo.subSection', - title: (application) => - isReportingOnBehalfOfEmployee(application.answers) - ? fishingCompanyInfo.general.informationAboutShipTitle - : fishingCompanyInfo.general.title, - condition: (formValue) => isFishermanAccident(formValue), - children: [ - buildMultiField({ - id: 'fishingShipInfo', - title: fishingCompanyInfo.general.informationAboutShipTitle, - description: - fishingCompanyInfo.general.informationAboutShipDescription, - children: [ - buildTextField({ - id: 'fishingShipInfo.shipName', - title: fishingCompanyInfo.labels.shipName, - backgroundColor: 'blue', - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'fishingShipInfo.shipCharacters', - title: fishingCompanyInfo.labels.shipCharacters, - backgroundColor: 'blue', - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'fishingShipInfo.homePort', - title: fishingCompanyInfo.labels.homePort, - backgroundColor: 'blue', - width: 'half', - maxLength: 100, - }), - buildTextField({ - id: 'fishingShipInfo.shipRegisterNumber', - title: fishingCompanyInfo.labels.shipRegisterNumber, - backgroundColor: 'blue', - width: 'half', - maxLength: 100, - }), - ], - }), - buildMultiField({ - id: 'fishingCompanyInfo', - title: fishingCompanyInfo.general.title, - description: fishingCompanyInfo.general.description, - condition: (formValue) => !isReportingOnBehalfOfEmployee(formValue), - children: [ - buildTextField({ - id: 'companyInfo.name', - title: fishingCompanyInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - }), - buildTextField({ - id: 'companyInfo.nationalRegistrationId', - title: fishingCompanyInfo.labels.nationalId, - backgroundColor: 'blue', - format: '######-####', - required: true, - width: 'half', - }), - // buildCheckboxField({ - // id: 'isRepresentativeOfCompanyOrInstitue', - // title: '', - // defaultValue: [], - // large: false, - // backgroundColor: 'white', - // options: [ - // { - // value: YES, - // label: fishingCompanyInfo.labels.checkBox, - // }, - // ], - // }), - buildDescriptionField({ - id: 'fishingCompanyInfo.descriptionField', - description: fishingCompanyInfo.labels.subDescription, - space: 'containerGutter', - titleVariant: 'h5', - title: fishingCompanyInfo.labels.descriptionField, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - // These should all be required if the user is not the representative of the company. - // Should look into if we can require conditionally - buildTextField({ - id: 'representative.name', - title: representativeInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.nationalId', - title: representativeInfo.labels.nationalId, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '######-####', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.email', - title: representativeInfo.labels.email, - backgroundColor: 'blue', - variant: 'email', - width: 'half', - maxLength: 100, - required: true, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.phoneNumber', - title: representativeInfo.labels.tel, - backgroundColor: 'blue', - format: '###-####', - variant: 'tel', - width: 'half', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildCustomField( - { - id: 'representativeInfo.custom', - title: '', - doesNotRequireAnswer: true, - component: 'HiddenInformation', - }, - { - id: 'representativeInfo', - }, - ), - ], - }), - ], - }), - // Sports club information when the injured has a sports related accident - buildSubSection({ - id: 'sportsClubInfo.subSection', - title: sportsClubInfo.general.title, - condition: (formValue) => - isProfessionalAthleteAccident(formValue) && - !isReportingOnBehalfOfEmployee(formValue), - children: [ - buildMultiField({ - id: 'sportsClubInfo', - title: sportsClubInfo.general.title, - description: sportsClubInfo.general.description, - children: [ - buildTextField({ - id: 'companyInfo.name', - title: sportsClubInfo.labels.name, - backgroundColor: 'blue', - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'companyInfo.nationalRegistrationId', - title: sportsClubInfo.labels.nationalId, - backgroundColor: 'blue', - format: '######-####', - required: true, - width: 'half', - }), - // buildCheckboxField({ - // id: 'isRepresentativeOfCompanyOrInstitue', - // title: '', - // defaultValue: [], - // large: false, - // backgroundColor: 'white', - // options: [ - // { - // value: YES, - // label: sportsClubInfo.labels.checkBox, - // }, - // ], - // }), - buildDescriptionField({ - id: 'sportsClubInfo.descriptionField', - description: sportsClubInfo.labels.subDescription, - space: 'containerGutter', - titleVariant: 'h5', - title: sportsClubInfo.labels.descriptionField, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - // These should all be required if the user is not the representative of the company. - // Should look into if we can require conditionally - buildTextField({ - id: 'representative.name', - title: representativeInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.nationalId', - title: representativeInfo.labels.nationalId, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '######-####', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.email', - title: representativeInfo.labels.email, - backgroundColor: 'blue', - variant: 'email', - width: 'half', - maxLength: 100, - required: true, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.phoneNumber', - title: representativeInfo.labels.tel, - backgroundColor: 'blue', - format: '###-####', - variant: 'tel', - width: 'half', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildCustomField( - { - id: 'representativeInfo.custom', - title: '', - doesNotRequireAnswer: true, - component: 'HiddenInformation', - }, - { - id: 'representativeInfo', - }, - ), - ], - }), - ], - }), - // Rescue squad information when accident is related to rescue squad - buildSubSection({ - id: 'rescueSquadInfo.subSection', - title: rescueSquadInfo.general.title, - condition: (formValue) => - isRescueWorkAccident(formValue) && - !isReportingOnBehalfOfEmployee(formValue), - children: [ - buildMultiField({ - id: 'rescueSquad', - title: rescueSquadInfo.general.title, - description: rescueSquadInfo.general.description, - children: [ - buildTextField({ - id: 'companyInfo.name', - title: rescueSquadInfo.labels.name, - backgroundColor: 'blue', - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'companyInfo.nationalRegistrationId', - title: rescueSquadInfo.labels.nationalId, - backgroundColor: 'blue', - format: '######-####', - required: true, - width: 'half', - }), - // buildCheckboxField({ - // id: 'isRepresentativeOfCompanyOrInstitue', - // title: '', - // defaultValue: [], - // large: false, - // backgroundColor: 'white', - // options: [ - // { - // value: YES, - // label: rescueSquadInfo.labels.checkBox, - // }, - // ], - // }), - buildDescriptionField({ - id: 'rescueSquadInfo.descriptionField', - description: rescueSquadInfo.labels.subDescription, - space: 'containerGutter', - titleVariant: 'h5', - title: rescueSquadInfo.labels.descriptionField, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.name', - title: representativeInfo.labels.name, - backgroundColor: 'blue', - required: true, - width: 'half', - maxLength: 100, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.nationalId', - title: representativeInfo.labels.nationalId, - backgroundColor: 'blue', - required: true, - width: 'half', - format: '######-####', - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.email', - title: representativeInfo.labels.email, - backgroundColor: 'blue', - variant: 'email', - width: 'half', - maxLength: 100, - required: true, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildTextField({ - id: 'representative.phoneNumber', - title: representativeInfo.labels.tel, - backgroundColor: 'blue', - format: '###-####', - variant: 'tel', - width: 'half', - doesNotRequireAnswer: true, - condition: (formValue) => - !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), - }), - buildCustomField( - { - id: 'representativeInfo.custom', - title: '', - doesNotRequireAnswer: true, - component: 'HiddenInformation', - }, - { - id: 'representativeInfo', - }, - ), - ], - }), - ], - }), - ], -}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentDetailSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentDetailSubSection.ts new file mode 100644 index 000000000000..dfe52a39a6d8 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentDetailSubSection.ts @@ -0,0 +1,100 @@ +import { + buildAlertMessageField, + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { accidentDetails } from '../../../lib/messages' +import { isDateOlderThanAYear } from '../../../utils' +import { isHealthInsured } from '../../../utils/isHealthInsured' + +// Details of the accident +export const accidentDetailsSubSection = buildSubSection({ + id: 'accidentDetails.section', + title: accidentDetails.general.sectionTitle, + children: [ + buildMultiField({ + id: 'accidentDetails', + title: accidentDetails.general.sectionTitle, + description: accidentDetails.general.description, + children: [ + buildCustomField({ + id: 'accidentDetails.dateOfAccident', + title: accidentDetails.labels.date, + component: 'DateOfAccident', + width: 'half', + }), + buildTextField({ + id: 'accidentDetails.timeOfAccident', + title: accidentDetails.labels.time, + placeholder: accidentDetails.placeholder.time, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '##:##', + }), + buildAlertMessageField({ + id: 'accidentDetails.moreThanAYearAlertMessage', + title: accidentDetails.general.moreThanAYearAlertTitle, + message: accidentDetails.general.moreThanAYearAlertMessage, + width: 'full', + alertType: 'warning', + condition: (formValue) => isDateOlderThanAYear(formValue), + marginBottom: 0, + }), + buildAlertMessageField({ + id: 'accidentDetails.notHealthInsuredAlertMessage', + title: accidentDetails.general.insuranceAlertTitle, + message: accidentDetails.general.insuranceAlertText, + width: 'full', + alertType: 'warning', + condition: (formValue) => !isHealthInsured(formValue), + marginBottom: 0, + }), + buildTextField({ + id: 'accidentDetails.descriptionOfAccident', + title: accidentDetails.labels.description, + placeholder: accidentDetails.placeholder.description, + backgroundColor: 'blue', + required: true, + rows: 10, + variant: 'textarea', + maxLength: 2000, + }), + buildTextField({ + id: 'accidentDetails.accidentSymptoms', + title: accidentDetails.labels.symptoms, + placeholder: accidentDetails.placeholder.symptoms, + backgroundColor: 'blue', + required: true, + rows: 10, + variant: 'textarea', + maxLength: 2000, + }), + buildDescriptionField({ + id: 'accidentDetails.descriptionField', + space: 'containerGutter', + titleVariant: 'h5', + title: accidentDetails.labels.doctorVisit, + width: 'full', + }), + buildCustomField({ + id: 'accidentDetails.dateOfDoctorVisit', + title: accidentDetails.labels.date, + component: 'DateOfAccident', + width: 'half', + }), + buildTextField({ + id: 'accidentDetails.timeOfDoctorVisit', + title: accidentDetails.labels.time, + placeholder: accidentDetails.placeholder.doctorVisitTime, + backgroundColor: 'blue', + width: 'half', + format: '##:##', + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentTypeSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentTypeSubSection.ts new file mode 100644 index 000000000000..387eb21ad6c9 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/accidentTypeSubSection.ts @@ -0,0 +1,17 @@ +import { buildRadioField, buildSubSection } from '@island.is/application/core' +import { accidentType } from '../../../lib/messages' +import { getAccidentTypeOptions } from '../../../utils' + +export const accidentTypeSubSection = buildSubSection({ + id: 'accidentType.section', + title: accidentType.general.subsectionTitle, + children: [ + buildRadioField({ + id: 'accidentType.radioButton', + width: 'half', + title: accidentType.general.heading, + description: accidentType.general.description, + options: (formValue) => getAccidentTypeOptions(formValue.answers), + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/attachmentsSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/attachmentsSubSection.ts new file mode 100644 index 000000000000..8d666ce9d97c --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/attachmentsSubSection.ts @@ -0,0 +1,230 @@ +import { + buildAlertMessageField, + buildFileUploadField, + buildMultiField, + buildRadioField, + buildSubSection, + getValueViaPath, +} from '@island.is/application/core' +import { + addDocuments, + application, + attachments, + error, + fatalAccident, + fatalAccidentAttachment, + injuredPersonInformation, +} from '../../../lib/messages' +import { + isFatalAccident, + isReportingOnBehalfOfInjured, + isRepresentativeOfCompanyOrInstitute, +} from '../../../utils' +import { AttachmentsEnum } from '../../../types' +import { FILE_SIZE_LIMIT, NO, UPLOAD_ACCEPT, YES } from '../../../constants' + +// Injury certificate and fatal accident section +export const attachmentsSubSection = buildSubSection({ + id: 'attachments.section', + title: attachments.general.sectionTitle, + children: [ + buildMultiField({ + id: 'attachments', + title: attachments.general.heading, + children: [ + buildRadioField({ + id: 'injuryCertificate.answer', + title: '', + description: attachments.general.description, + required: true, + options: (application) => + isRepresentativeOfCompanyOrInstitute(application.answers) + ? [ + { + value: AttachmentsEnum.INJURYCERTIFICATE, + label: attachments.labels.injuryCertificate, + }, + { + value: AttachmentsEnum.SENDCERTIFICATELATER, + label: attachments.labels.sendCertificateLater, + }, + ] + : [ + { + value: AttachmentsEnum.INJURYCERTIFICATE, + label: attachments.labels.injuryCertificate, + }, + { + value: AttachmentsEnum.HOSPITALSENDSCERTIFICATE, + label: attachments.labels.hospitalSendsCertificate, + }, + { + value: AttachmentsEnum.SENDCERTIFICATELATER, + label: attachments.labels.sendCertificateLater, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: attachments.labels.alertMessage, + message: attachments.general.alertMessage, + doesNotRequireAnswer: true, + condition: (formValue) => + getValueViaPath(formValue, 'injuryCertificate.answer') === + AttachmentsEnum.SENDCERTIFICATELATER, + alertType: 'warning', + }), + ], + }), + buildMultiField({ + id: 'attachments.injuryCertificateFile.subSection', + title: attachments.general.heading, + children: [ + buildFileUploadField({ + id: 'attachments.injuryCertificateFile.file', + title: attachments.general.heading, + maxSize: FILE_SIZE_LIMIT, + maxSizeErrorText: error.attachmentMaxSizeError, + uploadAccept: UPLOAD_ACCEPT, + uploadHeader: injuredPersonInformation.upload.uploadHeader, + uploadDescription: attachments.general.uploadDescription, + uploadButtonLabel: attachments.general.uploadButtonLabel, + introduction: attachments.general.uploadIntroduction, + }), + ], + condition: (formValue) => + getValueViaPath(formValue, 'injuryCertificate.answer') === + AttachmentsEnum.INJURYCERTIFICATE, + }), + buildMultiField({ + id: 'fatalAccidentMulti.section', + title: fatalAccident.general.sectionTitle, + condition: (formValue) => isReportingOnBehalfOfInjured(formValue), + children: [ + buildRadioField({ + id: 'wasTheAccidentFatal', + title: '', + backgroundColor: 'blue', + width: 'half', + required: true, + options: [ + { value: YES, label: application.general.yesOptionLabel }, + { value: NO, label: application.general.noOptionLabel }, + ], + }), + ], + }), + buildMultiField({ + id: 'fatalAccidentUploadDeathCertificateNowMulti', + title: fatalAccidentAttachment.labels.title, + description: fatalAccidentAttachment.labels.description, + condition: (formValue) => + isReportingOnBehalfOfInjured(formValue) && + formValue.wasTheAccidentFatal === YES, + children: [ + buildRadioField({ + id: 'fatalAccidentUploadDeathCertificateNow', + title: '', + backgroundColor: 'blue', + required: true, + options: [ + { + value: YES, + label: fatalAccidentAttachment.options.addAttachmentsNow, + }, + { + value: NO, + label: fatalAccidentAttachment.options.addAttachmentsLater, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: fatalAccident.alertMessage.title, + message: fatalAccident.alertMessage.description, + doesNotRequireAnswer: true, + alertType: 'warning', + condition: (formValue) => + getValueViaPath( + formValue, + 'fatalAccidentUploadDeathCertificateNow', + ) === NO, + }), + ], + }), + + buildMultiField({ + id: 'attachments.deathCertificateFile.subSection', + title: attachments.general.uploadTitle, + condition: (formValue) => + isReportingOnBehalfOfInjured(formValue) && + isFatalAccident(formValue) && + formValue.fatalAccidentUploadDeathCertificateNow === YES, + children: [ + buildFileUploadField({ + id: 'attachments.deathCertificateFile.file', + title: attachments.general.uploadHeader, + maxSize: FILE_SIZE_LIMIT, + maxSizeErrorText: error.attachmentMaxSizeError, + uploadAccept: UPLOAD_ACCEPT, + uploadHeader: attachments.general.uploadHeader, + uploadDescription: attachments.general.uploadDescription, + uploadButtonLabel: attachments.general.uploadButtonLabel, + introduction: attachments.general.uploadIntroduction, + }), + ], + }), + buildMultiField({ + id: 'attachments.additionalFilesMulti', + title: attachments.general.heading, + children: [ + buildRadioField({ + id: 'additionalAttachments.answer', + title: '', + description: attachments.general.additionalAttachmentDescription, + required: true, + options: () => [ + { + value: AttachmentsEnum.ADDITIONALNOW, + label: attachments.labels.additionalNow, + }, + { + value: AttachmentsEnum.ADDITIONALLATER, + label: attachments.labels.additionalLater, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: attachments.labels.alertMessage, + message: attachments.general.alertMessage, + alertType: 'warning', + doesNotRequireAnswer: true, + condition: (formValue) => + getValueViaPath(formValue, 'additionalAttachments.answer') === + AttachmentsEnum.ADDITIONALLATER, + }), + ], + }), + buildMultiField({ + id: 'attachments.additionalAttachments.subSection', + title: attachments.general.heading, + condition: (formValue) => + getValueViaPath(formValue, 'additionalAttachments.answer') === + AttachmentsEnum.ADDITIONALNOW, + children: [ + buildFileUploadField({ + id: 'attachments.additionalFiles.file', + title: attachments.general.heading, + maxSize: FILE_SIZE_LIMIT, + maxSizeErrorText: error.attachmentMaxSizeError, + uploadAccept: UPLOAD_ACCEPT, + uploadHeader: addDocuments.general.uploadHeader, + uploadDescription: addDocuments.general.uploadDescription, + uploadButtonLabel: addDocuments.general.uploadButtonLabel, + introduction: addDocuments.general.additionalDocumentsDescription, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/companyInfoSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/companyInfoSubSection.ts new file mode 100644 index 000000000000..05cc9f837316 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/companyInfoSubSection.ts @@ -0,0 +1,117 @@ +import { + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { companyInfo, representativeInfo } from '../../../lib/messages' +import { + isAgricultureAccident, + isGeneralWorkplaceAccident, + isHomeActivitiesAccident, + isInjuredAndRepresentativeOfCompanyOrInstitute, + isInternshipStudiesAccident, + isReportingOnBehalfOfEmployee, +} from '../../../utils' + +// Company information if work accident without the injured being a fisherman or in agriculture +export const companyInfoSubSection = buildSubSection({ + id: 'companyInfo.subSection', + title: companyInfo.general.title, + condition: (formValue) => + !isAgricultureAccident(formValue) && + !isReportingOnBehalfOfEmployee(formValue) && + !isHomeActivitiesAccident(formValue) && + (isGeneralWorkplaceAccident(formValue) || + isInternshipStudiesAccident(formValue)), + children: [ + buildMultiField({ + id: 'companyInfo', + title: companyInfo.general.title, + description: companyInfo.general.description, + children: [ + buildTextField({ + id: 'companyInfo.name', + title: companyInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + }), + buildTextField({ + id: 'companyInfo.nationalRegistrationId', + title: companyInfo.labels.nationalId, + backgroundColor: 'blue', + width: 'half', + format: '######-####', + required: true, + }), + buildDescriptionField({ + id: 'companyInfo.descriptionField', + description: companyInfo.labels.subDescription, + space: 'containerGutter', + titleVariant: 'h5', + title: companyInfo.labels.descriptionField, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + + // These should all be required if the user is not the representative of the company. + // Should look into if we can require conditionally + buildTextField({ + id: 'representative.name', + title: representativeInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.nationalId', + title: representativeInfo.labels.nationalId, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '######-####', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.email', + title: representativeInfo.labels.email, + backgroundColor: 'blue', + variant: 'email', + width: 'half', + required: true, + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.phoneNumber', + title: representativeInfo.labels.tel, + backgroundColor: 'blue', + format: '###-####', + variant: 'tel', + width: 'half', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildCustomField( + { + id: 'representativeInfo.custom', + title: '', + doesNotRequireAnswer: true, + component: 'HiddenInformation', + }, + { + id: 'representativeInfo', + }, + ), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/fishingCompanyInfoSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/fishingCompanyInfoSubSection.ts new file mode 100644 index 000000000000..03efd89ffdaf --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/fishingCompanyInfoSubSection.ts @@ -0,0 +1,149 @@ +import { + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { + isFishermanAccident, + isInjuredAndRepresentativeOfCompanyOrInstitute, + isReportingOnBehalfOfEmployee, +} from '../../../utils' +import { fishingCompanyInfo, representativeInfo } from '../../../lib/messages' + +// fishery information if fisherman +export const fishingCompanyInfoSubSection = buildSubSection({ + id: 'fishingCompanyInfo.subSection', + title: (application) => + isReportingOnBehalfOfEmployee(application.answers) + ? fishingCompanyInfo.general.informationAboutShipTitle + : fishingCompanyInfo.general.title, + condition: (formValue) => isFishermanAccident(formValue), + children: [ + buildMultiField({ + id: 'fishingShipInfo', + title: fishingCompanyInfo.general.informationAboutShipTitle, + description: fishingCompanyInfo.general.informationAboutShipDescription, + children: [ + buildTextField({ + id: 'fishingShipInfo.shipName', + title: fishingCompanyInfo.labels.shipName, + backgroundColor: 'blue', + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'fishingShipInfo.shipCharacters', + title: fishingCompanyInfo.labels.shipCharacters, + backgroundColor: 'blue', + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'fishingShipInfo.homePort', + title: fishingCompanyInfo.labels.homePort, + backgroundColor: 'blue', + width: 'half', + maxLength: 100, + }), + buildTextField({ + id: 'fishingShipInfo.shipRegisterNumber', + title: fishingCompanyInfo.labels.shipRegisterNumber, + backgroundColor: 'blue', + width: 'half', + maxLength: 100, + }), + ], + }), + buildMultiField({ + id: 'fishingCompanyInfo', + title: fishingCompanyInfo.general.title, + description: fishingCompanyInfo.general.description, + condition: (formValue) => !isReportingOnBehalfOfEmployee(formValue), + children: [ + buildTextField({ + id: 'companyInfo.name', + title: fishingCompanyInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + }), + buildTextField({ + id: 'companyInfo.nationalRegistrationId', + title: fishingCompanyInfo.labels.nationalId, + backgroundColor: 'blue', + format: '######-####', + required: true, + width: 'half', + }), + buildDescriptionField({ + id: 'fishingCompanyInfo.descriptionField', + description: fishingCompanyInfo.labels.subDescription, + space: 'containerGutter', + titleVariant: 'h5', + title: fishingCompanyInfo.labels.descriptionField, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + // These should all be required if the user is not the representative of the company. + // Should look into if we can require conditionally + buildTextField({ + id: 'representative.name', + title: representativeInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.nationalId', + title: representativeInfo.labels.nationalId, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '######-####', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.email', + title: representativeInfo.labels.email, + backgroundColor: 'blue', + variant: 'email', + width: 'half', + maxLength: 100, + required: true, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.phoneNumber', + title: representativeInfo.labels.tel, + backgroundColor: 'blue', + format: '###-####', + variant: 'tel', + width: 'half', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildCustomField( + { + id: 'representativeInfo.custom', + title: '', + doesNotRequireAnswer: true, + component: 'HiddenInformation', + }, + { + id: 'representativeInfo', + }, + ), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/index.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/index.ts new file mode 100644 index 000000000000..8c15c70a4bd3 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/index.ts @@ -0,0 +1,33 @@ +import { buildSection } from '@island.is/application/core' +import { accidentType } from '../../../lib/messages' +import { accidentTypeSubSection } from './accidentTypeSubSection' +import { workAccidentSubSection } from './workAccidentSubSection' +import { studiesAccidentSubSection } from './studiesAccidentSubSection' +import { locationSubSection } from './locationSubSection' +import { workMachineSubSection } from './workMachineSubSection' +import { accidentDetailsSubSection } from './accidentDetailSubSection' +import { attachmentsSubSection } from './attachmentsSubSection' +import { schoolInfoSubSection } from './schoolInfoSubSection' +import { fishingCompanyInfoSubSection } from './fishingCompanyInfoSubSection' +import { sportsClubInfoSubSection } from './sportsClubInfoSubSection' +import { rescueSquadInfoSubSection } from './rescueSquadInfoSubSection' +import { companyInfoSubSection } from './companyInfoSubSection' + +export const aboutTheAccidentSection = buildSection({ + id: 'accidentType.section', + title: accidentType.general.sectionTitle, + children: [ + accidentTypeSubSection, + workAccidentSubSection, + studiesAccidentSubSection, + locationSubSection, + workMachineSubSection, + accidentDetailsSubSection, + attachmentsSubSection, + companyInfoSubSection, + schoolInfoSubSection, + fishingCompanyInfoSubSection, + sportsClubInfoSubSection, + rescueSquadInfoSubSection, + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts new file mode 100644 index 000000000000..86c5459e1169 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts @@ -0,0 +1,336 @@ +import { + buildAlertMessageField, + buildMultiField, + buildRadioField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { + accidentLocation, + application, + locationAndPurpose, + sportsClubInfo, +} from '../../../lib/messages' +import { + hideLocationAndPurpose, + isAgricultureAccident, + isFishermanAccident, + isGeneralWorkplaceAccident, + isHomeActivitiesAccident, + isInternshipStudiesAccident, + isProfessionalAthleteAccident, + isRescueWorkAccident, + isStudiesAccident, +} from '../../../utils' +import { NO, YES } from '../../../constants' +import { isSportAccidentAndEmployee } from '../../../utils/isSportAccidentAndEmployee' +import { + AgricultureAccidentLocationEnum, + FishermanWorkplaceAccidentLocationEnum, + FishermanWorkplaceAccidentShipLocationEnum, + GeneralWorkplaceAccidentLocationEnum, + ProfessionalAthleteAccidentLocationEnum, + RescueWorkAccidentLocationEnum, + StudiesAccidentLocationEnum, +} from '../../../types' + +// Location Subsection +export const locationSubSection = buildSubSection({ + id: 'location.subSection', + title: 'Staðsetning', + children: [ + buildMultiField({ + id: 'sportsClubInfo.employee.field', + title: sportsClubInfo.employee.title, + condition: (formValue) => isProfessionalAthleteAccident(formValue), + children: [ + buildRadioField({ + id: 'onPayRoll.answer', + width: 'half', + title: '', + options: [ + { + value: YES, + label: application.general.yesOptionLabel, + }, + { + value: NO, + label: application.general.noOptionLabel, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: application.labels.warningTitle, + message: application.labels.warningMessage, + alertType: 'info', + doesNotRequireAnswer: true, + condition: (formValue) => isSportAccidentAndEmployee(formValue), + }), + ], + }), + + // Accident location section + // location of home related accident + buildMultiField({ + id: 'accidentLocation.homeAccident', + title: accidentLocation.homeAccidentLocation.title, + description: accidentLocation.homeAccidentLocation.description, + condition: (formValue) => isHomeActivitiesAccident(formValue), + children: [ + buildTextField({ + id: 'homeAccident.address', + title: accidentLocation.homeAccidentLocation.address, + backgroundColor: 'blue', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'homeAccident.postalCode', + title: accidentLocation.homeAccidentLocation.postalCode, + backgroundColor: 'blue', + width: 'half', + format: '###', + required: true, + }), + buildTextField({ + id: 'homeAccident.community', + title: accidentLocation.homeAccidentLocation.community, + backgroundColor: 'blue', + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'homeAccident.moreDetails', + title: accidentLocation.homeAccidentLocation.moreDetails, + placeholder: + accidentLocation.homeAccidentLocation.moreDetailsPlaceholder, + backgroundColor: 'blue', + rows: 4, + variant: 'textarea', + maxLength: 2000, + }), + ], + }), + // location of general work related accident + buildMultiField({ + id: 'accidentLocation.generalWorkAccident', + title: accidentLocation.general.heading, + description: accidentLocation.general.description, + condition: (formValue) => + isGeneralWorkplaceAccident(formValue) || + isSportAccidentAndEmployee(formValue), + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: GeneralWorkplaceAccidentLocationEnum.ATTHEWORKPLACE, + label: accidentLocation.generalWorkAccident.atTheWorkplace, + }, + { + value: GeneralWorkplaceAccidentLocationEnum.TOORFROMTHEWORKPLACE, + label: accidentLocation.generalWorkAccident.toOrFromTheWorkplace, + }, + { + value: GeneralWorkplaceAccidentLocationEnum.OTHER, + label: accidentLocation.generalWorkAccident.other, + }, + ], + }), + ], + }), + // location of rescue work related accident + buildMultiField({ + id: 'accidentLocation.rescueWorkAccident', + title: accidentLocation.general.heading, + description: accidentLocation.rescueWorkAccident.description, + condition: (formValue) => { + return isRescueWorkAccident(formValue) + }, + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: RescueWorkAccidentLocationEnum.DURINGRESCUE, + label: accidentLocation.rescueWorkAccident.duringRescue, + }, + { + value: RescueWorkAccidentLocationEnum.TOORFROMRESCUE, + label: accidentLocation.rescueWorkAccident.toOrFromRescue, + }, + { + value: RescueWorkAccidentLocationEnum.OTHER, + label: accidentLocation.rescueWorkAccident.other, + }, + ], + }), + ], + }), + // location of studies related accident + buildMultiField({ + id: 'accidentLocation.studiesAccident', + title: accidentLocation.studiesAccidentLocation.heading, + description: accidentLocation.studiesAccidentLocation.description, + condition: (formValue) => + isStudiesAccident(formValue) && !isInternshipStudiesAccident(formValue), + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: StudiesAccidentLocationEnum.ATTHESCHOOL, + label: accidentLocation.studiesAccidentLocation.atTheSchool, + }, + { + value: StudiesAccidentLocationEnum.OTHER, + label: accidentLocation.studiesAccidentLocation.other, + }, + ], + }), + ], + }), + // location of fisherman related accident + buildMultiField({ + id: 'accidentLocation.fishermanAccident', + title: accidentLocation.general.heading, + description: accidentLocation.general.description, + condition: (formValue) => isFishermanAccident(formValue), + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: FishermanWorkplaceAccidentLocationEnum.ONTHESHIP, + label: accidentLocation.fishermanAccident.onTheShip, + }, + { + value: + FishermanWorkplaceAccidentLocationEnum.TOORFROMTHEWORKPLACE, + label: accidentLocation.fishermanAccident.toOrFromTheWorkplace, + }, + { + value: FishermanWorkplaceAccidentLocationEnum.OTHER, + label: accidentLocation.fishermanAccident.other, + }, + ], + }), + ], + }), + // location of sports related accident + buildMultiField({ + id: 'accidentLocation.professionalAthleteAccident', + title: accidentLocation.general.heading, + description: accidentLocation.general.description, + condition: (formValue) => + isProfessionalAthleteAccident(formValue) && + !isSportAccidentAndEmployee(formValue), + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: + ProfessionalAthleteAccidentLocationEnum.SPORTCLUBSFACILITES, + label: + accidentLocation.professionalAthleteAccident + .atTheClubsSportsFacilites, + }, + { + value: + ProfessionalAthleteAccidentLocationEnum.TOORFROMTHESPORTCLUBSFACILITES, + label: + accidentLocation.professionalAthleteAccident + .toOrFromTheSportsFacilites, + }, + { + value: ProfessionalAthleteAccidentLocationEnum.OTHER, + label: accidentLocation.professionalAthleteAccident.other, + }, + ], + }), + ], + }), + // location of agriculture related accident + buildMultiField({ + id: 'accidentLocation.agricultureAccident', + title: accidentLocation.general.heading, + description: accidentLocation.general.description, + condition: (formValue) => isAgricultureAccident(formValue), + children: [ + buildRadioField({ + id: 'accidentLocation.answer', + title: '', + options: [ + { + value: AgricultureAccidentLocationEnum.ATTHEWORKPLACE, + label: accidentLocation.agricultureAccident.atTheWorkplace, + }, + { + value: AgricultureAccidentLocationEnum.TOORFROMTHEWORKPLACE, + label: accidentLocation.agricultureAccident.toOrFromTheWorkplace, + }, + { + value: AgricultureAccidentLocationEnum.OTHER, + label: accidentLocation.agricultureAccident.other, + }, + ], + }), + ], + }), + // Fisherman information only applicable to fisherman workplace accidents + buildMultiField({ + id: 'shipLocation.multifield', + title: accidentLocation.fishermanAccidentLocation.heading, + description: accidentLocation.fishermanAccidentLocation.description, + condition: (formValue) => isFishermanAccident(formValue), + children: [ + buildRadioField({ + id: 'shipLocation.answer', + title: '', + backgroundColor: 'blue', + options: [ + { + value: + FishermanWorkplaceAccidentShipLocationEnum.SAILINGORFISHING, + label: accidentLocation.fishermanAccidentLocation.whileSailing, + }, + { + value: FishermanWorkplaceAccidentShipLocationEnum.HARBOR, + label: accidentLocation.fishermanAccidentLocation.inTheHarbor, + }, + { + value: FishermanWorkplaceAccidentShipLocationEnum.OTHER, + label: accidentLocation.fishermanAccidentLocation.other, + }, + ], + }), + ], + }), + buildMultiField({ + id: 'locationAndPurpose', + title: locationAndPurpose.general.title, + description: locationAndPurpose.general.description, + condition: (formValue) => + !isFishermanAccident(formValue) && !hideLocationAndPurpose(formValue), + children: [ + buildTextField({ + id: 'locationAndPurpose.location', + title: locationAndPurpose.labels.location, + backgroundColor: 'blue', + variant: 'textarea', + required: true, + rows: 4, + maxLength: 2000, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/rescueSquadInfoSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/rescueSquadInfoSubSection.ts new file mode 100644 index 000000000000..640aa635f36b --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/rescueSquadInfoSubSection.ts @@ -0,0 +1,109 @@ +import { + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { representativeInfo, rescueSquadInfo } from '../../../lib/messages' +import { + isInjuredAndRepresentativeOfCompanyOrInstitute, + isReportingOnBehalfOfEmployee, + isRescueWorkAccident, +} from '../../../utils' + +// Rescue squad information when accident is related to rescue squad +export const rescueSquadInfoSubSection = buildSubSection({ + id: 'rescueSquadInfo.subSection', + title: rescueSquadInfo.general.title, + condition: (formValue) => + isRescueWorkAccident(formValue) && + !isReportingOnBehalfOfEmployee(formValue), + children: [ + buildMultiField({ + id: 'rescueSquad', + title: rescueSquadInfo.general.title, + description: rescueSquadInfo.general.description, + children: [ + buildTextField({ + id: 'companyInfo.name', + title: rescueSquadInfo.labels.name, + backgroundColor: 'blue', + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'companyInfo.nationalRegistrationId', + title: rescueSquadInfo.labels.nationalId, + backgroundColor: 'blue', + format: '######-####', + required: true, + width: 'half', + }), + buildDescriptionField({ + id: 'rescueSquadInfo.descriptionField', + description: rescueSquadInfo.labels.subDescription, + space: 'containerGutter', + titleVariant: 'h5', + title: rescueSquadInfo.labels.descriptionField, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.name', + title: representativeInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.nationalId', + title: representativeInfo.labels.nationalId, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '######-####', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.email', + title: representativeInfo.labels.email, + backgroundColor: 'blue', + variant: 'email', + width: 'half', + maxLength: 100, + required: true, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.phoneNumber', + title: representativeInfo.labels.tel, + backgroundColor: 'blue', + format: '###-####', + variant: 'tel', + width: 'half', + doesNotRequireAnswer: true, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildCustomField( + { + id: 'representativeInfo.custom', + title: '', + doesNotRequireAnswer: true, + component: 'HiddenInformation', + }, + { + id: 'representativeInfo', + }, + ), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/schoolInfoSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/schoolInfoSubSection.ts new file mode 100644 index 000000000000..148f9ec35872 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/schoolInfoSubSection.ts @@ -0,0 +1,112 @@ +import { + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { representativeInfo, schoolInfo } from '../../../lib/messages' +import { + isInjuredAndRepresentativeOfCompanyOrInstitute, + isInternshipStudiesAccident, + isReportingOnBehalfOfEmployee, + isStudiesAccident, +} from '../../../utils' + +// School information if school accident +export const schoolInfoSubSection = buildSubSection({ + id: 'schoolInfo.subSection', + title: schoolInfo.general.title, + condition: (formValue) => + isStudiesAccident(formValue) && + !isInternshipStudiesAccident(formValue) && + !isReportingOnBehalfOfEmployee(formValue), + children: [ + buildMultiField({ + id: 'schoolInfo', + title: schoolInfo.general.title, + description: schoolInfo.general.description, + children: [ + buildTextField({ + id: 'companyInfo.name', + title: schoolInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + }), + buildTextField({ + id: 'companyInfo.nationalRegistrationId', + title: schoolInfo.labels.nationalId, + backgroundColor: 'blue', + format: '######-####', + required: true, + width: 'half', + }), + buildDescriptionField({ + id: 'schoolInfo.descriptionField', + description: schoolInfo.labels.subDescription, + space: 'containerGutter', + titleVariant: 'h5', + title: schoolInfo.labels.descriptionField, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + // These should all be required if the user is not the representative of the company. + // Should look into if we can require conditionally + buildTextField({ + id: 'representative.name', + title: representativeInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.nationalId', + title: representativeInfo.labels.nationalId, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '######-####', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.email', + title: representativeInfo.labels.email, + backgroundColor: 'blue', + variant: 'email', + width: 'half', + maxLength: 100, + required: true, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.phoneNumber', + title: representativeInfo.labels.tel, + backgroundColor: 'blue', + format: '###-####', + variant: 'tel', + width: 'half', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildCustomField( + { + id: 'schoolInfo.custom', + title: '', + doesNotRequireAnswer: true, + component: 'HiddenInformation', + }, + { + id: 'representativeInfo', + }, + ), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/sportsClubInfoSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/sportsClubInfoSubSection.ts new file mode 100644 index 000000000000..7914ecbe0158 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/sportsClubInfoSubSection.ts @@ -0,0 +1,110 @@ +import { + buildCustomField, + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { + isInjuredAndRepresentativeOfCompanyOrInstitute, + isProfessionalAthleteAccident, + isReportingOnBehalfOfEmployee, +} from '../../../utils' +import { representativeInfo, sportsClubInfo } from '../../../lib/messages' + +// Sports club information when the injured has a sports related accident +export const sportsClubInfoSubSection = buildSubSection({ + id: 'sportsClubInfo.subSection', + title: sportsClubInfo.general.title, + condition: (formValue) => + isProfessionalAthleteAccident(formValue) && + !isReportingOnBehalfOfEmployee(formValue), + children: [ + buildMultiField({ + id: 'sportsClubInfo', + title: sportsClubInfo.general.title, + description: sportsClubInfo.general.description, + children: [ + buildTextField({ + id: 'companyInfo.name', + title: sportsClubInfo.labels.name, + backgroundColor: 'blue', + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'companyInfo.nationalRegistrationId', + title: sportsClubInfo.labels.nationalId, + backgroundColor: 'blue', + format: '######-####', + required: true, + width: 'half', + }), + buildDescriptionField({ + id: 'sportsClubInfo.descriptionField', + description: sportsClubInfo.labels.subDescription, + space: 'containerGutter', + titleVariant: 'h5', + title: sportsClubInfo.labels.descriptionField, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + // These should all be required if the user is not the representative of the company. + // Should look into if we can require conditionally + buildTextField({ + id: 'representative.name', + title: representativeInfo.labels.name, + backgroundColor: 'blue', + required: true, + width: 'half', + maxLength: 100, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.nationalId', + title: representativeInfo.labels.nationalId, + backgroundColor: 'blue', + required: true, + width: 'half', + format: '######-####', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.email', + title: representativeInfo.labels.email, + backgroundColor: 'blue', + variant: 'email', + width: 'half', + maxLength: 100, + required: true, + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildTextField({ + id: 'representative.phoneNumber', + title: representativeInfo.labels.tel, + backgroundColor: 'blue', + format: '###-####', + variant: 'tel', + width: 'half', + condition: (formValue) => + !isInjuredAndRepresentativeOfCompanyOrInstitute(formValue), + }), + buildCustomField( + { + id: 'representativeInfo.custom', + title: '', + doesNotRequireAnswer: true, + component: 'HiddenInformation', + }, + { + id: 'representativeInfo', + }, + ), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/studiesAccidentSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/studiesAccidentSubSection.ts new file mode 100644 index 000000000000..87bead5e5d5c --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/studiesAccidentSubSection.ts @@ -0,0 +1,41 @@ +import { + buildMultiField, + buildRadioField, + buildSubSection, +} from '@island.is/application/core' +import { accidentType } from '../../../lib/messages' +import { isStudiesAccident } from '../../../utils' +import { StudiesAccidentTypeEnum } from '../../../types' + +export const studiesAccidentSubSection = buildSubSection({ + id: 'studiesAccident.subSection', + title: accidentType.workAccidentType.subSectionTitle, + condition: (formValue) => isStudiesAccident(formValue), + children: [ + buildMultiField({ + id: 'studiesAccident.section', + title: accidentType.studiesAccidentType.heading, + description: accidentType.studiesAccidentType.description, + children: [ + buildRadioField({ + id: 'studiesAccident.type', + title: '', + options: [ + { + value: StudiesAccidentTypeEnum.INTERNSHIP, + label: accidentType.studiesAccidentType.internship, + }, + { + value: StudiesAccidentTypeEnum.APPRENTICESHIP, + label: accidentType.studiesAccidentType.apprenticeship, + }, + { + value: StudiesAccidentTypeEnum.VOCATIONALEDUCATION, + label: accidentType.studiesAccidentType.vocationalEducation, + }, + ], + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workAccidentSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workAccidentSubSection.ts new file mode 100644 index 000000000000..bf47941d017b --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workAccidentSubSection.ts @@ -0,0 +1,84 @@ +import { + buildAlertMessageField, + buildDescriptionField, + buildMultiField, + buildRadioField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { + accidentType, + attachments, + injuredPersonInformation, +} from '../../../lib/messages' +import { + isAgricultureAccident, + isReportingOnBehalfSelf, + isWorkAccident, +} from '../../../utils' +import { WorkAccidentTypeEnum } from '../../../types' + +export const workAccidentSubSection = buildSubSection({ + id: 'workAccident.subSection', + title: accidentType.workAccidentType.subSectionTitle, + condition: (formValue) => isWorkAccident(formValue), + children: [ + buildMultiField({ + id: 'workAccident.section', + title: accidentType.workAccidentType.heading, + description: accidentType.workAccidentType.description, + children: [ + buildRadioField({ + id: 'workAccident.type', + width: 'half', + title: '', + options: [ + { + value: WorkAccidentTypeEnum.GENERAL, + label: accidentType.workAccidentType.generalWorkAccident, + }, + { + value: WorkAccidentTypeEnum.FISHERMAN, + label: accidentType.workAccidentType.fishermanAccident, + }, + { + value: WorkAccidentTypeEnum.PROFESSIONALATHLETE, + label: accidentType.workAccidentType.professionalAthlete, + }, + { + value: WorkAccidentTypeEnum.AGRICULTURE, + label: accidentType.workAccidentType.agricultureAccident, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert2', + title: attachments.labels.alertMessage, + description: accidentType.warning.agricultureAccidentWarning, + doesNotRequireAnswer: true, + message: accidentType.warning.agricultureAccidentWarning, + alertType: 'warning', + condition: (formValue) => isAgricultureAccident(formValue), + marginBottom: 5, + }), + buildDescriptionField({ + id: 'workAccident.descriptionField', + space: 'containerGutter', + title: injuredPersonInformation.general.jobTitle, + description: injuredPersonInformation.general.jobTitleDescription, + width: 'full', + marginBottom: 2, + condition: (formValue) => isReportingOnBehalfSelf(formValue), + }), + buildTextField({ + id: 'workAccident.jobTitle', + title: injuredPersonInformation.labels.jobTitle, + backgroundColor: 'white', + width: 'full', + maxLength: 100, + condition: (formValue) => isReportingOnBehalfSelf(formValue), + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workMachineSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workMachineSubSection.ts new file mode 100644 index 000000000000..6b9ccee5acdb --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/workMachineSubSection.ts @@ -0,0 +1,60 @@ +import { + buildMultiField, + buildRadioField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { application, workMachine } from '../../../lib/messages' +import { + isAgricultureAccident, + isGeneralWorkplaceAccident, +} from '../../../utils' +import { isSportAccidentAndEmployee } from '../../../utils/isSportAccidentAndEmployee' +import { NO, YES } from '../../../constants' + +// Workmachine information only applicable to generic workplace accidents +export const workMachineSubSection = buildSubSection({ + id: 'workMachine.section', + title: workMachine.general.sectionTitle, + condition: (formValue) => + isGeneralWorkplaceAccident(formValue) || + isAgricultureAccident(formValue) || + isSportAccidentAndEmployee(formValue), + children: [ + buildMultiField({ + id: 'workMachine', + title: workMachine.general.workMachineRadioTitle, + description: '', + children: [ + buildRadioField({ + id: 'workMachineRadio', + title: '', + backgroundColor: 'blue', + width: 'half', + required: true, + options: [ + { value: YES, label: application.general.yesOptionLabel }, + { value: NO, label: application.general.noOptionLabel }, + ], + }), + ], + }), + buildMultiField({ + id: 'workMachine.description', + title: workMachine.general.subSectionTitle, + condition: (formValue) => formValue.workMachineRadio === YES, + children: [ + buildTextField({ + id: 'workMachine.desriptionOfMachine', + title: workMachine.labels.desriptionOfMachine, + placeholder: workMachine.placeholder.desriptionOfMachine, + backgroundColor: 'blue', + rows: 4, + variant: 'textarea', + required: true, + maxLength: 2000, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection.ts deleted file mode 100644 index 807c67e9c41d..000000000000 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { - buildCustomField, - buildDataProviderItem, - buildExternalDataProvider, - buildMultiField, - buildSection, - buildSubSection, -} from '@island.is/application/core' -import { NationalRegistryUserApi } from '@island.is/application/types' -import { externalData } from '../../lib/messages' - -export const externalDataSection = buildSection({ - id: 'ExternalDataSection', - title: 'Meðferð á gögnum', - children: [ - buildMultiField({ - title: externalData.agreementDescription.sectionTitle, - id: 'agreementDescriptionMultiField', - space: 2, - children: [ - buildCustomField({ - id: 'agreementDescriptionCustomField', - title: '', - component: 'AgreementDescription', - doesNotRequireAnswer: true, - }), - buildCustomField( - { - id: 'extrainformationWithDataprovider', - title: '', - component: 'DescriptionWithLink', - doesNotRequireAnswer: true, - }, - { - descriptionFirstPart: externalData.extraInformation.description, - descriptionSecondPart: '', - linkName: externalData.extraInformation.linkText, - url: externalData.extraInformation.link, - }, - ), - ], - }), - buildSubSection({ - id: 'AccidentNotificationForm', - title: externalData.dataProvider.sectionTitle, - children: [ - buildExternalDataProvider({ - title: externalData.dataProvider.pageTitle, - id: 'approveExternalData', - subTitle: externalData.dataProvider.subTitle, - description: '', - checkboxLabel: externalData.dataProvider.checkboxLabel, - dataProviders: [ - buildDataProviderItem({ - id: 'directoryOfLabor', - title: externalData.directoryOfLabor.title, - subTitle: externalData.directoryOfLabor.description, - }), - buildDataProviderItem({ - id: 'revAndCustoms', - title: externalData.revAndCustoms.title, - subTitle: externalData.revAndCustoms.description, - }), - buildDataProviderItem({ - id: 'nationalInsurancy', - title: externalData.nationalInsurancy.title, - subTitle: externalData.nationalInsurancy.description, - }), - buildDataProviderItem({ - id: 'municipalCollectionAgency', - title: externalData.municipalCollectionAgency.title, - subTitle: externalData.municipalCollectionAgency.description, - }), - buildDataProviderItem({ - provider: NationalRegistryUserApi, - title: externalData.nationalRegistry.title, - subTitle: externalData.nationalRegistry.description, - }), - buildDataProviderItem({ - id: 'accidentProvider', - title: '', - subTitle: externalData.accidentProvider.description, - }), - ], - }), - ], - }), - ], -}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/accidentNotificationSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/accidentNotificationSubSection.ts new file mode 100644 index 000000000000..9551bdb5bad5 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/accidentNotificationSubSection.ts @@ -0,0 +1,53 @@ +import { + buildDataProviderItem, + buildExternalDataProvider, + buildSubSection, +} from '@island.is/application/core' +import { externalData } from '../../../lib/messages' +import { NationalRegistryUserApi } from '@island.is/application/types' + +export const accidentNotificationSubSection = buildSubSection({ + id: 'AccidentNotificationForm', + title: externalData.dataProvider.sectionTitle, + children: [ + buildExternalDataProvider({ + title: externalData.dataProvider.pageTitle, + id: 'approveExternalData', + subTitle: externalData.dataProvider.subTitle, + description: '', + checkboxLabel: externalData.dataProvider.checkboxLabel, + dataProviders: [ + buildDataProviderItem({ + id: 'directoryOfLabor', + title: externalData.directoryOfLabor.title, + subTitle: externalData.directoryOfLabor.description, + }), + buildDataProviderItem({ + id: 'revAndCustoms', + title: externalData.revAndCustoms.title, + subTitle: externalData.revAndCustoms.description, + }), + buildDataProviderItem({ + id: 'nationalInsurancy', + title: externalData.nationalInsurancy.title, + subTitle: externalData.nationalInsurancy.description, + }), + buildDataProviderItem({ + id: 'municipalCollectionAgency', + title: externalData.municipalCollectionAgency.title, + subTitle: externalData.municipalCollectionAgency.description, + }), + buildDataProviderItem({ + provider: NationalRegistryUserApi, + title: externalData.nationalRegistry.title, + subTitle: externalData.nationalRegistry.description, + }), + buildDataProviderItem({ + id: 'accidentProvider', + title: '', + subTitle: externalData.accidentProvider.description, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/agreementDescriptionMultiField.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/agreementDescriptionMultiField.ts new file mode 100644 index 000000000000..ff2088966a1e --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/agreementDescriptionMultiField.ts @@ -0,0 +1,30 @@ +import { buildCustomField, buildMultiField } from '@island.is/application/core' +import { externalData } from '../../../lib/messages' + +export const agreementDescriptionMultiField = buildMultiField({ + title: externalData.agreementDescription.sectionTitle, + id: 'agreementDescriptionMultiField', + space: 2, + children: [ + buildCustomField({ + id: 'agreementDescriptionCustomField', + title: '', + component: 'AgreementDescription', + doesNotRequireAnswer: true, + }), + buildCustomField( + { + id: 'extrainformationWithDataprovider', + title: '', + component: 'DescriptionWithLink', + doesNotRequireAnswer: true, + }, + { + descriptionFirstPart: externalData.extraInformation.description, + descriptionSecondPart: '', + linkName: externalData.extraInformation.linkText, + url: externalData.extraInformation.link, + }, + ), + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/index.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/index.ts new file mode 100644 index 000000000000..da22cbd29167 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/externalDataSection/index.ts @@ -0,0 +1,9 @@ +import { buildSection } from '@island.is/application/core' +import { agreementDescriptionMultiField } from './agreementDescriptionMultiField' +import { accidentNotificationSubSection } from './accidentNotificationSubSection' + +export const externalDataSection = buildSection({ + id: 'ExternalDataSection', + title: 'Meðferð á gögnum', + children: [agreementDescriptionMultiField, accidentNotificationSubSection], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/index.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/index.ts index f8b0408fe877..82a2dfd20d95 100644 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/index.ts +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/index.ts @@ -3,13 +3,14 @@ import { Form, FormModes } from '@island.is/application/types' import Logo from '../../assets/Logo' import { application } from '../../lib/messages' -import { aboutTheAccidentSection } from './aboutTheAccidentSection' import { conclusionSection } from './conclusionSection' -import { externalDataSection } from './externalDataSection' + import { overviewSection } from './overviewSection' -import { whoIsTheNotificationForSection } from './whoIsTheNotificationForSection' import { betaTestSection } from './betaTestSection' import { applicantInformationSection } from './applicantInformationSection' +import { whoIsTheNotificationForSection } from './whoIsTheNotificationForSection' +import { externalDataSection } from './externalDataSection' +import { aboutTheAccidentSection } from './aboutTheAccidentSection' export const AccidentNotificationForm: Form = buildForm({ id: 'AccidentNotificationForm', diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts deleted file mode 100644 index 43b91fcd3f80..000000000000 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { - buildAlertMessageField, - buildCheckboxField, - buildCustomField, - buildDescriptionField, - buildFileUploadField, - buildMultiField, - buildRadioField, - buildSection, - buildSubSection, - buildTextField, - getValueViaPath, -} from '@island.is/application/core' -import { FILE_SIZE_LIMIT, UPLOAD_ACCEPT, YES } from '../../constants' -import { - childInCustody, - injuredPersonInformation, - juridicalPerson, - powerOfAttorney, - whoIsTheNotificationFor, - error, -} from '../../lib/messages' -import { - PowerOfAttorneyUploadEnum, - WhoIsTheNotificationForEnum, -} from '../../types' -import { - isReportingOnBehalfOfChild, - isReportingOnBehalfOfEmployee, - isReportingOnBehalfOfInjured, -} from '../../utils' -import { isPowerOfAttorney } from '../../utils/isPowerOfAttorney' -import { isUploadNow } from '../../utils/isUploadNow' - -export const whoIsTheNotificationForSection = buildSection({ - id: 'whoIsTheNotificationFor.section', - title: whoIsTheNotificationFor.general.sectionTitle, - children: [ - buildMultiField({ - id: 'whoIsTheNotificationFor', - title: whoIsTheNotificationFor.general.heading, - description: whoIsTheNotificationFor.general.description, - children: [ - buildRadioField({ - id: 'whoIsTheNotificationFor.answer', - title: '', - width: 'half', - options: [ - { - value: WhoIsTheNotificationForEnum.ME, - label: whoIsTheNotificationFor.labels.me, - }, - { - value: WhoIsTheNotificationForEnum.POWEROFATTORNEY, - label: whoIsTheNotificationFor.labels.powerOfAttorney, - }, - { - value: WhoIsTheNotificationForEnum.JURIDICALPERSON, - label: whoIsTheNotificationFor.labels.juridicalPerson, - }, - { - value: WhoIsTheNotificationForEnum.CHILDINCUSTODY, - label: whoIsTheNotificationFor.labels.childInCustody, - }, - ], - }), - ], - }), - buildSubSection({ - id: 'injuredPersonInformation.section', - title: injuredPersonInformation.general.sectionTitle, - children: [ - buildMultiField({ - id: 'injuredPersonInformation', - title: injuredPersonInformation.general.heading, - description: (formValue) => - isReportingOnBehalfOfEmployee(formValue.answers) - ? injuredPersonInformation.general.juridicalDescription - : injuredPersonInformation.general.description, - children: [ - buildTextField({ - id: 'injuredPersonInformation.name', - title: injuredPersonInformation.labels.name, - width: 'half', - backgroundColor: 'blue', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'injuredPersonInformation.nationalId', - title: injuredPersonInformation.labels.nationalId, - format: '######-####', - width: 'half', - backgroundColor: 'blue', - required: true, - }), - buildTextField({ - id: 'injuredPersonInformation.email', - title: injuredPersonInformation.labels.email, - backgroundColor: 'blue', - width: 'half', - variant: 'email', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'injuredPersonInformation.phoneNumber', - title: injuredPersonInformation.labels.tel, - backgroundColor: 'blue', - format: '###-####', - width: 'half', - variant: 'tel', - }), - buildDescriptionField({ - id: 'accidentDetails.descriptionField', - space: 'containerGutter', - title: injuredPersonInformation.general.jobTitle, - description: injuredPersonInformation.general.jobTitleDescription, - width: 'full', - marginBottom: 2, - }), - buildTextField({ - id: 'injuredPersonInformation.jobTitle', - title: injuredPersonInformation.labels.jobTitle, - backgroundColor: 'white', - width: 'full', - maxLength: 100, - }), - ], - }), - ], - condition: (formValue) => isReportingOnBehalfOfInjured(formValue), - }), - buildSubSection({ - id: 'juridicalPerson.company', - title: juridicalPerson.general.sectionTitle, - children: [ - buildMultiField({ - id: 'juridicalPerson.company', - title: juridicalPerson.general.title, - description: juridicalPerson.general.description, - children: [ - buildTextField({ - id: 'juridicalPerson.companyName', - backgroundColor: 'blue', - title: juridicalPerson.labels.companyName, - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'juridicalPerson.companyNationalId', - backgroundColor: 'blue', - title: juridicalPerson.labels.companyNationalId, - format: '######-####', - width: 'half', - required: true, - }), - buildCheckboxField({ - id: 'juridicalPerson.companyConfirmation', - title: '', - large: false, - backgroundColor: 'white', - defaultValue: [], - options: [ - { - value: YES, - label: juridicalPerson.labels.confirmation, - }, - ], - }), - ], - }), - ], - condition: (formValue) => isReportingOnBehalfOfEmployee(formValue), - }), - buildSubSection({ - id: 'powerOfAttorney.type.section', - title: powerOfAttorney.type.sectionTitle, - children: [ - buildMultiField({ - id: 'powerOfAttorney.type.multifield', - title: powerOfAttorney.type.heading, - description: powerOfAttorney.type.description, - children: [ - buildRadioField({ - id: 'powerOfAttorney.type', - title: '', - options: [ - { - value: PowerOfAttorneyUploadEnum.UPLOADNOW, - label: powerOfAttorney.labels.uploadNow, - }, - { - value: PowerOfAttorneyUploadEnum.UPLOADLATER, - label: powerOfAttorney.labels.uploadLater, - }, - ], - }), - buildAlertMessageField({ - id: 'attachments.injuryCertificate.alert', - title: powerOfAttorney.alertMessage.title, - message: powerOfAttorney.alertMessage.description, - alertType: 'warning', - doesNotRequireAnswer: true, - condition: (formValue) => - getValueViaPath(formValue, 'powerOfAttorney.type') === - PowerOfAttorneyUploadEnum.UPLOADLATER, - }), - ], - }), - ], - condition: (formValue) => isPowerOfAttorney(formValue), - }), - buildSubSection({ - id: 'childInCustody.section', - title: childInCustody.general.sectionTitle, - children: [ - buildMultiField({ - id: 'childInCustody.fields', - title: childInCustody.general.screenTitle, - description: childInCustody.general.screenDescription, - children: [ - buildTextField({ - id: 'childInCustody.name', - backgroundColor: 'blue', - title: childInCustody.labels.name, - width: 'half', - required: true, - maxLength: 100, - }), - buildTextField({ - id: 'childInCustody.nationalId', - backgroundColor: 'blue', - title: childInCustody.labels.nationalId, - format: '######-####', - width: 'half', - required: true, - }), - ], - }), - ], - condition: (answers) => isReportingOnBehalfOfChild(answers), - }), - buildSubSection({ - id: 'powerOfAttorney.upload.section', - title: powerOfAttorney.upload.sectionTitle, - children: [ - buildMultiField({ - id: 'powerOfAttorney', - title: powerOfAttorney.upload.heading, - description: powerOfAttorney.upload.description, - children: [ - buildCustomField({ - id: 'attachments.powerOfAttorney.fileLink', - component: 'ProxyDocument', - doesNotRequireAnswer: true, - title: '', - }), - buildFileUploadField({ - id: 'attachments.powerOfAttorneyFile.file', - title: '', - introduction: '', - maxSize: FILE_SIZE_LIMIT, - maxSizeErrorText: error.attachmentMaxSizeError, - uploadAccept: UPLOAD_ACCEPT, - uploadHeader: powerOfAttorney.upload.uploadHeader, - uploadDescription: powerOfAttorney.upload.uploadDescription, - uploadButtonLabel: powerOfAttorney.upload.uploadButtonLabel, - }), - ], - }), - ], - condition: (formValue) => isUploadNow(formValue), - }), - ], -}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/childInCustodySubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/childInCustodySubSection.ts new file mode 100644 index 000000000000..9587578fe81c --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/childInCustodySubSection.ts @@ -0,0 +1,38 @@ +import { + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { childInCustody } from '../../../lib/messages' +import { isReportingOnBehalfOfChild } from '../../../utils' + +export const childInCustodySubSection = buildSubSection({ + id: 'childInCustody.section', + title: childInCustody.general.sectionTitle, + children: [ + buildMultiField({ + id: 'childInCustody.fields', + title: childInCustody.general.screenTitle, + description: childInCustody.general.screenDescription, + children: [ + buildTextField({ + id: 'childInCustody.name', + backgroundColor: 'blue', + title: childInCustody.labels.name, + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'childInCustody.nationalId', + backgroundColor: 'blue', + title: childInCustody.labels.nationalId, + format: '######-####', + width: 'half', + required: true, + }), + ], + }), + ], + condition: (answers) => isReportingOnBehalfOfChild(answers), +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/index.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/index.ts new file mode 100644 index 000000000000..cfd061cbe286 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/index.ts @@ -0,0 +1,21 @@ +import { buildSection } from '@island.is/application/core' +import { whoIsTheNotificationFor } from '../../../lib/messages' +import { whoIsTheNotificationForMultiField } from './whoIsTheNotificationForMultiField' +import { injuredPersonInformationSubSection } from './injuredPersonInformationSubSection' +import { juridicalPersonCompanySubSection } from './juridicialPersonCompanySubSection' +import { powerOfAttorneySubSection } from './powerOfAttorneySubSection' +import { childInCustodySubSection } from './childInCustodySubSection' +import { powerOfAttorneyUploadSubSection } from './powerOfAttorneyUploadSubSection' + +export const whoIsTheNotificationForSection = buildSection({ + id: 'whoIsTheNotificationFor.section', + title: whoIsTheNotificationFor.general.sectionTitle, + children: [ + whoIsTheNotificationForMultiField, + injuredPersonInformationSubSection, + juridicalPersonCompanySubSection, + powerOfAttorneySubSection, + childInCustodySubSection, + powerOfAttorneyUploadSubSection, + ], +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/injuredPersonInformationSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/injuredPersonInformationSubSection.ts new file mode 100644 index 000000000000..434a2b6c2ea1 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/injuredPersonInformationSubSection.ts @@ -0,0 +1,77 @@ +import { + buildDescriptionField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { injuredPersonInformation } from '../../../lib/messages' +import { + isReportingOnBehalfOfEmployee, + isReportingOnBehalfOfInjured, +} from '../../../utils' + +export const injuredPersonInformationSubSection = buildSubSection({ + id: 'injuredPersonInformation.section', + title: injuredPersonInformation.general.sectionTitle, + children: [ + buildMultiField({ + id: 'injuredPersonInformation', + title: injuredPersonInformation.general.heading, + description: (formValue) => + isReportingOnBehalfOfEmployee(formValue.answers) + ? injuredPersonInformation.general.juridicalDescription + : injuredPersonInformation.general.description, + children: [ + buildTextField({ + id: 'injuredPersonInformation.name', + title: injuredPersonInformation.labels.name, + width: 'half', + backgroundColor: 'blue', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'injuredPersonInformation.nationalId', + title: injuredPersonInformation.labels.nationalId, + format: '######-####', + width: 'half', + backgroundColor: 'blue', + required: true, + }), + buildTextField({ + id: 'injuredPersonInformation.email', + title: injuredPersonInformation.labels.email, + backgroundColor: 'blue', + width: 'half', + variant: 'email', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'injuredPersonInformation.phoneNumber', + title: injuredPersonInformation.labels.tel, + backgroundColor: 'blue', + format: '###-####', + width: 'half', + variant: 'tel', + }), + buildDescriptionField({ + id: 'accidentDetails.descriptionField', + space: 'containerGutter', + title: injuredPersonInformation.general.jobTitle, + description: injuredPersonInformation.general.jobTitleDescription, + width: 'full', + marginBottom: 2, + }), + buildTextField({ + id: 'injuredPersonInformation.jobTitle', + title: injuredPersonInformation.labels.jobTitle, + backgroundColor: 'white', + width: 'full', + maxLength: 100, + }), + ], + }), + ], + condition: (formValue) => isReportingOnBehalfOfInjured(formValue), +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/juridicialPersonCompanySubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/juridicialPersonCompanySubSection.ts new file mode 100644 index 000000000000..45ec29a5a2a7 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/juridicialPersonCompanySubSection.ts @@ -0,0 +1,53 @@ +import { + buildCheckboxField, + buildMultiField, + buildSubSection, + buildTextField, +} from '@island.is/application/core' +import { juridicalPerson } from '../../../lib/messages' +import { isReportingOnBehalfOfEmployee } from '../../../utils' +import { YES } from '../../../constants' + +export const juridicalPersonCompanySubSection = buildSubSection({ + id: 'juridicalPerson.company', + title: juridicalPerson.general.sectionTitle, + children: [ + buildMultiField({ + id: 'juridicalPerson.company', + title: juridicalPerson.general.title, + description: juridicalPerson.general.description, + children: [ + buildTextField({ + id: 'juridicalPerson.companyName', + backgroundColor: 'blue', + title: juridicalPerson.labels.companyName, + width: 'half', + required: true, + maxLength: 100, + }), + buildTextField({ + id: 'juridicalPerson.companyNationalId', + backgroundColor: 'blue', + title: juridicalPerson.labels.companyNationalId, + format: '######-####', + width: 'half', + required: true, + }), + buildCheckboxField({ + id: 'juridicalPerson.companyConfirmation', + title: '', + large: false, + backgroundColor: 'white', + defaultValue: [], + options: [ + { + value: YES, + label: juridicalPerson.labels.confirmation, + }, + ], + }), + ], + }), + ], + condition: (formValue) => isReportingOnBehalfOfEmployee(formValue), +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneySubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneySubSection.ts new file mode 100644 index 000000000000..eb16cefeec0f --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneySubSection.ts @@ -0,0 +1,49 @@ +import { + buildAlertMessageField, + buildMultiField, + buildRadioField, + buildSubSection, + getValueViaPath, +} from '@island.is/application/core' +import { powerOfAttorney } from '../../../lib/messages' +import { PowerOfAttorneyUploadEnum } from '../../../types' +import { isPowerOfAttorney } from '../../../utils' + +export const powerOfAttorneySubSection = buildSubSection({ + id: 'powerOfAttorney.type.section', + title: powerOfAttorney.type.sectionTitle, + children: [ + buildMultiField({ + id: 'powerOfAttorney.type.multifield', + title: powerOfAttorney.type.heading, + description: powerOfAttorney.type.description, + children: [ + buildRadioField({ + id: 'powerOfAttorney.type', + title: '', + options: [ + { + value: PowerOfAttorneyUploadEnum.UPLOADNOW, + label: powerOfAttorney.labels.uploadNow, + }, + { + value: PowerOfAttorneyUploadEnum.UPLOADLATER, + label: powerOfAttorney.labels.uploadLater, + }, + ], + }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: powerOfAttorney.alertMessage.title, + message: powerOfAttorney.alertMessage.description, + alertType: 'warning', + doesNotRequireAnswer: true, + condition: (formValue) => + getValueViaPath(formValue, 'powerOfAttorney.type') === + PowerOfAttorneyUploadEnum.UPLOADLATER, + }), + ], + }), + ], + condition: (formValue) => isPowerOfAttorney(formValue), +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneyUploadSubSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneyUploadSubSection.ts new file mode 100644 index 000000000000..d3defa608ae5 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/powerOfAttorneyUploadSubSection.ts @@ -0,0 +1,41 @@ +import { + buildCustomField, + buildFileUploadField, + buildMultiField, + buildSubSection, +} from '@island.is/application/core' +import { error, powerOfAttorney } from '../../../lib/messages' +import { FILE_SIZE_LIMIT, UPLOAD_ACCEPT } from '../../../constants' +import { isUploadNow } from '../../../utils/isUploadNow' + +export const powerOfAttorneyUploadSubSection = buildSubSection({ + id: 'powerOfAttorney.upload.section', + title: powerOfAttorney.upload.sectionTitle, + children: [ + buildMultiField({ + id: 'powerOfAttorney', + title: powerOfAttorney.upload.heading, + description: powerOfAttorney.upload.description, + children: [ + buildCustomField({ + id: 'attachments.powerOfAttorney.fileLink', + component: 'ProxyDocument', + doesNotRequireAnswer: true, + title: '', + }), + buildFileUploadField({ + id: 'attachments.powerOfAttorneyFile.file', + title: '', + introduction: '', + maxSize: FILE_SIZE_LIMIT, + maxSizeErrorText: error.attachmentMaxSizeError, + uploadAccept: UPLOAD_ACCEPT, + uploadHeader: powerOfAttorney.upload.uploadHeader, + uploadDescription: powerOfAttorney.upload.uploadDescription, + uploadButtonLabel: powerOfAttorney.upload.uploadButtonLabel, + }), + ], + }), + ], + condition: (formValue) => isUploadNow(formValue), +}) diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/whoIsTheNotificationForMultiField.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/whoIsTheNotificationForMultiField.ts new file mode 100644 index 000000000000..766ea3128bc2 --- /dev/null +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection/whoIsTheNotificationForMultiField.ts @@ -0,0 +1,34 @@ +import { buildMultiField, buildRadioField } from '@island.is/application/core' +import { whoIsTheNotificationFor } from '../../../lib/messages' +import { WhoIsTheNotificationForEnum } from '../../../types' + +export const whoIsTheNotificationForMultiField = buildMultiField({ + id: 'whoIsTheNotificationFor', + title: whoIsTheNotificationFor.general.heading, + description: whoIsTheNotificationFor.general.description, + children: [ + buildRadioField({ + id: 'whoIsTheNotificationFor.answer', + title: '', + width: 'half', + options: [ + { + value: WhoIsTheNotificationForEnum.ME, + label: whoIsTheNotificationFor.labels.me, + }, + { + value: WhoIsTheNotificationForEnum.POWEROFATTORNEY, + label: whoIsTheNotificationFor.labels.powerOfAttorney, + }, + { + value: WhoIsTheNotificationForEnum.JURIDICALPERSON, + label: whoIsTheNotificationFor.labels.juridicalPerson, + }, + { + value: WhoIsTheNotificationForEnum.CHILDINCUSTODY, + label: whoIsTheNotificationFor.labels.childInCustody, + }, + ], + }), + ], +}) diff --git a/libs/application/templates/accident-notification/src/lib/dataSchema.ts b/libs/application/templates/accident-notification/src/lib/dataSchema.ts index 8777b3490c13..ea66619b0a67 100644 --- a/libs/application/templates/accident-notification/src/lib/dataSchema.ts +++ b/libs/application/templates/accident-notification/src/lib/dataSchema.ts @@ -20,6 +20,7 @@ import { } from '../types' import { isValid24HFormatTime } from '../utils' import { error } from './messages/error' +import { time } from 'console' export enum OnBehalf { MYSELF = 'myself', @@ -166,6 +167,14 @@ export const AccidentNotificationSchema = z.object({ accidentSymptoms: z.string().refine((x) => x.trim().length > 0, { params: error.invalidValue, }), + dateOfDoctorVisit: z.string().refine((x) => x.trim().length > 0, { + params: error.invalidValue, + }), + timeOfDoctorVisit: z + .string() + .refine((x) => (x ? isValid24HFormatTime(x) : false), { + params: error.invalidValue, + }), }), isRepresentativeOfCompanyOrInstitue: z.array(z.string()).optional(), fishingShipInfo: z.object({ @@ -252,6 +261,7 @@ export const AccidentNotificationSchema = z.object({ WorkAccidentTypeEnum.GENERAL, WorkAccidentTypeEnum.PROFESSIONALATHLETE, ]), + jobTitle: z.string().optional(), }), studiesAccident: z.object({ type: z.enum([ @@ -274,6 +284,7 @@ export const AccidentNotificationSchema = z.object({ params: error.invalidValue, }), phoneNumber: z.string().optional(), + jobTitle: z.string().optional(), }), juridicalPerson: z.object({ companyName: z.string().refine((x) => x.trim().length > 0, { diff --git a/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts b/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts index c2253673c238..c0136d511525 100644 --- a/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts +++ b/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts @@ -28,13 +28,13 @@ export const injuredPersonInformation = { jobTitle: { id: 'an.application:injuredPersonInformation.general.jobTitle', defaultMessage: 'Starfsheiti', - description: 'Job title', + description: 'Title above the job title input field', }, jobTitleDescription: { id: 'an.application:injuredPersonInformation.general.jobTitleDescription', defaultMessage: 'Sláðu inn starfsheiti þess slasaða þegar slysið átti sér stað.', - description: 'Description for job title', + description: 'Description for job title input field', }, }), labels: defineMessages({ @@ -61,7 +61,7 @@ export const injuredPersonInformation = { jobTitle: { id: 'an.application:injuredPersonInformation.labels.jobTitle', defaultMessage: 'Starfsheiti', - description: 'Job title', + description: 'Label for job title input field', }, }), upload: defineMessages({