From de60caae6e1dc9a926a1fa6d820ce7938396447e Mon Sep 17 00:00:00 2001 From: Maks Turtiainen Date: Tue, 10 Oct 2023 13:37:16 +0200 Subject: [PATCH] fix: paysubsidy attachment (HL-1009) --- .../AttachmentsListView.tsx | 26 +++++++------------ .../formContent/FormContent.tsx | 12 +++++---- .../newApplication/useApplicationForm.ts | 2 +- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/frontend/benefit/handler/src/components/attachmentsListView/AttachmentsListView.tsx b/frontend/benefit/handler/src/components/attachmentsListView/AttachmentsListView.tsx index 0b12ecd411..5e41cdcb50 100644 --- a/frontend/benefit/handler/src/components/attachmentsListView/AttachmentsListView.tsx +++ b/frontend/benefit/handler/src/components/attachmentsListView/AttachmentsListView.tsx @@ -1,5 +1,5 @@ import { ATTACHMENT_TYPES } from 'benefit-shared/constants'; -import { IconLinkExternal, IconPaperclip } from 'hds-react'; +import { IconPaperclip } from 'hds-react'; import * as React from 'react'; import { $ViewField, @@ -37,33 +37,25 @@ const AttachmentsListView: React.FC = ({
{attachmentItems.length > 0 && ( <$GridCell $colStart={1} $colSpan={6}> - {title && ( - <$ViewFieldBold css={{ fontSize: theme.fontSize.body.m }}> - {title} - - )} + {title && <$ViewFieldBold>{title}} {attachmentItems.map((attachment) => ( <$ViewField + onClick={() => handleOpenFile(attachment)} + aria-label={`${attachment.attachmentFileName}_open`} css={{ display: 'flex', alignItems: 'center', marginTop: `${theme.spacing.xs}`, fontSize: theme.fontSize.body.m, color: theme.colors.coatOfArms, + cursor: 'pointer', }} key={attachment.attachmentFileName} > - - {attachment.attachmentFileName} - handleOpenFile(attachment)} - aria-label={`${attachment.attachmentFileName}_open`} - css={{ marginLeft: theme.spacing.xs, cursor: 'pointer' }} - size="s" - /> + + + {attachment.attachmentFileName} + ))} diff --git a/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx b/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx index 90500e6ce8..cf0f3b4039 100644 --- a/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx +++ b/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx @@ -91,6 +91,11 @@ const FormContent: React.FC = ({ getErrorMessage, } = useFormContent(formik, fields); + const truthySubsidies = new Set([ + PAY_SUBSIDY_GRANTED.GRANTED, + PAY_SUBSIDY_GRANTED.GRANTED_AGED, + ]); + const theme = useTheme(); useAlertBeforeLeaving(formik.dirty); @@ -513,10 +518,7 @@ const FormContent: React.FC = ({ /> - {[ - PAY_SUBSIDY_GRANTED.GRANTED, - PAY_SUBSIDY_GRANTED.GRANTED_AGED, - ].includes(formik.values.paySubsidyGranted) && ( + {truthySubsidies.has(formik.values.paySubsidyGranted) && ( <$GridCell as={$Grid} $colSpan={12} @@ -658,7 +660,7 @@ const FormContent: React.FC = ({ /> )} - {formik.values.paySubsidyGranted && ( + {truthySubsidies.has(formik.values.paySubsidyGranted) && ( <$GridCell $colSpan={12}> { React.useEffect(() => { if (id) { - dispatchStep({ type: 'setActive', payload: 2 }); + dispatchStep({ type: 'setActive', payload: 1 }); } }, [id, dispatchStep]);