From 71b3e6beb76b573128117a7bdfe9032a16075b97 Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Sat, 23 Nov 2024 23:01:26 +0530 Subject: [PATCH 1/2] fix: handle invalid date in date fields --- .../entities/Questionnaire/QuestionnaireRules.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/domain/entities/Questionnaire/QuestionnaireRules.ts b/src/domain/entities/Questionnaire/QuestionnaireRules.ts index c9d5cd8..7051d5c 100644 --- a/src/domain/entities/Questionnaire/QuestionnaireRules.ts +++ b/src/domain/entities/Questionnaire/QuestionnaireRules.ts @@ -81,10 +81,17 @@ export const getQuestionValueByType = (question: Question): string => { case "boolean": return question.value === undefined ? "false" : question.value.toString(); case "date": - return question.value?.toISOString().split("T")[0] ?? ""; + try { + return question.value?.toISOString().split("T")[0] ?? ""; + } catch (e) { + return ""; //Handle invalid date + } case "datetime": - return question.value?.toString() ?? ""; - + try { + return question.value?.toString() ?? ""; + } catch (e) { + return ""; //Handle invalid date + } case "number": case "text": return question.value ?? ""; From 471fe7413ff95798c123253336a4321d55261db0 Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Sun, 24 Nov 2024 00:00:46 +0530 Subject: [PATCH 2/2] fix: white screen fix --- .../components/survey-list/table/SurveyListTable.tsx | 7 ++++--- src/webapp/hooks/useSurveys.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/webapp/components/survey-list/table/SurveyListTable.tsx b/src/webapp/components/survey-list/table/SurveyListTable.tsx index b1a647b..db463a3 100644 --- a/src/webapp/components/survey-list/table/SurveyListTable.tsx +++ b/src/webapp/components/survey-list/table/SurveyListTable.tsx @@ -300,9 +300,10 @@ export const SurveyListTable: React.FC = ({ {survey.name} )} - {SURVEYS_WITH_CHILD_COUNT.includes(surveyFormType) && ( - {survey.childCount as number} - )} + {SURVEYS_WITH_CHILD_COUNT.includes(surveyFormType) && + typeof survey.childCount === "number" && ( + {survey.childCount} + )} { diff --git a/src/webapp/hooks/useSurveys.ts b/src/webapp/hooks/useSurveys.ts index d6dc73f..4357398 100644 --- a/src/webapp/hooks/useSurveys.ts +++ b/src/webapp/hooks/useSurveys.ts @@ -122,8 +122,8 @@ export function useSurveys(surveyFormType: SURVEY_FORM_TYPES) { compositionRoot.surveys.getSurveys .execute(surveyFormType, orgUnitId, parentSurveyId, makeChunkedCall) .run( - surveys => { - setSurveys(surveys); + nonPaginatedSurveys => { + setSurveys(nonPaginatedSurveys); setLoadingSurveys(false); }, err => {