Skip to content

Commit

Permalink
refactor: date of birth log added (#605)
Browse files Browse the repository at this point in the history
Co-authored-by: Saksham Sharma <[email protected]>
Co-authored-by: Pritish Budhiraja <[email protected]>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent bddeb86 commit 36e4ee5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/Payments/DateOfBirth.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ let years = Array.fromInitializer(~length=currentYear - startYear, i => currentY
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 (isNotEligible, setIsNotEligible) = React.useState(_ => false)
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let (dateOfBirth, setDateOfBirth) = Recoil.useLoggedRecoilState(
RecoilAtoms.dateOfBirth,
"dateOfBirth",
loggerState,
)

let submitCallback = React.useCallback((ev: Window.event) => {
let json = ev.data->safeParse
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit {
switch selectedDate->Nullable.toOption {
switch dateOfBirth->Nullable.toOption {
| Some(_) => setError(_ => false)
| None => ()
}
}
}, (selectedDate, isNotEligible))
}, (dateOfBirth, isNotEligible))

useSubmitPaymentData(submitCallback)

Expand All @@ -45,7 +50,7 @@ let make = () => {
| Some(val) => val->checkIs18OrAbove
| None => false
}
setSelectedDate(_ => date)
setDateOfBirth(_ => date)
setIsNotEligible(_ => !isAbove18)
}

Expand All @@ -67,7 +72,7 @@ let make = () => {
showIcon=true
icon={<Icon name="calander" size=13 className="!px-[6px] !py-[10px]" />}
className="w-full border border-gray-300 rounded p-2"
selected={selectedDate}
selected={dateOfBirth}
onChange
dateFormat="dd-MM-yyyy"
wrapperClassName="datepicker"
Expand Down
6 changes: 5 additions & 1 deletion src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ let useSetInitialRequiredFields = (
let (cryptoCurrencyNetworks, setCryptoCurrencyNetworks) = Recoil.useRecoilState(
cryptoCurrencyNetworks,
)
let (dateOfBirth, setDateOfBirth) = Recoil.useRecoilState(dateOfBirth)
let (dateOfBirth, setDateOfBirth) = Recoil.useLoggedRecoilState(
dateOfBirth,
"dateOfBirth",
logger,
)

React.useEffect(() => {
let getNameValue = (item: PaymentMethodsRecord.required_fields) => {
Expand Down

0 comments on commit 36e4ee5

Please sign in to comment.