From 369d3b860bb85464f11ada0dce7f0fdb1dd86b86 Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Fri, 4 Aug 2023 11:01:56 +0300 Subject: [PATCH] feat: p2p/ahjo inspection inputs are shown based on radio selection --- .../BatchActionsInspectionForm.tsx | 116 +++++++++++++----- 1 file changed, 86 insertions(+), 30 deletions(-) diff --git a/frontend/benefit/handler/src/components/batchProcessing/BatchActionsInspectionForm.tsx b/frontend/benefit/handler/src/components/batchProcessing/BatchActionsInspectionForm.tsx index 5c9f06d3cc..4338db5df9 100644 --- a/frontend/benefit/handler/src/components/batchProcessing/BatchActionsInspectionForm.tsx +++ b/frontend/benefit/handler/src/components/batchProcessing/BatchActionsInspectionForm.tsx @@ -5,10 +5,16 @@ import { PROPOSALS_FOR_DECISION, } from 'benefit-shared/constants'; import { BatchProposal } from 'benefit-shared/types/application'; -import { Button, DateInput, IconArrowUndo, TextInput } from 'hds-react'; +import { + Button, + DateInput, + IconArrowUndo, + RadioButton, + TextInput, +} from 'hds-react'; import noop from 'lodash/noop'; import { useTranslation } from 'next-i18next'; -import React from 'react'; +import React, { ChangeEvent } from 'react'; import { $GridCell } from 'shared/components/forms/section/FormSection.sc'; import Modal from 'shared/components/modal/Modal'; @@ -33,7 +39,8 @@ const BatchActionsInspectionForm: React.FC = ({ isInspectionFormSent, setInspectionFormSent, setBatchCloseAnimation, -}: BatchProps) => { +}: // eslint-disable-next-line sonarjs/cognitive-complexity +BatchProps) => { const { id, proposal_for_decision: proposalForDecision } = batch; const { t } = useTranslation(); const { formik, yearFromNow, isSuccess, isError } = useBatchActionsInspected( @@ -46,6 +53,8 @@ const BatchActionsInspectionForm: React.FC = ({ const [isModalBatchToCompletion, setModalBatchToCompletion] = React.useState(false); + const [inspectorMode, setInspectorMode] = React.useState('ahjo'); + React.useEffect(() => { if (isError) { setInspectionFormSent(false); @@ -82,6 +91,10 @@ const BatchActionsInspectionForm: React.FC = ({ return false; }); + const handleRadioButton = (event: ChangeEvent): void => { + setInspectorMode(event.target.value); + }; + const handleSubmit = (e: React.FormEvent): void => { e.preventDefault(); formik @@ -118,6 +131,33 @@ const BatchActionsInspectionForm: React.FC = ({ return ( <> + {proposalForDecision === PROPOSALS_FOR_DECISION.ACCEPTED ? ( + <$FormSection> + <$GridCell $colSpan={2}> + + + <$GridCell $colSpan={2}> + + + + ) : null} + = ({ - <$FormSection> - <$GridCell $colSpan={3}> - - + {proposalForDecision === PROPOSALS_FOR_DECISION.ACCEPTED && + inspectorMode === 'ahjo' ? ( + <$FormSection> + <$GridCell $colSpan={3}> + + - <$GridCell $colSpan={3}> - - - + <$GridCell $colSpan={3}> + + + <$GridCell $colSpan={3}> + + + + ) : null} - {proposalForDecision === PROPOSALS_FOR_DECISION.ACCEPTED ? ( + {proposalForDecision === PROPOSALS_FOR_DECISION.ACCEPTED && + inspectorMode === 'p2p' ? ( <$FormSection css="border-top: 1pox solid #000;"> <$GridCell $colSpan={3}>