Skip to content

Commit

Permalink
fix: paysubsidy attachment (HL-1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjturt committed Oct 10, 2023
1 parent 42cbeba commit de60caa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -37,33 +37,25 @@ const AttachmentsListView: React.FC<AttachmentsListViewProps> = ({
<div>
{attachmentItems.length > 0 && (
<$GridCell $colStart={1} $colSpan={6}>
{title && (
<$ViewFieldBold css={{ fontSize: theme.fontSize.body.m }}>
{title}
</$ViewFieldBold>
)}
{title && <$ViewFieldBold>{title}</$ViewFieldBold>}
{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}
>
<IconPaperclip
css={{ color: theme.colors.black }}
aria-label={attachment.attachmentFileName}
/>
{attachment.attachmentFileName}
<IconLinkExternal
onClick={() => handleOpenFile(attachment)}
aria-label={`${attachment.attachmentFileName}_open`}
css={{ marginLeft: theme.spacing.xs, cursor: 'pointer' }}
size="s"
/>
<IconPaperclip aria-label={attachment.attachmentFileName} />
<span css={{ textDecoration: 'underline' }}>
{attachment.attachmentFileName}
</span>
</$ViewField>
))}
</$GridCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const FormContent: React.FC<Props> = ({
getErrorMessage,
} = useFormContent(formik, fields);

const truthySubsidies = new Set([
PAY_SUBSIDY_GRANTED.GRANTED,
PAY_SUBSIDY_GRANTED.GRANTED_AGED,
]);

const theme = useTheme();
useAlertBeforeLeaving(formik.dirty);

Expand Down Expand Up @@ -513,10 +518,7 @@ const FormContent: React.FC<Props> = ({
/>
</SelectionGroup>
</$GridCell>
{[
PAY_SUBSIDY_GRANTED.GRANTED,
PAY_SUBSIDY_GRANTED.GRANTED_AGED,
].includes(formik.values.paySubsidyGranted) && (
{truthySubsidies.has(formik.values.paySubsidyGranted) && (
<$GridCell
as={$Grid}
$colSpan={12}
Expand Down Expand Up @@ -658,7 +660,7 @@ const FormContent: React.FC<Props> = ({
/>
</$GridCell>
)}
{formik.values.paySubsidyGranted && (
{truthySubsidies.has(formik.values.paySubsidyGranted) && (
<$GridCell $colSpan={12}>
<AttachmentsList
attachments={attachments}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const useApplicationForm = (): ExtendedComponentProps => {

React.useEffect(() => {
if (id) {
dispatchStep({ type: 'setActive', payload: 2 });
dispatchStep({ type: 'setActive', payload: 1 });
}
}, [id, dispatchStep]);

Expand Down

0 comments on commit de60caa

Please sign in to comment.