From 96628aa3b4dd5abae00b429486139431a8b3bf05 Mon Sep 17 00:00:00 2001 From: Kathleen Koh Date: Wed, 3 Apr 2024 00:16:14 +0800 Subject: [PATCH 1/2] fix: correcting submission button bug for MRF --- .../components/FormEndPage/FormEndPage.tsx | 8 +++++++- .../FormEndPage/components/EndPageBlock.tsx | 12 ++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/frontend/src/features/public-form/components/FormEndPage/FormEndPage.tsx b/frontend/src/features/public-form/components/FormEndPage/FormEndPage.tsx index c3eb632e64..0be32c2a16 100644 --- a/frontend/src/features/public-form/components/FormEndPage/FormEndPage.tsx +++ b/frontend/src/features/public-form/components/FormEndPage/FormEndPage.tsx @@ -2,7 +2,10 @@ import { Container, Flex, Stack, StackDivider } from '@chakra-ui/react' import { FormColorTheme, FormDto } from '~shared/types/form' -import { SubmissionData } from '~features/public-form/PublicFormContext' +import { + SubmissionData, + usePublicFormContext, +} from '~features/public-form/PublicFormContext' import { EndPageBlock } from './components/EndPageBlock' import { FeedbackBlock, FeedbackFormInput } from './components/FeedbackBlock' @@ -23,6 +26,8 @@ export const FormEndPage = ({ colorTheme, ...endPageProps }: FormEndPageProps): JSX.Element => { + const { previousSubmissionId } = usePublicFormContext() + return ( @@ -39,6 +44,7 @@ export const FormEndPage = ({ focusOnMount {...endPageProps} colorTheme={colorTheme} + isButtonHidden={!!previousSubmissionId} /> {isFeedbackSectionHidden ? null : ( { const focusRef = useRef(null) useEffect(() => { @@ -56,9 +55,6 @@ export const EndPageBlock = ({ return 'You have successfully submitted your response.' }, [formTitle]) - const { previousSubmissionId } = usePublicFormContext() - const disableSubmitResponseButton = !!previousSubmissionId //disable for MRF 2nd respondent onwards - return ( <> @@ -86,7 +82,7 @@ export const EndPageBlock = ({ - {disableSubmitResponseButton || ( + {isButtonHidden || (