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(parental-leave): Refactor Sync - VMST #14436

Merged
merged 29 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2a38289
Small change after merge main
veronikasif Mar 6, 2024
618f83e
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Mar 25, 2024
2f3c54a
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Mar 26, 2024
213b755
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 2, 2024
0c8754c
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 2, 2024
e72dd6e
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 4, 2024
ca77b04
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 8, 2024
26db8e5
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 8, 2024
37a5bc9
Changed MODIFY event to EDIT and added tiggerEvent to validateApplica…
veronikasif Apr 9, 2024
d82904c
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 10, 2024
b284c2f
Removed shouldNotCall from getApplicationInformation query, use skip …
veronikasif Apr 10, 2024
aade2f0
[UUFV-415] Refactor Sync - VMST
veronikasif Apr 10, 2024
888c419
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 10, 2024
59d54b8
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 11, 2024
75dc8d3
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 12, 2024
405b3cf
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 15, 2024
01df946
Removed unused comments and made some changes
veronikasif Apr 16, 2024
8333317
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif Apr 30, 2024
b54da2b
Fix SummaryTimeline label
veronikasif Apr 30, 2024
c45cac6
Fixed merge conflict
veronikasif May 10, 2024
5f6b89a
Fixed merge conflict - 2
veronikasif May 10, 2024
b71a405
Updated sync - use days from VMST and removed comments
veronikasif May 14, 2024
f7fdaad
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif May 14, 2024
5205fcd
Changes requested by coderabbitai
veronikasif May 14, 2024
cd405f6
Updated setVMSTPeriods action so it only updates periods in specific …
veronikasif May 15, 2024
87c2d0e
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif May 15, 2024
5196942
Merge branch 'main' into feat/parental-leave-sync-vmst
karenbjorg May 16, 2024
101d791
Merge branch 'main' into feat/parental-leave-sync-vmst
karenbjorg May 16, 2024
bb9f367
Merge branch 'main' into feat/parental-leave-sync-vmst
veronikasif May 16, 2024
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 @@ -36,13 +36,8 @@ export class DirectorateOfLabourResolver {
async getApplicationInformation(
@Args('applicationId') applicationId: string,
@Args('nationalId') nationalId: string,
@Args('shouldNotCall') shouldNotCall: boolean,
@CurrentUser() user: User,
): Promise<ApplicationInformation | null> {
if (shouldNotCall) {
return null
}

if (nationalId == user.nationalId) {
return this.directorateOfLabourService.getApplicationInfo(applicationId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ export class ApplicationInformationPeriod {

@Field(() => String)
firstPeriodStart!: string

@Field(() => String)
days!: string
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,7 @@ export class ParentalLeaveService extends BaseTemplateApiService {
}
} catch (e) {
this.logger.warn(
`Could not fetch applicationInformation on applicationId: {applicationId} with error: {error}`
.replace(`{${'applicationId'}}`, application.id)
.replace(`{${'error'}}`, e),
`Could not fetch applicationInformation on applicationId: ${application.id} with error: ${e}`,
)
}
}
Expand Down Expand Up @@ -1533,4 +1531,23 @@ export class ParentalLeaveService extends BaseTemplateApiService {
throw this.parseErrors(e as VMSTError)
}
}

async setVMSTPeriods({ application }: TemplateApiModuleActionProps) {
try {
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
const applicationInformation =
await this.applicationInformationAPI.applicationGetApplicationInformation(
{
applicationId: application.id,
},
)

return applicationInformation.periods
} catch (e) {
this.logger.warn(
`Could not fetch applicationInformation on applicationId: ${application.id} with error: ${e}`,
)
}

return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const NO_MULTIPLE_BIRTHS = '1'
export const MINIMUM_PERIOD_LENGTH = 14

export enum PLEvents {
MODIFY = 'MODIFY',
CLOSED = 'CLOSED',
ADDITIONALDOCUMENTSREQUIRED = 'ADDITIONALDOCUMENTSREQUIRED',
}
Expand All @@ -35,7 +34,6 @@ export type Events =
| { type: DefaultEvents.SUBMIT }
| { type: DefaultEvents.ABORT }
| { type: DefaultEvents.EDIT }
| { type: 'MODIFY' } // Ex: The user might modify their 'edits'.
| { type: 'CLOSED' } // Ex: Close application
| { type: 'ADDITIONALDOCUMENTSREQUIRED' } // Ex: VMST ask for more documents

Expand Down Expand Up @@ -68,6 +66,7 @@ export enum ApiModuleActions {
setChildrenInformation = 'setChildrenInformation',
setBirthDateForNoPrimaryParent = 'setBirthDateForNoPrimaryParent',
setBirthDate = 'setBirthDate',
setVMSTPeriods = 'setVMSTPeriods',
}

export enum StartDateOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ const Periods: FC<React.PropsWithChildren<ReviewScreenProps>> = ({
return (
<DataValue
key={`SummaryTimeline-${index}`}
label={formatMessage(
parentalLeaveFormMessages.reviewScreen.period,
{
index: index + 1,
ratio: period.ratio,
},
)}
label={period.title}
value={value}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const PeriodsRepeater: FC<React.PropsWithChildren<ScreenProps>> = ({
variables: {
applicationId: application.id,
nationalId: application.applicant,
shouldNotCall: !shouldCall,
},
skip: !shouldCall,
})

useEffect(() => {
Expand All @@ -85,7 +85,7 @@ const PeriodsRepeater: FC<React.PropsWithChildren<ScreenProps>> = ({
setRepeaterItems,
setFieldLoadingState,
)
}, [loading])
}, [loading]) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (!editable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ export const Periods = ({
return (
<DataValue
key={`SummaryTimeline-${index}`}
label={formatMessage(
parentalLeaveFormMessages.reviewScreen.period,
{
index: index + 1,
ratio: period.ratio,
},
)}
label={period.title}
value={value}
/>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react'
import parseISO from 'date-fns/parseISO'

import { Box, Icon, Text } from '@island.is/island-ui/core'
import { Box, Icon, Text, Tooltip } from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'

import { parentalLeaveFormMessages } from '../../../lib/messages'
Expand Down Expand Up @@ -31,6 +31,7 @@ export const Panel: FC<
const formatStyle = isMobile ? 'dd MMM' : 'dd MMM yyyy'
const titleLabel = isMobile ? titleSmall : title
const firstPeriodUsingActualDateOfBirth = periods?.[0]?.actualDob

return (
<Box className={styles.panel}>
<Box className={styles.panelRow}>
Expand All @@ -50,17 +51,63 @@ export const Panel: FC<

{periods.map((p, index) => (
<Box className={styles.panelRow} key={index}>
{p.canDelete && editable && onDeletePeriod && (
<Box
className={styles.deleteIcon}
onClick={() => onDeletePeriod(p.startDate)}
>
<Icon
color="dark200"
icon="removeCircle"
size="medium"
type="outline"
/>
{editable && onDeletePeriod && (
<Box className={styles.deleteIcon}>
{p.canDelete ? (
// Period can be deleted
<Tooltip
placement="right"
text={formatMessage(
parentalLeaveFormMessages.shared.deletePeriod,
)}
>
<button
type="button"
onClick={() => onDeletePeriod(p.startDate)}
>
<Icon
color="dark200"
icon="removeCircle"
size="medium"
type="outline"
/>
</button>
</Tooltip>
) : p.paid ? (
// Period can't be deleted, period paid
<Tooltip
placement="right"
text={formatMessage(
parentalLeaveFormMessages.shared.periodPaid,
)}
>
<button type="button">
<Icon
color="mint600"
icon="checkmarkCircle"
size="medium"
type="filled"
/>
</button>
</Tooltip>
) : (
// Period can't be deleted, period in progress
<Tooltip
placement="right"
text={formatMessage(
parentalLeaveFormMessages.shared.periodInProgress,
)}
>
<button type="button">
<Icon
color="mint600"
icon="checkmarkCircle"
size="medium"
type="outline"
/>
</button>
</Tooltip>
)}
</Box>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface TimelinePeriod {
color?: string
canDelete?: boolean
rawIndex: number
paid?: boolean
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
}

interface TimelineProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
buildSection,
buildSubmitField,
} from '@island.is/application/core'
import { Form } from '@island.is/application/types'
import { DefaultEvents, Form } from '@island.is/application/types'
import Logo from '../assets/Logo'
import { States as ApplicationStates } from '../constants'
import {
Expand Down Expand Up @@ -38,13 +38,13 @@ export const EditsRequireAction: Form = buildForm({
refetchApplicationAfterSubmit: true,
actions: [
{
event: 'ABORT',
event: DefaultEvents.ABORT,
name: parentalLeaveFormMessages.editFlow
.editsNotApprovedDiscardButton,
type: 'reject',
},
{
event: 'MODIFY',
event: DefaultEvents.EDIT,
name: parentalLeaveFormMessages.reviewScreen.buttonsEdit,
type: 'sign',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ export const GetApplicationInformation = gql`
query GetApplicationInformation(
$applicationId: String!
$nationalId: String!
$shouldNotCall: Boolean!
) {
getApplicationInformation(
applicationId: $applicationId
nationalId: $nationalId
shouldNotCall: $shouldNotCall
) {
periods {
from
Expand All @@ -45,6 +43,8 @@ export const GetApplicationInformation = gql`
paid
firstPeriodStart
rightsCodePeriod
days
approved
}
}
}
Expand Down
Loading
Loading