Skip to content

Commit

Permalink
feat(ks-handler): show/accept/reject youth applications that have no SSN
Browse files Browse the repository at this point in the history
TODO:
 - Add UI for creating youth applications without social security number

refs YJDH-697 (handler UI for showing/accepting/rejecting)
  • Loading branch information
karisal-anders committed May 6, 2024
1 parent 097b099 commit 2e91239
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
3 changes: 3 additions & 0 deletions frontend/kesaseteli/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"title": "Hakemuksen tiedot",
"name": "Nimi",
"social_security_number": "Hlö-tunnus",
"non_vtj_birthdate": "Syntymäaika (Ei VTJ:stä!)",
"non_vtj_home_municipality": "Kotikunta (Ei VTJ:stä!)",
"postcode": "Postinumero",
"school": "Koulu",
"is_unlisted_school": "(Koulua ei löytynyt listalta)",
Expand Down Expand Up @@ -56,6 +58,7 @@
},
"vtjException": {
"notFound": "Väestötietojärjestelmästä ei löytynyt tietoja henkilötunnuksella: {{ social_security_number }}!",
"missingSsn": "Henkilötunnus puuttuu!",
"differentLastName": "Sukunimi poikkeaa hakemukselle syötetystä sukunimestä ({{ last_name }})",
"notInTargetAgeGroup": "Henkilö ei kuulu iän puolesta kohderyhmään ({{ age }}-vuotias)",
"addressNotFound": "Osoitetietoja ei löytynyt!",
Expand Down
18 changes: 15 additions & 3 deletions frontend/kesaseteli/handler/src/components/form/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ type Props = GridCellProps & {
const ActionButtons: React.FC<Props> = ({ application, ...gridCellprops }) => {
const { t } = useTranslation();
const theme = useTheme();
const { id, encrypted_handler_vtj_json } = application;
const {
id,
encrypted_handler_vtj_json,
non_vtj_birthdate,
social_security_number,
} = application;
const { confirm } = useConfirm();
const { isLoading, mutate } = useCompleteYouthApplicationQuery(id);
const isVtjEnabled = !isVtjDisabled();
Expand Down Expand Up @@ -51,6 +56,13 @@ const ActionButtons: React.FC<Props> = ({ application, ...gridCellprops }) => {
}
};

const isDisabled =
isLoading ||
// Social security number requires VTJ data for processing
(social_security_number && vtjDataNotFound) ||
// Missing social security number requires birthdate for processing
(!social_security_number && !non_vtj_birthdate);

return (
<$GridCell {...gridCellprops}>
<Button
Expand All @@ -59,7 +71,7 @@ const ActionButtons: React.FC<Props> = ({ application, ...gridCellprops }) => {
iconLeft={icon.accept}
onClick={() => complete('accept')}
isLoading={isLoading}
disabled={vtjDataNotFound || isLoading}
disabled={isDisabled}
css={`
margin-right: ${theme.spacing.l};
`}
Expand All @@ -73,7 +85,7 @@ const ActionButtons: React.FC<Props> = ({ application, ...gridCellprops }) => {
onClick={() => complete('reject')}
loadingText={t(`common:handlerApplication.saving`)}
isLoading={isLoading}
disabled={vtjDataNotFound || isLoading}
disabled={isDisabled}
>
{t(`common:handlerApplication.reject`)}
</Button>
Expand Down
30 changes: 24 additions & 6 deletions frontend/kesaseteli/handler/src/components/form/HandlerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import React from 'react';
import { $GridCell } from 'shared/components/forms/section/FormSection.sc';
import FormSectionHeading from 'shared/components/forms/section/FormSectionHeading';
import { $Notification } from 'shared/components/notification/Notification.sc';
import { convertToUIDateAndTimeFormat } from 'shared/utils/date.utils';
import {
convertToUIDateAndTimeFormat,
convertToUIDateFormat,
} from 'shared/utils/date.utils';
import { useTheme } from 'styled-components';

type Props = {
Expand All @@ -31,6 +34,8 @@ const HandlerForm: React.FC<Props> = ({ application }) => {
first_name,
last_name,
social_security_number,
non_vtj_birthdate,
non_vtj_home_municipality,
postcode,
school,
is_unlisted_school,
Expand Down Expand Up @@ -92,7 +97,21 @@ const HandlerForm: React.FC<Props> = ({ application }) => {
{!isVtjDisabled() && <VtjInfo application={application} />}
</$GridCell>
<Field type="name" value={`${first_name} ${last_name}`} />
<Field type="social_security_number" value={social_security_number} />
{social_security_number && (
<Field type="social_security_number" value={social_security_number} />
)}
{non_vtj_birthdate && (
<Field
type="non_vtj_birthdate"
value={convertToUIDateFormat(non_vtj_birthdate)}
/>
)}
{non_vtj_home_municipality && (
<Field
type="non_vtj_home_municipality"
value={non_vtj_home_municipality}
/>
)}
<Field type="postcode" value={postcode} />
<Field
type="school"
Expand Down Expand Up @@ -135,10 +154,9 @@ const HandlerForm: React.FC<Props> = ({ application }) => {
</>
)}
{waitingForHandlerAction ? (
<ActionButtons
application={application}
$rowSpan={additionalInfoProvided ? 12 : 8}
/>
<$GridCell $colSpan={2}>
<ActionButtons application={application} />
</$GridCell>
) : (
<$GridCell>
<$Notification
Expand Down
4 changes: 4 additions & 0 deletions frontend/kesaseteli/handler/src/components/form/VtjInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const VtjInfo: React.FC<Props> = ({ application }) => {
postcode,
} = application;

if (!social_security_number) {
return <VtjErrorNotification reason="missingSsn" type="error" />;
}

if (!vtjData || !('Henkilo' in vtjData)) {
return (
<VtjErrorNotification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const VTJ_EXCEPTIONS = [
'notFound',
'missingSsn',
'differentLastName',
'notInTargetAgeGroup',
'addressNotFound',
Expand Down
2 changes: 2 additions & 0 deletions frontend/kesaseteli/shared/src/types/youth-application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ type YouthApplication = {
first_name: string;
last_name: string;
social_security_number: string;
non_vtj_birthdate?: Date;
non_vtj_home_municipality?: string;
postcode: string;
school?: string;
is_unlisted_school: boolean;
Expand Down
1 change: 1 addition & 0 deletions frontend/shared/src/utils/mask-gdpr-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ATTRIBUTES_TO_MASK = [
'employee_name',
'employee_ssn',
'employee_phone_number',
'non_vtj_birthdate',
// benefit attributes
'lastName',
'phoneNumber',
Expand Down

0 comments on commit 2e91239

Please sign in to comment.