Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(haskolagatt): Small fixes in application #16726

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getAllCountryCodes } from '@island.is/shared/utils'
import { FileUploadController } from '@island.is/application/ui-components'
import { useFormContext } from 'react-hook-form'
import { EducationDetailsItem } from '../../shared/types'
import { degreeLevelOptions } from '../../lib/constants'

interface DetailsRepeaterItemProps extends FieldBaseProps {
index: number
Expand All @@ -38,8 +39,6 @@ interface DetailsRepeaterItemProps extends FieldBaseProps {
export const DetailsRepeaterItem: FC<DetailsRepeaterItemProps> = ({
id,
application,
field,
goToScreen,
index,
repeaterField,
itemNumber,
Expand Down Expand Up @@ -122,7 +121,7 @@ export const DetailsRepeaterItem: FC<DetailsRepeaterItemProps> = ({
return (
<Box
position="relative"
marginBottom={1}
marginBottom={2}
hidden={repeaterField.wasRemoved === 'true' && !readOnly}
>
{itemNumber > 0 && (
Expand Down Expand Up @@ -180,36 +179,10 @@ export const DetailsRepeaterItem: FC<DetailsRepeaterItemProps> = ({
index,
)
}
options={[
{
label: formatMessage(
formerEducation.labels.educationDetails
.framhaldsskoliSelectionLabel,
),
value: 'framhaldsskoli',
},
{
label: formatMessage(
formerEducation.labels.educationDetails
.bachelorsSelectionLabel,
),
value: 'bachelors',
},
{
label: formatMessage(
formerEducation.labels.educationDetails
.mastersSelectionLabel,
),
value: 'masters',
},
{
label: formatMessage(
formerEducation.labels.educationDetails
.doctorsSelectionLabel,
),
value: 'doctors',
},
]}
options={degreeLevelOptions.map((x) => ({
label: formatMessage(x.label),
value: x.value,
}))}
/>
</GridColumn>
) : (
Expand Down Expand Up @@ -417,21 +390,23 @@ export const DetailsRepeaterItem: FC<DetailsRepeaterItemProps> = ({
/>
)}
{!readOnly && (
<InputController
id={moreDetailsField}
textarea
backgroundColor="blue"
label={formatMessage(
formerEducation.labels.educationDetails.moreDetailsLabel,
)}
onChange={(value) =>
addDataToEducationList(
'moreDetails',
value.target.value as string,
index,
)
}
/>
<Box marginTop={2}>
<InputController
id={moreDetailsField}
textarea
backgroundColor="blue"
label={formatMessage(
formerEducation.labels.educationDetails.moreDetailsLabel,
)}
onChange={(value) =>
addDataToEducationList(
'moreDetails',
value.target.value as string,
index,
)
}
/>
</Box>
)}
</Box>
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { FieldBaseProps } from '@island.is/application/types'
import { Box } from '@island.is/island-ui/core'
import { FC } from 'react'
import { EMPTY_MODE_OF_DELIVERY, Routes } from '../../lib/constants'
import { useFormContext } from 'react-hook-form'

// Special validation to make sure chosenMode is not empty,
// since we sometimes need to set the value to dummy EMPTY_MODE_OF_DELIVERY
// when trying to clear the field in the programSelection step
export const HiddenValidation: FC<FieldBaseProps> = ({
setBeforeSubmitCallback,
}) => {
const { getValues } = useFormContext()

setBeforeSubmitCallback?.(async () => {
const modeOfDeliveryAnswer = getValues(
`${Routes.MODEOFDELIVERYINFORMATION}.chosenMode`,
)

if (modeOfDeliveryAnswer === EMPTY_MODE_OF_DELIVERY) return [false, '']

return [true, null]
})

return <Box hidden={true}></Box>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EducationDetailsItemNotFinished,
} from '../../shared/types'
import { ApplicationTypes } from '@island.is/university-gateway'
import { getChosenProgram } from '../../utils'

export const Overview: FC<FieldBaseProps> = ({
application,
Expand Down Expand Up @@ -47,12 +48,19 @@ export const Overview: FC<FieldBaseProps> = ({
setAcceptModalVisibility(true)
}

const chosenProgram = getChosenProgram(application.externalData, answers)
const showOtherDocuments =
!!chosenProgram &&
chosenProgram.extraApplicationFields &&
chosenProgram.extraApplicationFields.length > 0

return (
<Box>
<Divider />
<ProgramReview field={field} application={application} />

<Divider />
<ApplicantReview field={field} application={application} />

<Divider />
{educationOptionChosen &&
educationOptionChosen === ApplicationTypes.EXEMPTION && (
Expand Down Expand Up @@ -89,13 +97,18 @@ export const Overview: FC<FieldBaseProps> = ({
route={Routes.EDUCATIONDETAILSFINISHED}
/>
)}
<Divider />
<OtherDocumentsReview
field={field}
application={application}
route={Routes.OTHERDOCUMENTS}
goToScreen={goToScreen}
/>

{showOtherDocuments && <Divider />}
{showOtherDocuments && (
<OtherDocumentsReview
field={field}
application={application}
route={Routes.OTHERDOCUMENTS}
goToScreen={goToScreen}
extraApplicationFields={chosenProgram.extraApplicationFields}
/>
)}

<Box marginTop={14}>
<Divider />
<Box display="flex" justifyContent="spaceBetween" paddingY={5}>
Expand Down
Loading