From 3cbc6adf289b0144afc83245c17956c901f3f965 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 8 Jul 2024 13:09:52 +0530 Subject: [PATCH 1/8] fix: date of birth null value --- src/Payments/DateOfBirth.res | 28 ++++++++++++++++++++++++++++ src/Utilities/DynamicFieldsUtils.res | 14 +++++++++++--- src/Utilities/RecoilAtoms.res | 2 +- src/libraries/DatePicker.res | 4 ++-- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/Payments/DateOfBirth.res b/src/Payments/DateOfBirth.res index c1637f260..e53d31825 100644 --- a/src/Payments/DateOfBirth.res +++ b/src/Payments/DateOfBirth.res @@ -21,8 +21,23 @@ let years = Array.fromInitializer(~length=currentYear - startYear, i => currentY @react.component let make = () => { + open Utils let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) let (selectedDate, setSelectedDate) = Recoil.useRecoilState(RecoilAtoms.dateOfBirth) + let (error, setError) = React.useState(_ => false) + + let submitCallback = React.useCallback((ev: Window.event) => { + let json = ev.data->JSON.parseExn + let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper + if confirm.doSubmit { + switch selectedDate->Nullable.toOption { + | Some(_) => setError(_ => false) + | None => setError(_ => true) + } + } + }, [selectedDate]) + + useSubmitPaymentData(submitCallback)
{ onChange={date => setSelectedDate(_ => date)} dateFormat="dd-MM-yyyy" wrapperClassName="datepicker" + placeholderText="Enter Date of Birth" renderCustomHeader={val => {