Skip to content

Commit

Permalink
fix(parental-leave): Amend condition for other parent approval (#16050)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
ylfahfa and kodiakhq[bot] authored Sep 18, 2024
1 parent 0421bfe commit a97a7fe
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import { Form, FormModes, Application } from '@island.is/application/types'
import Logo from '../assets/Logo'
import { YES } from '../constants'
import { otherParentApprovalFormMessages } from '../lib/messages'
import { currentDateStartTime } from '../lib/parentalLeaveTemplateUtils'
import { getApplicationAnswers } from '../lib/parentalLeaveUtils'
import {
getApplicationAnswers,
getLastDayOfLastMonth,
} from '../lib/parentalLeaveUtils'

export const OtherParentApproval: Form = buildForm({
id: 'OtherParentApprovalForParentalLeave',
Expand Down Expand Up @@ -94,10 +96,14 @@ export const OtherParentApproval: Form = buildForm({
title: otherParentApprovalFormMessages.warning,
titleVariant: 'h4',
description: otherParentApprovalFormMessages.startDateInThePast,
condition: (answers) =>
new Date(
condition: (answers) => {
const lastDateOfLastMonth = getLastDayOfLastMonth()
const startDateTime = new Date(
getApplicationAnswers(answers).periods[0].startDate,
).getTime() < currentDateStartTime(),
).getTime()

return startDateTime <= lastDateOfLastMonth.getTime()
},
}),
buildSubmitField({
id: 'submit',
Expand All @@ -113,10 +119,14 @@ export const OtherParentApproval: Form = buildForm({
name: coreMessages.buttonApprove,
type: 'primary',
event: 'APPROVE',
condition: (answers) =>
new Date(
condition: (answers) => {
const lastDateOfLastMonth = getLastDayOfLastMonth()
const startDateTime = new Date(
getApplicationAnswers(answers).periods[0].startDate,
).getTime() >= currentDateStartTime(),
).getTime()

return startDateTime > lastDateOfLastMonth.getTime()
},
},
],
}),
Expand Down

0 comments on commit a97a7fe

Please sign in to comment.