-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for cobadged cards
- Loading branch information
1 parent
3c82cfb
commit a974990
Showing
8 changed files
with
73 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module CoBadgeCardSchemeDropDown = { | ||
@react.component | ||
let make = (~cardNumber, ~setCardBrand) => { | ||
<select | ||
className="w-[15px]" | ||
onChange={ev => { | ||
let target = ev->ReactEvent.Form.target | ||
let value = target["value"] | ||
setCardBrand(_ => value) | ||
}}> | ||
<option disabled=true> {"Select a card brand"->React.string} </option> | ||
{cardNumber | ||
->CardUtils.getCoBadgesCardSchemes | ||
->Array.mapWithIndex((item: string, i) => { | ||
<option key={Int.toString(i)} value=item className="opacity-0 w-0 h-0"> | ||
{item->React.string} | ||
</option> | ||
}) | ||
->React.array} | ||
</select> | ||
} | ||
} | ||
|
||
@react.component | ||
let make = (~cardNumber, ~paymentType, ~cardBrand, ~setCardBrand, ~isCardCoBadged=false) => { | ||
let cardType = React.useMemo1(_ => cardBrand->CardUtils.getCardType, [cardBrand]) | ||
let animate = cardType == NOTFOUND ? "animate-slideLeft" : "animate-slideRight" | ||
|
||
let cardBrandIcon = React.useMemo1( | ||
_ => CardUtils.getCardBrandIcon(cardType, paymentType), | ||
[cardBrand], | ||
) | ||
<div className={`${animate} flex items-center`}> | ||
cardBrandIcon | ||
{isCardCoBadged ? <CoBadgeCardSchemeDropDown cardNumber setCardBrand /> : React.null} | ||
</div> | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ let make = ( | |
_, | ||
_, | ||
maxCardLength, | ||
_, | ||
) = cardProps | ||
|
||
let ( | ||
|
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ let make = ( | |
_, | ||
_, | ||
maxCardLength, | ||
_, | ||
) = cardProps | ||
|
||
let ( | ||
|