Skip to content

Commit

Permalink
refactor: comments resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanskar2001 committed Sep 4, 2024
1 parent d0a3626 commit d607d9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/CardSchemeComponent.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module CoBadgeCardSchemeDropDown = {
@react.component
let make = (~cardNumber, ~setCardBrand) => {
<select
className="w-[15px]"
className="w-4"
onChange={ev => {
let target = ev->ReactEvent.Form.target
let value = target["value"]
Expand All @@ -11,7 +11,7 @@ module CoBadgeCardSchemeDropDown = {
<option disabled=true> {"Select a card brand"->React.string} </option>
{cardNumber
->CardUtils.getCoBadgesCardSchemes
->Array.mapWithIndex((item: string, i) => {
->Array.mapWithIndex((item, i) => {
<option key={Int.toString(i)} value=item className="opacity-0 w-0 h-0">
{item->React.string}
</option>
Expand All @@ -32,6 +32,8 @@ let make = (~cardNumber, ~paymentType, ~cardBrand, ~setCardBrand, ~isCardCoBadge
)
<div className={`${animate} flex items-center`}>
cardBrandIcon
{isCardCoBadged ? <CoBadgeCardSchemeDropDown cardNumber setCardBrand /> : React.null}
<RenderIf condition={isCardCoBadged}>
<CoBadgeCardSchemeDropDown cardNumber setCardBrand />
</RenderIf>
</div>
}
4 changes: 2 additions & 2 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(isManualRetryEnabled)
let paymentToken = Recoil.useRecoilValueFromAtom(paymentTokenAtom)
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)
let isCardCoBadged = Recoil.useRecoilValueFromAtom(isCardCoBadged)

let {iframeId} = keys

Expand Down Expand Up @@ -352,13 +353,12 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
}, (isExpiryValid, isExpiryComplete(cardExpiry)))

React.useEffect(() => {
// Console.log("changing card brand" ++ cardBrand ++ cardNumber)
setCardBrand(_ => cardNumber->CardUtils.getCardBrand)
None
}, [cardNumber])

let icon = React.useMemo(() => {
<CardSchemeComponent cardNumber paymentType cardBrand setCardBrand isCardCoBadged=true />
<CardSchemeComponent cardNumber paymentType cardBrand setCardBrand isCardCoBadged />
}, (cardType, paymentType, cardBrand, cardNumber))

let cardProps: CardUtils.cardProps = (
Expand Down
4 changes: 3 additions & 1 deletion src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let make = (
let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)
let isCardCoBadged = Recoil.useRecoilValueFromAtom(RecoilAtoms.isCardCoBadged)

let (nickname, setNickname) = React.useState(_ => "")

Expand Down Expand Up @@ -218,6 +219,7 @@ let make = (
!isBancontact

let nicknameFieldClassName = conditionsForShowingSaveCardCheckbox ? "pt-2" : "pt-5"
let cardInputRightIconClassName = isCardCoBadged ? "-ml-12" : "-ml-10"

let compressedLayoutStyleForCvcError =
innerLayout === Compressed && cvcError->String.length > 0 ? "!border-l-0" : ""
Expand Down Expand Up @@ -256,7 +258,7 @@ let make = (
? "border-b-0"
: ""}
name=TestUtils.cardNoInputTestId
rightIconClassName="-ml-12"
rightIconClassName=cardInputRightIconClassName
/>
<div
className="flex flex-row w-full place-content-between"
Expand Down
1 change: 1 addition & 0 deletions src/Utilities/RecoilAtoms.res
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ let userVpaId = Recoil.atom("userVpaId", defaultFieldValues)
let userPixKey = Recoil.atom("userPixKey", defaultFieldValues)
let userPixCPF = Recoil.atom("userPixCPF", defaultFieldValues)
let userPixCNPJ = Recoil.atom("userPixCNPJ", defaultFieldValues)
let isCardCoBadged = Recoil.atom("isCardCoBadged", false)

type areOneClickWalletsRendered = {
isGooglePay: bool,
Expand Down

0 comments on commit d607d9e

Please sign in to comment.