Skip to content

Commit

Permalink
fix(application-system): Fixing export error and input error in custo…
Browse files Browse the repository at this point in the history
…m component (#17046)

* initial application creation

* Continued work setting up application

* Further work setting up work accident notification application

* Work on company screen in application

* skeleton work for page steps

* mock data and further work on steps

* Further development of work accident notificaion application

* Creating a new client for slysaskraning

* starting client setup, getting open-api from VER

* Setting up client for slysaskraning

* clientConfig testing removed

* further progress of work accident notification

* fixing broken component to not push broken code

* Working on consistant data going back and forth in screens

* MultiSelect states/answers setup, added most serious option. Missing validation if user chooses most serious and then removes that option from multiselect

* multiselect work

* minor fixes, adding attributes to data schema

* adding attributes to dataschema, still incomplete in terms of refining, validaiton etc..

* dev readme, delete later

* fixing some messeges and adding seeder script

* multiselect finished

* dev readme, delete later v2

* adding create account mockup and submitapplication
!

* some changes

* Working on multiselect screens in tilkynning vinnuslyss

* removing comments, logs and addding a useEffect to setValue to formcontext on load

* adding 2 new screens (typeOfInjury and injuredBodyParts), minor fixes for when a user removes options from list that was previously chosen as the most serious, minor comments added and removed

* changes to submitapplication

* starting to index starfsmadur and orsakir screens to allow for multiple employees

* indexing for multiple employees, data schema update, moving announcement page to its own file

* overview

* adding indexing to ids otherwise we get graphql validation errors

* overview company

* commenting out atvinnugreinaflokkun, will remove once confirmed it should not be there

* about accident

* adding conditional radio field to verkkaup, fixing code for major and sub groups since they do not all have the same format, employmentStatus dataschema added and fixed, starfsgrein not auto filling correct on back button fixes (should look at again to clean up code)

* adding add employees button

* add employee button works

* bunch of schema/required/validation added

* doesnotrequireanswer added

* zod schema additions, required on component that should be required, removed console.logs, added error messaging to pages

* Fixing mount issue when going from employee 2 to employee 1 via back button

* adding things to overview employees and few things to submit application

* forgot to save

* adding template name and institution

* resolving conflicts

* adding input values and some changes to submit app

* submit and conclusion

* first commit of delete functionality, some todo cleanup

* remove log

* select checkbox design

* adding delete button to overview screen

* feature flag added, mobile styling fixed in overview, data schema minor update

* merge conflict

* fixing config module after recent main changes

* Chaning minor texts, adding README, deleting dev_readme

* update messages

* adding date check

* fixing submit

* merge conflict

* fixing minors things from PR suggestions etc.

* Using Locale type

* fixing spacing on Select inputs and adding a placeholder

* placeholder and message changes

* fallback if individual for branch info

* fixing errors

* employee name in overview + placeholder for causeAndConsequences

* removing default on Select

* fixing back button and conclusion navigation step view

* Fixing for PR comment, mostly error message translations etc..

* fixing null values in answers causing validation fails because missing nullable. Simplifying multiple calls to same getValues

* fixing issues with multidropdown and answers

* Adding missing contentfulId to institutionMapper

* add requiredScope

* import missing

* adding pdf to final page

* minor fixes from PR review

* fixing types

* forgot one type

* PR comment fixes

* moved payload

* adding type

* Remove fake sections

* removing title for pages that have no section

* Adding work accident client to infra/src/dsl and application-system/api/infra and generating values

* Adding to apps/api/infra and running yarn charts

---------

Co-authored-by: berglindoma13 <[email protected]>
Co-authored-by: Sigrún Tinna Gissurardóttir <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 28, 2024
1 parent edf13e2 commit 4c6fade
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC, useEffect, useState } from 'react'
import {
Box,
Checkbox,
GridColumn,
GridRow,
Select,
} from '@island.is/island-ui/core'
import { FC, useState } from 'react'
import { Box, GridColumn, GridRow, Select } from '@island.is/island-ui/core'
import { getValueViaPath } from '@island.is/application/core'
import { Controller, useFormContext } from 'react-hook-form'
import { accident } from '../../lib/messages'
import { useLocale } from '@island.is/localization'
import { WorkingEnvironmentDto } from '@island.is/clients/work-accident-ver'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { WorkAccidentNotification } from '../..'

