Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: date of birth log added #605

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading