From 8a23e178c2b1496dc2a9efc578145563ed15314b Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Tue, 22 Oct 2024 22:44:27 +0530 Subject: [PATCH] fix: parse index in risk custom question --- src/webapp/pages/form-page/mapFormStateToEntityData.ts | 4 ++-- .../risk-assessment/mapRiskAssessmentToInitialFormState.ts | 2 +- src/webapp/pages/form-page/useForm.ts | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/webapp/pages/form-page/mapFormStateToEntityData.ts b/src/webapp/pages/form-page/mapFormStateToEntityData.ts index 00c4f74..1ff9e1c 100644 --- a/src/webapp/pages/form-page/mapFormStateToEntityData.ts +++ b/src/webapp/pages/form-page/mapFormStateToEntityData.ts @@ -460,9 +460,9 @@ function mapFormStateToRiskAssessmentQuestionnaire( formData.options, index.toString() ); - const idWithoutIdentifier = customSection.id.replace("additionalQuestions", ""); + return { - id: idWithoutIdentifier.length < 11 ? "" : idWithoutIdentifier, //TO DO : Temp fix + id: customSection.id.replace("additionalQuestions", "").replace(`_${index}`, ""), question: allFields.find(field => field.id.includes(`custom-question${index}`)) ?.value as string, likelihood: likelihoodOption, diff --git a/src/webapp/pages/form-page/risk-assessment/mapRiskAssessmentToInitialFormState.ts b/src/webapp/pages/form-page/risk-assessment/mapRiskAssessmentToInitialFormState.ts index 8114f08..26c7913 100644 --- a/src/webapp/pages/form-page/risk-assessment/mapRiskAssessmentToInitialFormState.ts +++ b/src/webapp/pages/form-page/risk-assessment/mapRiskAssessmentToInitialFormState.ts @@ -754,7 +754,7 @@ function getRiskAssessmentCustomQuestionSection( options; const riskAssesssmentQuestionFormSection: FormSectionState = { title: title, - id: questionId ? `${id}${questionId}` : `${id}${index}`, + id: questionId ? `${id}${questionId}` : `${id}_${index}`, isVisible: true, fields: [ { diff --git a/src/webapp/pages/form-page/useForm.ts b/src/webapp/pages/form-page/useForm.ts index 01a2e6e..80945f9 100644 --- a/src/webapp/pages/form-page/useForm.ts +++ b/src/webapp/pages/form-page/useForm.ts @@ -67,9 +67,6 @@ export function useForm(formType: FormType, id?: Id): State { const currentEventTracker = getCurrentEventTracker(); useEffect(() => { - // if (currentEventTracker?.id && currentEventTrackerState?.id === currentEventTracker?.id) - // return; - compositionRoot.getWithOptions.execute(formType, currentEventTracker, id).run( formData => { setConfigurableForm(formData);