type Option = {
value: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UPDATE_APPLICATION } from '@island.is/application/graphql'
import { FieldBaseProps } from '@island.is/application/types'
import { getValueViaPath } from '@island.is/application/core'
import { useFormContext } from 'react-hook-form'
import { MAX_EMPLOYEES } from '../../shared/constants'

export const AddEmployee: FC<React.PropsWithChildren<FieldBaseProps>> = ({
application,
Expand Down Expand Up @@ -58,6 +59,9 @@ export const AddEmployee: FC<React.PropsWithChildren<FieldBaseProps>> = ({
{formatMessage(overview.labels.addEmployeeDescription)}
</Text>
<Button
disabled={
employeeAmount && employeeAmount > MAX_EMPLOYEES ? true : false
}
variant="ghost"
icon="add"
fluid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { FieldBaseProps } from '@island.is/application/types'
import { FC } from 'react'
import { causeAndConsequences } from '../../lib/messages'
import { Option } from '../Components/types'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { CausesAndEffects } from '../Components/CausesAndEffects'
import { WorkAccidentNotification } from '../..'

export type OptionAndKey = {
option: Option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
import { getErrorViaPath, getValueViaPath } from '@island.is/application/core'
import { Controller, useFormContext } from 'react-hook-form'
import { WorkplaceHealthAndSafetyDto } from '@island.is/clients/work-accident-ver'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { useLocale } from '@island.is/localization'
import { information } from '../../lib/messages/information'
import { WorkAccidentNotification } from '../..'

export const CheckboxFieldCustom: FC<
React.PropsWithChildren<FieldBaseProps>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC } from 'react'
import { causeAndConsequences } from '../../lib/messages'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { CausesAndEffects } from '../Components/CausesAndEffects'
import { WorkAccidentNotification } from '../..'

interface CircumstanceProps {
field: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const CausesAndEffects: FC<
errors,
answerId,
setBeforeSubmitCallback,
majorGroupLength,
} = props
const { setValue } = useFormContext()
const { formatMessage } = useLocale()
Expand All @@ -68,9 +69,14 @@ export const CausesAndEffects: FC<

const onChange = (answers: OptionWithKey) => {
const options: Option[] = []
const uniqueOptions = new Set<string>()

for (const key in answers) {
answers[key].forEach((option) => {
options.push(option)
if (!uniqueOptions.has(option.value)) {
uniqueOptions.add(option.value)
options.push(option)
}
})
}

Expand Down Expand Up @@ -111,7 +117,7 @@ export const CausesAndEffects: FC<
causeAndConsequences.shared.searchPlaceholder,
)}
onChange={(value) => {
const code = value?.value.substring(0, 1)
const code = value?.value.substring(0, majorGroupLength)
const activity: Option = {
value: value?.value || '',
label: value?.label || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,23 @@ export const MultiSelectDropdownController: FC<

useEffect(() => {
if (!pickedValue || !pickedValue.key || !pickedValue.option) return

setAnswers((currentValue) => ({
...currentValue,
[pickedValue.key]: [
...(currentValue[pickedValue.key] || []),
pickedValue.option,
],
[pickedValue.key]: currentValue[pickedValue.key]?.some(
(option) => option.value === pickedValue.option.value,
)
? currentValue[pickedValue.key]
: [...(currentValue[pickedValue.key] || []), pickedValue.option],
}))

setValue(answerId, {
...answers,
[pickedValue.key]: [
...(answers[pickedValue.key] || []),
pickedValue.option,
],
[pickedValue.key]: answers[pickedValue.key]?.some(
(option) => option.value === pickedValue.option.value,
)
? answers[pickedValue.key]
: [...(answers[pickedValue.key] || []), pickedValue.option],
})
}, [pickedValue])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FieldBaseProps } from '@island.is/application/types'
import { Button } from '@island.is/island-ui/core'
import { FC } from 'react'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { useMutation } from '@apollo/client'
import { UPDATE_APPLICATION } from '@island.is/application/graphql'
import { useLocale } from '@island.is/localization'
import { shared } from '../../lib/messages'
import { WorkAccidentNotification } from '../..'

interface DeleteEmployeeProps {
index: number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC } from 'react'
import { causeAndConsequences } from '../../lib/messages'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { CausesAndEffects } from '../Components/CausesAndEffects'
import { WorkAccidentNotification } from '../..'

interface DeviationProps {
field: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, ErrorMessage } from '@island.is/island-ui/core'
import { useFormContext } from 'react-hook-form'
import { employee } from '../../lib/messages'
import { useLocale } from '@island.is/localization'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { WorkAccidentNotification } from '../..'
import { dateIsWithin36Hours, formatDate } from '../../utils'
import { getValueViaPath } from '@island.is/application/core'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC } from 'react'
import { causeAndConsequences } from '../../lib/messages'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { CausesAndEffects } from '../Components/CausesAndEffects'
import { getValueViaPath } from '@island.is/application/core'
import { WorkAccidentNotification } from '../..'

interface InjuredBodyPartsProps {
field: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useLocale } from '@island.is/localization'
import { employee } from '../../lib/messages'
import { Controller, useFormContext } from 'react-hook-form'
import { VictimsOccupationDto } from '@island.is/clients/work-accident-ver'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { WorkAccidentNotification } from '../..'

export type Options = {
label: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { useLocale } from '@island.is/localization'
import { overview } from '../../lib/messages'
import { ReviewGroup } from '../Components/ReviewGroup'
import { KeyValueFormField } from '@island.is/application/ui-fields'
import { EmployeeType, WorkAccidentNotification } from '../../lib/dataSchema'
import { EmployeeType } from '../../lib/dataSchema'
import { getEmployeeInformationForOverview } from '../../utils/getEmployeeInformationForOverview'
import { getCauseAndConsequencesForOverview } from '../../utils/getCauseAndConsequencesForOverview'
import { DeleteEmployee } from '../DeleteEmployee'
import { WorkAccidentNotification } from '../..'

type EmployeeAccordionItemType = {
employee: EmployeeType
Expand All @@ -23,7 +24,7 @@ type EmployeeAccordionItemType = {
export const EmployeeAccordionItem: FC<
React.PropsWithChildren<FieldBaseProps & EmployeeAccordionItemType>
> = ({ ...props }) => {
const { application, field, employee, onClick, index } = props
const { application, employee, onClick, index } = props
const { formatMessage } = useLocale()
const answers = application.answers as WorkAccidentNotification

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC } from 'react'
import { causeAndConsequences } from '../../lib/messages'
import { WorkAccidentNotification } from '../../lib/dataSchema'
import { CausesAndEffects } from '../Components/CausesAndEffects'
import { WorkAccidentNotification } from '../..'

interface TypeOfInjuryProps {
field: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { typeOfInjurySection } from './typeOfInjury'
import { injuredBodyPartsSection } from './injuredBodyParts'
import { deviationSection } from './deviation'
import { FormValue } from '@island.is/application/types'
import { WorkAccidentNotification } from '../../../lib/dataSchema'
import { WorkAccidentNotification } from '../../..'

export const causeAndConsequencesSection = (index: number) =>
buildSection({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { buildSection } from '@island.is/application/core'
import { sections } from '../../../lib/messages/sections'
import { employeeSubSection } from './employee'
import { FormValue } from '@island.is/application/types'
import { WorkAccidentNotification } from '../../../lib/dataSchema'
import { WorkAccidentNotification } from '../../..'

export const employeeSection = (index: number) =>
buildSection({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { EmployeeAndAccidentInformationSection } from '../RepeatableSection'
import { overviewSection } from './OverviewSection'
import { announcementSection } from './AnnouncementSection'
import { conclusionSection } from './ConclusionSection'
import { MAX_EMPLOYEES } from '../../shared/constants'

const buildRepeatableSections = (): Section[] => {
const sections = [...Array(20)].map((_key, index) => {
const sections = [...Array(MAX_EMPLOYEES)].map((_key, index) => {
return EmployeeAndAccidentInformationSection(index)
})
return sections.flat()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import template from './lib/WorkAccidentNotificationTemplate'
import { WorkAccidentNotificationAnswers } from './lib/dataSchema'

export const getFields = () => import('./fields/')

export { WorkAccidentNotification } from './lib/dataSchema'

export type WorkAccidentNotification = WorkAccidentNotificationAnswers
export default template
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const WorkAccidentNotificationAnswersSchema = z.object({
employeeAmount: z.number().min(1),
})

export type WorkAccidentNotification = z.TypeOf<
export type WorkAccidentNotificationAnswers = z.TypeOf<
typeof WorkAccidentNotificationAnswersSchema
>
export type BasicCompanyType = z.TypeOf<typeof basicCompanySchema>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export enum ApiActions {
export const EMPLOYMENT_STATUS = {
TEMP_AGENCY: '4', // starfsmannaleiga
} as const

export const MAX_EMPLOYEES = 20

0 comments on commit 4c6fade

Please sign in to comment.