-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Bonus Pagamenti Digitali): [#176578322] Visualize iteratively co…
…-badge card that can be added to the wallet (#2770) * [#176578578] create cobadge list selector * [#176578578] add optional abiInfo to creditCardPaymentMethod * [#176578578] add cobadgeCard to walletPreview * [#176578578] create cobadgePreview card * [#176578578] add cobadge card * [#176578578] wip enhance crediCard * [#176578578] enhance creditCard with abiInfo * [#176578578] renaming * [#176578578] add void CobadgeDetailScreen * [#176578578] add navigation to cobadgeDetailScreen action * [#176578578] add testId to cardPreview * [#176578578] add fake cobadgeDetailScreen * [#176578578] add navigation to cobadgeWalletDetail * [#176578578] add cobadgeWalletPreview tests * [#176578587] modify paymentMethodCapabilities test description * [#176578587] extract cobadge param from navigation * [#176578587] add dark layout * [#176578587] add paymentMethodCapabilities * [#176578587] add delete button * [#176578587] add cobadge card labels * [#176578587] add cobadge card * [#176578587] drill brandLogo from cobadgeWalletPreview to CobadgeCard component * [#176578587] remove bankName as abiLogo fallback * [#176578587] update CobadgeWalletPreview test * [#176578587] add abiLogo fallback * [#176578587] update expirationDate label * [#176578587] add expirationDate testId * [#176578587] add CobadgeCard tests * [#176578587] update labels * [#176578587] removed unused import * [#176578578] remove bancomat or bpay reference * [#176578578] use already existing getCardIconFromBrandLogo function instead of create a new one * [#176578578] add issuerAbiCode condition on cobadgeListVisibleInWalletSelector * [#176578578] fix * [#176578587] fix merge * [#176578587] fix merge * [#176578587] fix typo in test name * [#176578587] align brandLogo size with invision * [#176578587] pass the whole cobadge card instead of separate prop * [#176578587] add key to abiLogo in cobadge card * [#176578587] remove unused import * [#176578587] update test * [#176578322] add AddCobadgeComponent * [#176578322] rename CobadgeCard * [#176578322] refactor: add BaseCobadgeCard * [#176578322] refactor: use the BaseCobadgeCard in CobadgeCard * [#176578322] remove reactotron * [#176578322] update labels * [#176578322] update tests * [#176578322] add extract title for a payment method util * [#176578322] add extract card icon from brand util * [#176578322] insert AddCobadgeComponent in AddCobadgeScreen * [#176578322] add PreviewCoBadgeCard * [#176578322] insert PreviewCoBadgeCard into AddCobadgeComponent * [#176578322] remove reactotron * [#176578322] remove unused import * [#176578322] update labels * [#176578322] add loading caption * [#176578322] remove wrong test file * [#176578322] update CoBadgeCard component * [#176578322] fix lint errors * [#176578322] porting BrandEnum -> PaymentNetworkEnum Co-authored-by: fabriziofff <[email protected]>
- Loading branch information
1 parent
4b6611f
commit 187b665
Showing
12 changed files
with
323 additions
and
66 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from "react"; | ||
import { getCardIconFromBrandLogo } from "../../../../components/wallet/card/Logo"; | ||
import { CreditCardPaymentMethod } from "../../../../types/pagopa"; | ||
import BaseCoBadgeCard from "./BaseCoBadgeCard"; | ||
|
||
type Props = { enhancedCoBadge: CreditCardPaymentMethod }; | ||
|
||
const getExpireDate = (fullYear?: string, month?: string): Date | undefined => { | ||
if (!fullYear || !month) { | ||
return undefined; | ||
} | ||
const year = parseInt(fullYear, 10); | ||
const indexedMonth = parseInt(month, 10); | ||
if (isNaN(year) || isNaN(indexedMonth)) { | ||
return undefined; | ||
} | ||
return new Date(year, indexedMonth - 1); | ||
}; | ||
|
||
/** | ||
* Render a Co-badge card already added to the wallet | ||
* @param props | ||
* @constructor | ||
*/ | ||
const CoBadgeCard: React.FunctionComponent<Props> = props => { | ||
const brandLogo = getCardIconFromBrandLogo(props.enhancedCoBadge.info); | ||
return ( | ||
<BaseCoBadgeCard | ||
abi={props.enhancedCoBadge.abiInfo ?? {}} | ||
expiringDate={getExpireDate( | ||
props.enhancedCoBadge.info.expireYear, | ||
props.enhancedCoBadge.info.expireMonth | ||
)} | ||
brandLogo={brandLogo} | ||
caption={props.enhancedCoBadge.caption} | ||
/> | ||
); | ||
}; | ||
export default CoBadgeCard; |
29 changes: 29 additions & 0 deletions
29
ts/features/wallet/cobadge/component/PreviewCoBadgeCard.tsx
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,29 @@ | ||
import * as React from "react"; | ||
import { Abi } from "../../../../../definitions/pagopa/walletv2/Abi"; | ||
import { PaymentInstrument } from "../../../../../definitions/pagopa/walletv2/PaymentInstrument"; | ||
import { getCardIconFromPaymentNetwork } from "../../../../utils/card"; | ||
import { | ||
getTitleFromPaymentInstrument, | ||
isCoBadgeBlocked | ||
} from "../../../../utils/paymentMethod"; | ||
import BaseCoBadgeCard from "./BaseCoBadgeCard"; | ||
|
||
type Props = { coBadge: PaymentInstrument; abi: Abi }; | ||
|
||
/** | ||
* Display a preview of a cobadge that the user could add to the wallet | ||
* @constructor | ||
*/ | ||
const PreviewCoBadgeCard: React.FunctionComponent<Props> = props => { | ||
const brandLogo = getCardIconFromPaymentNetwork(props.coBadge.paymentNetwork); | ||
return ( | ||
<BaseCoBadgeCard | ||
abi={props.abi} | ||
expiringDate={props.coBadge.expiringDate} | ||
blocked={isCoBadgeBlocked(props.coBadge)} | ||
brandLogo={brandLogo} | ||
caption={getTitleFromPaymentInstrument(props.coBadge)} | ||
/> | ||
); | ||
}; | ||
export default PreviewCoBadgeCard; |
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
Oops, something went wrong.