Skip to content

Commit

Permalink
Merge branch 'main' into feat/mms-siblings-page-relation-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
hfhelgason committed Jan 10, 2025
2 parents d4f6a2a + 4dbc264 commit 9b9bd06
Show file tree
Hide file tree
Showing 47 changed files with 578 additions and 307 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const createIndictment = async (
lowercase(theCase.prosecutorsOffice?.name)
.replace('lögreglustjórinn', 'lögreglustjórans')
.replace('saksóknari', 'saksóknara') ?? '',
date: formatDate(nowFactory(), 'PPP'),
date: formatDate(confirmation?.date || nowFactory(), 'PPP'),
}),
)

Expand Down
2 changes: 2 additions & 0 deletions libs/application/core/src/lib/fieldBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const extractCommonFields = (
nextButtonText,
marginBottom,
marginTop,
clearOnChange,
} = data

return {
Expand All @@ -91,6 +92,7 @@ const extractCommonFields = (
nextButtonText,
marginBottom,
marginTop,
clearOnChange,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ export const transformApplicationToNewPrimarySchoolDTO = (
phone: relative.phoneNumber,
role: relative.relation,
})),
// TODO: Skoða hvernig ég veit hvaða ástæða var valin (ég er ekki með lista yfir ástæður)
...(reasonForApplication ===
ReasonForApplicationOptions.SIBLINGS_IN_THE_SAME_PRIMARY_SCHOOL
ReasonForApplicationOptions.SIBLINGS_IN_SAME_SCHOOL
? siblings.map((sibling) => ({
name: sibling.fullName,
nationalId: sibling.nationalId,
// TODO: Siblings relation options are not in the key-options endpoint => Júní has added "sibling" (We need to make sure that those options do not appear in the dropdown on the relatives page)
// TODO: We are waiting for a reply from MMS if this is important information or if we should remove it
role: 'sibling',
}))
: []),
Expand Down Expand Up @@ -113,7 +114,6 @@ export const transformApplicationToNewPrimarySchoolDTO = (
},
agents,
registration: {
// TODO: Skoða hvernig ég veit hvaða ástæða var valin (ég er ekki með lista yfir ástæður)
defaultOrg: primaryOrgId,
...(reasonForApplication !== ReasonForApplicationOptions.MOVING_ABROAD
? {
Expand All @@ -126,7 +126,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
}),
reason: reasonForApplication,
...(reasonForApplication ===
ReasonForApplicationOptions.TRANSFER_OF_LEGAL_DOMICILE
ReasonForApplicationOptions.MOVING_MUNICIPALITY
? {
newDomicile: {
address: reasonForApplicationStreetAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FriggOptionsAsyncSelectField: FC<
> = ({ error, field, application }) => {
const { lang } = useLocale()
const { title, props, defaultValue, id } = field
const { isMulti = true, optionsType, placeholder } = props
const { isMulti = false, optionsType, placeholder } = props

return (
<AsyncSelectFormField
Expand Down Expand Up @@ -58,7 +58,7 @@ const FriggOptionsAsyncSelectField: FC<
},
})

return (
const options =
data?.friggOptions?.flatMap(({ options }) =>
options.flatMap(({ value, key }) => {
let content = value.find(
Expand All @@ -72,7 +72,16 @@ const FriggOptionsAsyncSelectField: FC<
return { value: key ?? '', label: content ?? '' }
}),
) ?? []

const otherIndex = options.findIndex(
(option) => option.value === 'other',
)

if (otherIndex >= 0) {
options.push(options.splice(otherIndex, 1)[0])
}

return options
},
isMulti,
backgroundColor: 'blue',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const RelativesTableRepeater: FC<React.PropsWithChildren<FieldBaseProps>> = ({
}) => {
const { id, title } = field

const relationFriggOptions = useFriggOptions(OptionsType.RELATION)
const { options: relationFriggOptions } = useFriggOptions(
OptionsType.RELATION,
)

return (
<TableRepeaterFormField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const Review: FC<ReviewScreenProps> = ({
{reasonForApplication !== ReasonForApplicationOptions.MOVING_ABROAD && (
<>
{reasonForApplication ===
ReasonForApplicationOptions.SIBLINGS_IN_THE_SAME_PRIMARY_SCHOOL && (
ReasonForApplicationOptions.SIBLINGS_IN_SAME_SCHOOL && (
<Siblings {...childProps} />
)}
<School {...childProps} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { coreErrorMessages } from '@island.is/application/core'
import { YES } from '@island.is/application/types'
import { DataValue, ReviewGroup } from '@island.is/application/ui-components'
import { GridColumn, GridRow, Stack, Text } from '@island.is/island-ui/core'
import {
GridColumn,
GridRow,
SkeletonLoader,
Stack,
Text,
} from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { format as formatKennitala } from 'kennitala'
import { useFriggOptions } from '../../../hooks/useFriggOptions'
import { OptionsType } from '../../../lib/constants'
import { newPrimarySchoolMessages } from '../../../lib/messages'
import {
getApplicationAnswers,
getSelectedOptionLabel,
} from '../../../lib/newPrimarySchoolUtils'
import { ReviewGroupProps } from './props'
import { useFriggOptions } from '../../../hooks/useFriggOptions'
import { OptionsType } from '../../../lib/constants'

export const Child = ({
application,
Expand All @@ -22,7 +29,11 @@ export const Child = ({
application.answers,
)

const pronounOptions = useFriggOptions(OptionsType.PRONOUN)
const {
options: pronounOptions,
loading,
error,
} = useFriggOptions(OptionsType.PRONOUN)

return (
<ReviewGroup
Expand All @@ -37,77 +48,93 @@ export const Child = ({
</Text>
</GridColumn>
</GridRow>
<GridRow rowGap={2}>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(newPrimarySchoolMessages.shared.fullName)}
value={childInfo.name}
/>
</GridColumn>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(newPrimarySchoolMessages.shared.nationalId)}
value={formatKennitala(childInfo.nationalId)}
/>
</GridColumn>
</GridRow>
<GridRow rowGap={2}>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(newPrimarySchoolMessages.shared.address)}
value={childInfo.address.streetAddress}
/>
</GridColumn>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.shared.municipality,
)}
value={`${childInfo.address.postalCode}, ${childInfo.address.city}`}
/>
</GridColumn>
</GridRow>
{(childInfo.preferredName ||
childInfo.pronouns?.length > 0 ||
differentPlaceOfResidence === YES) && (
<GridRow rowGap={2}>
{childInfo.preferredName && (
{childInfo.pronouns?.length > 0 && loading ? (
<SkeletonLoader height={40} width="100%" borderRadius="large" />
) : (
<>
<GridRow rowGap={2}>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents
.childInfoPreferredName,
newPrimarySchoolMessages.shared.fullName,
)}
value={childInfo.preferredName}
value={childInfo.name}
/>
</GridColumn>
)}
{childInfo.pronouns?.length > 0 && (
<GridColumn span={['12/12', '12/12', '12/12', '12/12']}>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents.childInfoPronouns,
newPrimarySchoolMessages.shared.nationalId,
)}
value={childInfo.pronouns
.map((pronoun) =>
getSelectedOptionLabel(pronounOptions, pronoun),
)
.join(', ')}
value={formatKennitala(childInfo.nationalId)}
/>
</GridColumn>
</GridRow>
<GridRow rowGap={2}>
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(newPrimarySchoolMessages.shared.address)}
value={childInfo.address.streetAddress}
/>
</GridColumn>
)}
{differentPlaceOfResidence === YES && (
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents
.childInfoPlaceOfResidence,
newPrimarySchoolMessages.shared.municipality,
)}
value={`${childInfo.placeOfResidence?.streetAddress}, ${childInfo.placeOfResidence?.postalCode}`}
value={`${childInfo.address.postalCode}, ${childInfo.address.city}`}
/>
</GridColumn>
</GridRow>
{(childInfo.preferredName?.trim().length > 0 ||
childInfo.pronouns?.length > 0 ||
differentPlaceOfResidence === YES) && (
<GridRow rowGap={2}>
{childInfo.preferredName?.trim().length > 0 && (
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents
.childInfoPreferredName,
)}
value={childInfo.preferredName}
/>
</GridColumn>
)}
{childInfo.pronouns?.length > 0 && (
<GridColumn span={['12/12', '12/12', '12/12', '12/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents
.childInfoPronouns,
)}
value={childInfo.pronouns
.map((pronoun) =>
getSelectedOptionLabel(pronounOptions, pronoun),
)
.join(', ')}
error={
error
? formatMessage(coreErrorMessages.failedDataProvider)
: undefined
}
/>
</GridColumn>
)}
{differentPlaceOfResidence === YES && (
<GridColumn span={['12/12', '12/12', '12/12', '5/12']}>
<DataValue
label={formatMessage(
newPrimarySchoolMessages.childrenNParents
.childInfoPlaceOfResidence,
)}
value={`${childInfo.placeOfResidence?.streetAddress}, ${childInfo.placeOfResidence?.postalCode}`}
/>
</GridColumn>
)}
</GridRow>
)}
</GridRow>
</>
)}
</Stack>
</ReviewGroup>
Expand Down
Loading

0 comments on commit 9b9bd06

Please sign in to comment.