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 ?? ""; 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 63a14d3..79dd81d 100644 --- a/src/webapp/hooks/useSurveys.ts +++ b/src/webapp/hooks/useSurveys.ts @@ -123,8 +123,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 => {