diff --git a/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx b/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx index d8acf3a4024..4158b407167 100644 --- a/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx +++ b/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx @@ -16,7 +16,7 @@ import { GlobalState } from "../../../../../../../store/reducers/types"; import { PaymentMethodGroupedList } from "../../../../components/paymentMethodActivationToggle/list/PaymentMethodGroupedList"; import { atLeastOnePaymentMethodHasBpdEnabledSelector, - walletV2WithActivationStatusSelector + paymentMethodsWithActivationStatusSelector } from "../../../../store/reducers/details/combiner"; type Props = ReturnType & @@ -108,7 +108,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ }); const mapStateToProps = (state: GlobalState) => ({ - potWallets: walletV2WithActivationStatusSelector(state), + potWallets: paymentMethodsWithActivationStatusSelector(state), atLeastOnePaymentMethodActive: atLeastOnePaymentMethodHasBpdEnabledSelector( state ) diff --git a/ts/features/bonus/bpd/screens/onboarding/EnrollPaymentMethodsScreen.tsx b/ts/features/bonus/bpd/screens/onboarding/EnrollPaymentMethodsScreen.tsx index a15275b3dc5..0e3162fa3bc 100644 --- a/ts/features/bonus/bpd/screens/onboarding/EnrollPaymentMethodsScreen.tsx +++ b/ts/features/bonus/bpd/screens/onboarding/EnrollPaymentMethodsScreen.tsx @@ -16,7 +16,7 @@ import { PaymentMethod } from "../../../../../types/pagopa"; import { emptyContextualHelp } from "../../../../../utils/emptyContextualHelp"; import { FooterTwoButtons } from "../../../bonusVacanze/components/markdown/FooterTwoButtons"; import { PaymentMethodGroupedList } from "../../components/paymentMethodActivationToggle/list/PaymentMethodGroupedList"; -import { walletV2WithActivationStatusSelector } from "../../store/reducers/details/combiner"; +import { paymentMethodsWithActivationStatusSelector } from "../../store/reducers/details/combiner"; const loadLocales = () => ({ headerTitle: I18n.t("bonus.bpd.title"), @@ -89,7 +89,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ }); const mapStateToProps = (state: GlobalState) => ({ - potWallets: walletV2WithActivationStatusSelector(state) + potWallets: paymentMethodsWithActivationStatusSelector(state) }); export default connect( diff --git a/ts/features/bonus/bpd/store/reducers/details/combiner.ts b/ts/features/bonus/bpd/store/reducers/details/combiner.ts index 6635c18b018..2ce192e1ef1 100644 --- a/ts/features/bonus/bpd/store/reducers/details/combiner.ts +++ b/ts/features/bonus/bpd/store/reducers/details/combiner.ts @@ -211,7 +211,7 @@ export type PaymentMethodWithActivation = PaymentMethod & * Add the information of activationStatus to a PatchedWalletV2 * in order to group the elements "notActivable" */ -export const walletV2WithActivationStatusSelector = createSelector( +export const paymentMethodsWithActivationStatusSelector = createSelector( [paymentMethodsSelector, bpdPaymentMethodActivationSelector], (paymentMethodsPot, bpdActivations) => pot.map(paymentMethodsPot, paymentMethods => diff --git a/ts/features/wallet/component/WalletV2PreviewCards.tsx b/ts/features/wallet/component/WalletV2PreviewCards.tsx index 52659d2f2e0..6faaf6eda5b 100644 --- a/ts/features/wallet/component/WalletV2PreviewCards.tsx +++ b/ts/features/wallet/component/WalletV2PreviewCards.tsx @@ -4,8 +4,8 @@ import { connect } from "react-redux"; import { Dispatch } from "redux"; import { GlobalState } from "../../../store/reducers/types"; import { - bancomatListSelector, - satispayListSelector + bancomatListVisibleInWalletSelector, + satispayListVisibleInWalletSelector } from "../../../store/reducers/wallet/wallets"; import BancomatWalletPreview from "../bancomat/component/BancomatWalletPreview"; import SatispayWalletPreview from "../satispay/SatispayWalletPreview"; @@ -52,8 +52,8 @@ const WalletV2PreviewCards: React.FunctionComponent = props => ( const mapDispatchToProps = (_: Dispatch) => ({}); const mapStateToProps = (state: GlobalState) => ({ - bancomatList: bancomatListSelector(state), - satispayList: satispayListSelector(state) + bancomatList: bancomatListVisibleInWalletSelector(state), + satispayList: satispayListVisibleInWalletSelector(state) }); export default connect( diff --git a/ts/store/reducers/wallet/wallets.ts b/ts/store/reducers/wallet/wallets.ts index e6a80e4c6b3..250a8ab54a4 100644 --- a/ts/store/reducers/wallet/wallets.ts +++ b/ts/store/reducers/wallet/wallets.ts @@ -196,6 +196,56 @@ export const bPayListSelector = createSelector( pot.map(paymentMethodPot, paymentMethod => paymentMethod.filter(isBPay)) ); +/** + * return true if the payment method is visible in the wallet (the onboardingChannel + * is IO or WISP) + * @param pm + */ +export const isVisibleInWallet = (pm: PaymentMethod) => + pm.onboardingChannel === "IO" || pm.onboardingChannel === "WISP"; + +/** + * Return a credit card list visible in the wallet + */ +export const creditCardListVisibleInWalletSelector = createSelector( + [creditCardListSelector], + (creditCardListPot): pot.Pot, Error> => + pot.map(creditCardListPot, creditCardList => + creditCardList.filter(isVisibleInWallet) + ) +); + +/** + * Return a bancomat list visible in the wallet + */ +export const bancomatListVisibleInWalletSelector = createSelector( + [bancomatListSelector], + (bancomatListPot): pot.Pot, Error> => + pot.map(bancomatListPot, bancomatList => + bancomatList.filter(isVisibleInWallet) + ) +); + +/** + * Return a satispay list visible in the wallet + */ +export const satispayListVisibleInWalletSelector = createSelector( + [satispayListSelector], + (satispayListPot): pot.Pot, Error> => + pot.map(satispayListPot, satispayList => + satispayList.filter(isVisibleInWallet) + ) +); + +/** + * Return a BPay list visible in the wallet + */ +export const bPayListVisibleInWalletSelector = createSelector( + [bPayListSelector], + (bPayListPot): pot.Pot, Error> => + pot.map(bPayListPot, bPayList => bPayList.filter(isVisibleInWallet)) +); + /** * Get the list of credit cards using the info contained in v2 (Walletv2) to distinguish */