-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'paypal-tabs-flow' of github.com:juspay/hyperswitch-web …
…into paypal-tabs-flow
- Loading branch information
Showing
4 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,50 @@ | ||
@react.component | ||
let make = (~paymentType: CardThemeType.mode, ~value, ~setValue) => { | ||
let {config, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) | ||
let make = (~paymentType: CardThemeType.mode) => { | ||
open RecoilAtoms | ||
open Utils | ||
|
||
let (nickName, setNickName) = Recoil.useRecoilState(userCardNickName) | ||
let {localeString} = Recoil.useRecoilValueFromAtom(configAtom) | ||
|
||
let validateNickname = val => { | ||
let isValid = Some(val === "" || !(val->isDigitLimitExceeded(~digit=2))) | ||
let errorString = | ||
val !== "" && val->isDigitLimitExceeded(~digit=2) ? localeString.invalidNickNameError : "" | ||
|
||
(isValid, errorString) | ||
} | ||
|
||
let setNickNameState = (val, prevState: RecoilAtomTypes.field) => { | ||
let (isValid, errorString) = val->validateNickname | ||
{ | ||
...prevState, | ||
value: val, | ||
isValid, | ||
errorString, | ||
} | ||
} | ||
|
||
let onChange = ev => { | ||
let val = ReactEvent.Form.target(ev)["value"] | ||
setValue(_ => val) | ||
let val: string = ReactEvent.Form.target(ev)["value"] | ||
setNickName(prev => setNickNameState(val, prev)) | ||
} | ||
|
||
let onBlur = ev => { | ||
let val: string = ReactEvent.Focus.target(ev)["value"] | ||
setNickName(prev => setNickNameState(val, prev)) | ||
} | ||
|
||
<PaymentInputField | ||
<PaymentField | ||
fieldName=localeString.cardNickname | ||
value | ||
value=nickName | ||
setValue=setNickName | ||
onChange | ||
onBlur | ||
paymentType | ||
appearance=config.appearance | ||
type_="userCardNickName" | ||
name="userCardNickName" | ||
inputRef={React.useRef(Nullable.null)} | ||
placeholder=localeString.nicknamePlaceholder | ||
maxLength=12 | ||
/> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters