From 2fe76aa2fd7379d322fb094e483e80e9345e66e9 Mon Sep 17 00:00:00 2001 From: alaa-yahia Date: Tue, 26 Nov 2024 14:28:06 +0200 Subject: [PATCH] fix: error when date is null result in runtime error --- src/core_modules/capture-core/converters/formToClient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core_modules/capture-core/converters/formToClient.js b/src/core_modules/capture-core/converters/formToClient.js index adca6b5b72..61c286d4d2 100644 --- a/src/core_modules/capture-core/converters/formToClient.js +++ b/src/core_modules/capture-core/converters/formToClient.js @@ -24,8 +24,8 @@ function convertDateTime(formValue: DateTimeValue): ?string { const hours = momentTime.hour(); const minutes = momentTime.minute(); - const parsedDate = parseDate(editedDate); - if (!parsedDate.isValid) return null; + const parsedDate = editedDate ? parseDate(editedDate) : null; + if (!(parsedDate && parsedDate.isValid)) return null; // $FlowFixMe[incompatible-type] automated comment const momentDateTime: moment$Moment = parsedDate.momentDate; momentDateTime.hour(hours);