Skip to content

Commit 3d47450

Browse files
committed
Add check for applicationDataHasBeenPruned
1 parent 9785a08 commit 3d47450

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

libs/application/templates/secondary-school/src/fields/overview/index.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@ import { ApplicantOverview } from './ApplicantOverview'
55
import { CustodianOverview } from './CustodianOverview'
66
import { SchoolSelectionOverview } from './SchoolSelectionOverview'
77
import { ExtraInformationOverview } from './ExtraInformationOverview'
8+
import { applicationDataHasBeenPruned, States } from '../../utils'
9+
import { useLocale } from '@island.is/localization'
10+
import { overview } from '../../lib/messages'
811

912
export const Overview: FC<FieldBaseProps> = (props) => {
10-
return (
13+
const { formatMessage } = useLocale()
14+
15+
return applicationDataHasBeenPruned(props.application.answers) ? (
16+
<Box>
17+
{props.application.state === States.SUBMITTED &&
18+
formatMessage(overview.applicationDataHasBeenPruned.submitted)}
19+
{props.application.state === States.IN_REVIEW &&
20+
formatMessage(overview.applicationDataHasBeenPruned.inReview)}
21+
{props.application.state === States.COMPLETED &&
22+
formatMessage(overview.applicationDataHasBeenPruned.completed)}
23+
</Box>
24+
) : (
1125
<Box>
1226
<ApplicantOverview {...props} />
1327

libs/application/templates/secondary-school/src/forms/submittedForm.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { DefaultEvents, Form, FormModes } from '@island.is/application/types'
1212
import { conclusion, overview } from '../lib/messages'
1313
import { Logo } from '../assets/Logo'
14-
import { checkIsFreshman } from '../utils'
14+
import { applicationDataHasBeenPruned, checkIsFreshman } from '../utils'
1515

1616
export const Submitted: Form = buildForm({
1717
id: 'SubmittedForm',
@@ -34,7 +34,10 @@ export const Submitted: Form = buildForm({
3434
title: conclusion.overview.alertTitle,
3535
message: conclusion.overview.alertMessageFreshman,
3636
condition: (answers) => {
37-
return checkIsFreshman(answers)
37+
return (
38+
!applicationDataHasBeenPruned(answers) &&
39+
checkIsFreshman(answers)
40+
)
3841
},
3942
}),
4043
buildAlertMessageField({
@@ -43,7 +46,10 @@ export const Submitted: Form = buildForm({
4346
title: conclusion.overview.alertTitle,
4447
message: conclusion.overview.alertMessageGeneral,
4548
condition: (answers) => {
46-
return !checkIsFreshman(answers)
49+
return (
50+
!applicationDataHasBeenPruned(answers) &&
51+
!checkIsFreshman(answers)
52+
)
4753
},
4854
}),
4955
buildCustomField({
@@ -61,6 +67,7 @@ export const Submitted: Form = buildForm({
6167
id: 'submit',
6268
placement: 'footer',
6369
refetchApplicationAfterSubmit: true,
70+
condition: (answers) => !applicationDataHasBeenPruned(answers),
6471
actions: [
6572
{
6673
event: DefaultEvents.EDIT,

libs/application/templates/secondary-school/src/lib/messages/overview.ts

+21
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,25 @@ export const overview = {
171171
description: 'Received application button',
172172
},
173173
}),
174+
applicationDataHasBeenPruned: defineMessages({
175+
submitted: {
176+
id: 'ss.application:overview.applicationDataHasBeenPruned.submitted',
177+
defaultMessage:
178+
'Umsókn er innsend. Ef það þarf að breyta umsókn þarf að eyða þessari og gera nýja.',
179+
description:
180+
'Overview message if application data had been pruned, and application is in submitted state',
181+
},
182+
inReview: {
183+
id: 'ss.application:overview.applicationDataHasBeenPruned.inReview',
184+
defaultMessage: 'Umsókn er í vinnslu hjá stofnun.',
185+
description:
186+
'Overview message if application data had been pruned, and application is in in review state',
187+
},
188+
completed: {
189+
id: 'ss.application:overview.applicationDataHasBeenPruned.submitted',
190+
defaultMessage: 'Umsókn er afgreidd.',
191+
description:
192+
'Overview message if application data had been pruned, and application is in completed state',
193+
},
194+
}),
174195
}

libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { getValueViaPath } from '@island.is/application/core'
2+
import { FormValue } from '@island.is/application/types'
3+
14
export * from './checkHasAnyCustodians'
25
export * from './format'
36
export * from './getDate'
@@ -6,3 +9,7 @@ export * from './checkIsEditable'
69
export * from './checkUseAnswersCopy'
710
export * from './checkIsFreshman'
811
export * from './checkIsActor'
12+
13+
export const applicationDataHasBeenPruned = (answers: FormValue) => {
14+
return !getValueViaPath<boolean>(answers, 'approveExternalData')
15+
}

0 commit comments

Comments
 (0)