From 0939fa4afab9f290e41b63f9bbe50f2ac12dae14 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Wed, 6 Nov 2024 10:31:50 +1030 Subject: [PATCH] Temporarily remove removeEmptyAnswersFromResponse across the entire app --- .../components/FormPreviewPage/FormPreview.tsx | 15 ++++++++------- .../RendererNav/BlockerUnsavedFormDialog.tsx | 15 ++++++++------- .../tokenTimer/components/AutoSaveDialog.tsx | 17 ++++++++--------- .../tokenTimer/components/TokenTimerDialog.tsx | 16 +++++++--------- .../src/features/viewer/ResponsePreview.tsx | 9 ++------- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/apps/smart-forms-app/src/features/renderer/components/FormPreviewPage/FormPreview.tsx b/apps/smart-forms-app/src/features/renderer/components/FormPreviewPage/FormPreview.tsx index 5309c25db..a37f1b196 100644 --- a/apps/smart-forms-app/src/features/renderer/components/FormPreviewPage/FormPreview.tsx +++ b/apps/smart-forms-app/src/features/renderer/components/FormPreviewPage/FormPreview.tsx @@ -21,11 +21,7 @@ import parse from 'html-react-parser'; import { qrToHTML } from '../../../preview/utils/preview.ts'; import { Helmet } from 'react-helmet'; import PageHeading from '../../../dashboard/components/DashboardPages/PageHeading.tsx'; -import { - removeEmptyAnswersFromResponse, - useQuestionnaireResponseStore, - useQuestionnaireStore -} from '@aehrc/smart-forms-renderer'; +import { useQuestionnaireResponseStore, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; function FormPreview() { const sourceQuestionnaire = useQuestionnaireStore.use.sourceQuestionnaire(); @@ -39,8 +35,13 @@ function FormPreview() { return ; } - const cleanResponse = removeEmptyAnswersFromResponse(sourceQuestionnaire, updatableResponse); - const parsedHTML = parse(qrToHTML(sourceQuestionnaire, cleanResponse)); + // Temporarily comment out this line to avoid saving errors + // const cleanResponse = removeEmptyAnswersFromResponse( + // questionnaire, + // updatableResponse + // ); + + const parsedHTML = parse(qrToHTML(sourceQuestionnaire, updatableResponse)); return ( <> diff --git a/apps/smart-forms-app/src/features/renderer/components/RendererNav/BlockerUnsavedFormDialog.tsx b/apps/smart-forms-app/src/features/renderer/components/RendererNav/BlockerUnsavedFormDialog.tsx index 01324c776..87b730a12 100644 --- a/apps/smart-forms-app/src/features/renderer/components/RendererNav/BlockerUnsavedFormDialog.tsx +++ b/apps/smart-forms-app/src/features/renderer/components/RendererNav/BlockerUnsavedFormDialog.tsx @@ -28,11 +28,7 @@ import { } from '@mui/material'; import { saveQuestionnaireResponse } from '../../../../api/saveQr.ts'; import { LoadingButton } from '@mui/lab'; -import { - removeEmptyAnswersFromResponse, - useQuestionnaireResponseStore, - useQuestionnaireStore -} from '@aehrc/smart-forms-renderer'; +import { useQuestionnaireResponseStore, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; import useSmartClient from '../../../../hooks/useSmartClient.ts'; export interface Props { @@ -77,8 +73,13 @@ function BlockerUnsavedFormDialog(props: Props) { setIsSaving(true); - let responseToSave = structuredClone(updatableResponse); - responseToSave = removeEmptyAnswersFromResponse(sourceQuestionnaire, responseToSave); + const responseToSave = structuredClone(updatableResponse); + + // Temporarily comment out this line to avoid saving errors + // responseToSave = removeEmptyAnswersFromResponse( + // questionnaire, + // responseToSave + // ); setIsSaving(true); responseToSave.status = 'in-progress'; diff --git a/apps/smart-forms-app/src/features/tokenTimer/components/AutoSaveDialog.tsx b/apps/smart-forms-app/src/features/tokenTimer/components/AutoSaveDialog.tsx index da9c4a9dc..5a937ef4f 100644 --- a/apps/smart-forms-app/src/features/tokenTimer/components/AutoSaveDialog.tsx +++ b/apps/smart-forms-app/src/features/tokenTimer/components/AutoSaveDialog.tsx @@ -17,11 +17,7 @@ import { useEffect } from 'react'; import { Dialog, DialogContent, DialogContentText, DialogTitle } from '@mui/material'; -import { - removeEmptyAnswersFromResponse, - useQuestionnaireResponseStore, - useQuestionnaireStore -} from '@aehrc/smart-forms-renderer'; +import { useQuestionnaireResponseStore, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; import { saveQuestionnaireResponse } from '../../../api/saveQr.ts'; import { useSnackbar } from 'notistack'; import useSmartClient from '../../../hooks/useSmartClient.ts'; @@ -54,10 +50,13 @@ function AutoSaveDialog(props: AutoSaveDialogProps) { return; } - const responseToSave = removeEmptyAnswersFromResponse( - sourceQuestionnaire, - structuredClone(updatableResponse) - ); + // Temporarily comment out this line to avoid saving errors + // const responseToSave = removeEmptyAnswersFromResponse( + // questionnaire, + // structuredClone(updatableResponse) + // ); + + const responseToSave = structuredClone(updatableResponse); responseToSave.status = 'in-progress'; saveQuestionnaireResponse(smartClient, patient, user, sourceQuestionnaire, responseToSave) diff --git a/apps/smart-forms-app/src/features/tokenTimer/components/TokenTimerDialog.tsx b/apps/smart-forms-app/src/features/tokenTimer/components/TokenTimerDialog.tsx index 8c2566f83..1612abe34 100644 --- a/apps/smart-forms-app/src/features/tokenTimer/components/TokenTimerDialog.tsx +++ b/apps/smart-forms-app/src/features/tokenTimer/components/TokenTimerDialog.tsx @@ -29,11 +29,7 @@ import { Tooltip } from '@mui/material'; import { LoadingButton } from '@mui/lab'; -import { - removeEmptyAnswersFromResponse, - useQuestionnaireResponseStore, - useQuestionnaireStore -} from '@aehrc/smart-forms-renderer'; +import { useQuestionnaireResponseStore, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; import ReadMoreIcon from '@mui/icons-material/ReadMore'; import { saveQuestionnaireResponse } from '../../../api/saveQr.ts'; import useSmartClient from '../../../hooks/useSmartClient.ts'; @@ -75,10 +71,12 @@ function TokenTimerDialog(props: TokenTimerDialogProps) { } setIsSaving(true); - const responseToSave = removeEmptyAnswersFromResponse( - sourceQuestionnaire, - structuredClone(updatableResponse) - ); + const responseToSave = structuredClone(updatableResponse); + // Temporarily comment out this line to avoid saving errors + // const responseToSave = removeEmptyAnswersFromResponse( + // sourceQuestionnaire, + // structuredClone(updatableResponse) + // ); responseToSave.status = 'in-progress'; saveQuestionnaireResponse(smartClient, patient, user, sourceQuestionnaire, responseToSave) diff --git a/apps/smart-forms-app/src/features/viewer/ResponsePreview.tsx b/apps/smart-forms-app/src/features/viewer/ResponsePreview.tsx index 4896e3ca6..0d3884401 100644 --- a/apps/smart-forms-app/src/features/viewer/ResponsePreview.tsx +++ b/apps/smart-forms-app/src/features/viewer/ResponsePreview.tsx @@ -23,11 +23,7 @@ import parse from 'html-react-parser'; import { qrToHTML } from '../preview/utils/preview.ts'; import { Helmet } from 'react-helmet'; import PageHeading from '../dashboard/components/DashboardPages/PageHeading.tsx'; -import { - removeEmptyAnswersFromResponse, - useQuestionnaireResponseStore, - useQuestionnaireStore -} from '@aehrc/smart-forms-renderer'; +import { useQuestionnaireResponseStore, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; function ResponsePreview() { const { setComponentRef } = useContext(PrintComponentRefContext); @@ -49,8 +45,7 @@ function ResponsePreview() { return ; } - const responseCleaned = removeEmptyAnswersFromResponse(sourceQuestionnaire, sourceResponse); - const parsedHTML = parse(qrToHTML(sourceQuestionnaire, responseCleaned)); + const parsedHTML = parse(qrToHTML(sourceQuestionnaire, sourceResponse)); return ( <>