Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Bonus Pagamenti Digitali): [#175164503] Activate bpd on new onboarded Bancomat #2307

Merged
merged 75 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1335d1b
draft store action reducers
fabriziofff Oct 9, 2020
787b009
wip
fabriziofff Oct 9, 2020
0d523d3
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 12, 2020
2beec3f
complete reducer for bpdPaymentMethodActivation
fabriziofff Oct 12, 2020
dd204a8
wip
fabriziofff Oct 12, 2020
d9dd199
add update logic
fabriziofff Oct 12, 2020
d4a9416
Merge remote-tracking branch 'origin/master' into 175010541-enable-bp…
fabriziofff Oct 12, 2020
388312d
Merge remote-tracking branch 'origin/master' into 175010541-enable-bp…
fabriziofff Oct 13, 2020
dcaca78
Merge remote-tracking branch 'origin/master' into 175010541-enable-bp…
fabriziofff Oct 15, 2020
ca451ca
[#175010541] draft layout
fabriziofff Oct 15, 2020
d724550
wip
fabriziofff Oct 15, 2020
cbeed7b
poc pot!
fabriziofff Oct 15, 2020
82137c5
rework store
fabriziofff Oct 15, 2020
434a6d2
schedule retry
fabriziofff Oct 15, 2020
1b06b7e
wip retry
fabriziofff Oct 16, 2020
e64f088
better focus handling
fabriziofff Oct 16, 2020
6e006a4
clean code
fabriziofff Oct 16, 2020
6b25baf
Merge remote-tracking branch 'origin/master' into 175010541-enable-bp…
fabriziofff Oct 16, 2020
108cbb6
refinements
fabriziofff Oct 16, 2020
3d17097
renaming
fabriziofff Oct 16, 2020
66874bc
move style to styles
fabriziofff Oct 16, 2020
447ee5a
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 16, 2020
82773e6
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 16, 2020
a3acbd0
EnrollPaymentMethodScreen static content
fabriziofff Oct 16, 2020
6f8a8c7
Merge remote-tracking branch 'origin/175010541-enable-bpd-on-payment-…
fabriziofff Oct 16, 2020
1be15c8
link to business logic
fabriziofff Oct 16, 2020
6b191fa
add comment
fabriziofff Oct 16, 2020
f4b60f9
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 19, 2020
f17ba9b
Merge remote-tracking branch 'origin/175010541-enable-bpd-on-payment-…
fabriziofff Oct 19, 2020
51d4484
[#175329974] Add TMPBpdScreen
fabriziofff Oct 19, 2020
6c51b6d
fix typescript
fabriziofff Oct 19, 2020
1ad54ca
fix test fail
fabriziofff Oct 19, 2020
0fff03d
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
Undermaken Oct 20, 2020
940e651
[#174794326,174794981] support get payment status
Undermaken Oct 20, 2020
ae5fcc2
[#174794326,174794981] support update (enroll + delete) payment status
Undermaken Oct 20, 2020
07d1250
Merge remote-tracking branch 'origin/175010541-enable-bpd-on-payment-…
fabriziofff Oct 20, 2020
f40c6e2
Merge branch '174863016-EnrollPaymentMethodsScreen' into 175329974-te…
fabriziofff Oct 20, 2020
3dade1b
Merge branch '175329974-test-bpd-enable-disable-payment-method' into …
fabriziofff Oct 20, 2020
c742f31
locales refactoring
fabriziofff Oct 20, 2020
b0a21c8
fix LoadAddBancomat caption
fabriziofff Oct 20, 2020
da6763e
register added bancomat in the current session
fabriziofff Oct 20, 2020
8b3bb0c
wip enhance bancomat onboarding
fabriziofff Oct 20, 2020
80b6150
AskBpdActivationScreen
fabriziofff Oct 21, 2020
b616c7e
complete navigation based on bancomat onboarding state
fabriziofff Oct 21, 2020
69acc4f
fix typescript
fabriziofff Oct 21, 2020
9cb2917
fix typescript
fabriziofff Oct 21, 2020
023988b
fix integration with legacy add payment method
fabriziofff Oct 21, 2020
0ceab7f
renaming
fabriziofff Oct 21, 2020
044b02c
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 21, 2020
8733abc
Merge branch 'master' into 174794326-174794981-bpd-payment-instruments
Undermaken Oct 21, 2020
e85a7d3
support 409 http response status code
Undermaken Oct 21, 2020
198ecfa
Merge branch 'master' into 175010541-enable-bpd-on-payment-method-com…
fabriziofff Oct 22, 2020
011bece
use const for loadingState
fabriziofff Oct 22, 2020
f27ac54
Merge branch '175010541-enable-bpd-on-payment-method-component' into …
fabriziofff Oct 22, 2020
f752a8f
Merge remote-tracking branch 'origin/master' into 175010541-enable-bp…
fabriziofff Oct 22, 2020
755e74e
Merge branch '175010541-enable-bpd-on-payment-method-component' into …
fabriziofff Oct 22, 2020
bfacf57
Merge remote-tracking branch 'origin/master' into 174794326-174794981…
fabriziofff Oct 22, 2020
550846e
Merge branch '174794326-174794981-bpd-payment-instruments' into 17486…
fabriziofff Oct 22, 2020
6201a80
Merge branch '174863016-EnrollPaymentMethodsScreen' into 175329974-te…
fabriziofff Oct 22, 2020
f35ce26
Merge branch '175329974-test-bpd-enable-disable-payment-method' into …
fabriziofff Oct 22, 2020
5ee0940
fix merge
fabriziofff Oct 22, 2020
b8a0cdb
Merge branch '175329974-test-bpd-enable-disable-payment-method' into …
fabriziofff Oct 22, 2020
c349e57
Merge branch 'master' into 174863016-EnrollPaymentMethodsScreen
fabriziofff Oct 22, 2020
0a57c34
Merge branch 'master' into 174863016-EnrollPaymentMethodsScreen
fabriziofff Oct 22, 2020
fbb1c11
Merge remote-tracking branch 'origin/174863016-EnrollPaymentMethodsSc…
fabriziofff Oct 22, 2020
3f2ddf6
Merge branch '175329974-test-bpd-enable-disable-payment-method' into …
fabriziofff Oct 22, 2020
f238ebb
Merge remote-tracking branch 'origin/master' into 174863016-EnrollPay…
fabriziofff Oct 23, 2020
7fcbeee
Merge branch '174863016-EnrollPaymentMethodsScreen' into 175329974-te…
fabriziofff Oct 23, 2020
f4ab98a
Merge branch '175329974-test-bpd-enable-disable-payment-method' into …
fabriziofff Oct 23, 2020
5cda3db
Merge branch 'master' of github.com:pagopa/io-app into 174863016-Enro…
Undermaken Oct 23, 2020
a303abc
Merge branch '174863016-EnrollPaymentMethodsScreen' of github.com:pag…
Undermaken Oct 23, 2020
83081b4
[#175329974] sync activationDate&deactivationDate with local type def…
Undermaken Oct 23, 2020
ccbfc6f
Merge branch 'master' of github.com:pagopa/io-app into 175329974-test…
Undermaken Oct 23, 2020
7d1a3a5
Merge branch '175329974-test-bpd-enable-disable-payment-method' of gi…
Undermaken Oct 23, 2020
d28b30e
Update locales/it/index.yml
Undermaken Oct 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ global:
saveSelection: Save the selection
search: Search
skip: "Skip"
add: Add
navigator:
messages: messages
wallet: payments
Expand Down Expand Up @@ -636,13 +637,6 @@ wallet:
bankName: Name of the bank
noName: Name unavailable
loading: Loading bank list...
addBancomat:
title: "Add bancomat {{current}} of {{length}}"
screenTitle: "Do you want to add this card?"
bodySingular: "We found 1 card headed to you. Proceed with the addition of this card by clicking Add or click Skip to cancel the operation."
bodyPlural: "We found {{number}} cards headed to you. Proceed with the addition of this card by clicking Add or click Skip to cancel the operation."
skip: Skip
add: Add
accessibility:
cardsPreview: Payment methods' preview. Activate to navigate to the the list of payment methods.
transactionListItem:
Expand All @@ -662,6 +656,25 @@ wallet:
chooseAnother: "Choose another bank"
loadingSearch:
title: "We are asking Bancomat for the list of your cards\n\nPlease wait"
add:
title: "Add bancomat {{current}} of {{length}}"
screenTitle: "Do you want to add this card?"
bodySingular: "We found 1 card headed to you. Proceed with the addition of this card by clicking Add or click Skip to cancel the operation."
bodyPlural: "We found {{number}} cards headed to you. Proceed with the addition of this card by clicking Add or click Skip to cancel the operation."
loading: "We are adding your PagoBANCOMAT card\n\nPlease wait a few seconds"
bpd:
suggestActivation:
title: "Do you want to activate Digital Payments Cashback?"
body: "You have added payment methods compatible with Cashback Digital Payments, the initiative promoted by the Presidency of the Council of Ministers to promote the use of electronic money.\n\n
Each time you pay with one of the compatible electronic payment methods (cards, debit cards, apps, etc.), you will receive a partial refund based on your expense.\n\n
Based on how many transnations you have accumulated, in each period, you can receive a cash prize of up to XXXX euros. "
skip: "No, thanks"
confirm: "Info and activation"
activateNew:
title: "Do you want to activate Digital Payments Cashback?"
body1: "Payments you make with these methods will receive cashback and compete for your ranking."
body2: "If you prefer, you can activate cashback on these methods at a later time as well."
skip: "Not now, thanks"
alert:
msgErrorUpdateApp: "An error occurred while opening the app store"
titlePagoPaUpdateApp: Update required
Expand Down
27 changes: 20 additions & 7 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ global:
saveSelection: Salva la selezione
search: Ricerca
skip: "Salta"
add: Aggiungi
navigator:
messages: messaggi
wallet: pagamenti
Expand Down Expand Up @@ -657,13 +658,6 @@ wallet:
bankName: Denominazione della banca
noName: Nome non disponibile
loading: Carico la lista delle banche...
addBancomat:
title: "Aggiungi bancomat {{current}} di {{length}}"
screenTitle: "Vuoi aggiungere questa carta?"
bodySingular: "Abbiamo trovato 1 carta a te intestata. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per annullare l'operazione."
bodyPlural: "Abbiamo trovato {{number}} carte a te intestate. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per passare alla carta successiva."
skip: Salta
add: Aggiungi
accessibility:
cardsPreview: Anteprima dei metodi di pagamento. Attiva per accedere alla lista dei tuoi metodi
transactionListItem:
Expand All @@ -683,6 +677,25 @@ wallet:
chooseAnother: "Scegli un'altra banca"
loadingSearch:
title: "Stiamo chiedendo a Bancomat la lista delle tue carte\n\nAttendi qualche secondo"
add:
title: "Aggiungi bancomat {{current}} di {{length}}"
screenTitle: "Vuoi aggiungere questa carta?"
bodySingular: "Abbiamo trovato 1 carta a te intestata. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per annullare l'operazione."
bodyPlural: "Abbiamo trovato {{number}} carte a te intestate. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per passare alla carta successiva."
loading: "Stiamo aggiungendo la tua carta PagoBANCOMAT\n\nAttendi qualche secondo"
bpd:
suggestActivation:
title: "Vuoi attivare il Cashback Pagamenti Digitali?"
body: "Hai aggiunto dei metodi di pagamento compatibili con il Cashback Pagamenti Digitali, l’iniziativa promossa dalla Presidenza del Consiglio dei Ministri per promuovere l’uso della moneta elettronica.\n\n
Ogni volta che pagherai con uno dei metodi di pagamento elettronico compatibili (carte, bancomat, app, etc..), riceverai un riborso parziale in base alla tua spesa.\n\n
Undermaken marked this conversation as resolved.
Show resolved Hide resolved
In base a quante trasnazioni avrai accumulato, in ciascuno periodo, potrai ricevere un premio in denaro fino a XXXX euro."
skip: "No, grazie"
confirm: "Info e attivazione"
activateNew:
title: "Vuoi attivare il Cashback Pagamenti Digitali?"
body1: "I pagamenti che farai con questi metodi riceveranno il cashback e concorreranno alla tua posizione in classifica."
body2: "Se preferisci, puoi attivare il cashback su questi metodi anche in un secondo momento."
skip: "Non ora, grazie"
alert:
msgErrorUpdateApp: "Si è verificato un errore durante l'apertura dello store delle app"
titlePagoPaUpdateApp: Aggiornamento richiesto
Expand Down
6 changes: 4 additions & 2 deletions ts/features/bonus/bpd/components/PaymentMethodBpdList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as React from "react";
import { View } from "react-native";
import { WalletV2 } from "../../../../../definitions/pagopa/bancomat/WalletV2";
import { IOStyles } from "../../../../components/core/variables/IOStyles";
import { Wallet } from "../../../../types/pagopa";
import { HPan } from "../store/actions/paymentMethods";
import PaymentMethodBpdToggle from "./paymentMethodActivationToggle/PaymentMethodBpdToggle";

type Props = {
paymentList: ReadonlyArray<Wallet>;
// TODO: waiting for conversion to WalletV2
paymentList: ReadonlyArray<Wallet | WalletV2>;
};

/**
Expand All @@ -22,7 +24,7 @@ export const PaymentMethodBpdList: React.FunctionComponent<Props> = props => (
key={pm.idWallet}
// TODO: use hPan when available in v2 wallet
// TODO: when v2 is available, extract the image and caption foreach different pm
hPan={pm.idWallet.toString() as HPan}
hPan={pm.idWallet?.toString() as HPan}
// TODO: read from v2 wallet when ready
hasBpdCapability={true}
/>
Expand Down
10 changes: 10 additions & 0 deletions ts/features/wallet/onboarding/bancomat/navigation/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ export const navigateToOnboardingBancomatAdd = () =>
NavigationActions.navigate({
routeName: WALLET_ONBOARDING_BANCOMAT_ROUTES.ADD_BANCOMAT
});

export const navigateToSuggestBpdActivation = () =>
NavigationActions.navigate({
routeName: WALLET_ONBOARDING_BANCOMAT_ROUTES.SUGGEST_BPD_ACTIVATION
});

export const navigateToActivateBpdOnNewBancomat = () =>
NavigationActions.navigate({
routeName: WALLET_ONBOARDING_BANCOMAT_ROUTES.ACTIVATE_BPD_NEW_BANCOMAT
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { createStackNavigator } from "react-navigation";
import ActivateBpdOnNewBancomatScreen from "../screens/bpd/ActivateBpdOnNewBancomatScreen";
import SuggestBpdActivationScreen from "../screens/bpd/SuggestBpdActivationScreen";
import SearchBankScreen from "../screens/search/SearchBankScreen";
import SearchAvailableUserBancomatScreen from "../screens/searchBancomat/SearchAvailableUserBancomatScreen";
import WALLET_ONBOARDING_BANCOMAT_ROUTES from "./routes";
Expand All @@ -10,6 +12,12 @@ const PaymentMethodOnboardingBancomatNavigator = createStackNavigator(
},
[WALLET_ONBOARDING_BANCOMAT_ROUTES.SEARCH_AVAILABLE_USER_BANCOMAT]: {
screen: SearchAvailableUserBancomatScreen
},
[WALLET_ONBOARDING_BANCOMAT_ROUTES.SUGGEST_BPD_ACTIVATION]: {
screen: SuggestBpdActivationScreen
},
[WALLET_ONBOARDING_BANCOMAT_ROUTES.ACTIVATE_BPD_NEW_BANCOMAT]: {
screen: ActivateBpdOnNewBancomatScreen
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const WALLET_ONBOARDING_BANCOMAT_ROUTES = {
SEARCH_AVAILABLE_USER_BANCOMAT:
"WALLET_ONBOARDING_BANCOMAT_SEARCH_AVAILABLE_USER_BANCOMAT",

ADD_BANCOMAT: "WALLET_ONBOARDING_BANCOMAT_ADD"
ADD_BANCOMAT: "WALLET_ONBOARDING_BANCOMAT_ADD",
SUGGEST_BPD_ACTIVATION: "WALLET_ONBOARDING_BANCOMAT_SUGGEST_BPD_ACTIVATION",
ACTIVATE_BPD_NEW_BANCOMAT: "WALLET_ONBOARDING_BANCOMAT_ACTIVATE_BPD_NEW"
};

export default WALLET_ONBOARDING_BANCOMAT_ROUTES;
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { call, put } from "redux-saga/effects";
import { NavigationActions } from "react-navigation";
import { call, put, select } from "redux-saga/effects";
import {
ESagaResult,
executeWorkUnit,
withResetNavigationStack
} from "../../../../../../sagas/workUnit";
import { navigateToWalletHome } from "../../../../../../store/actions/navigation";
import { navigationCurrentRouteSelector } from "../../../../../../store/reducers/navigation";
import { SagaCallReturnType } from "../../../../../../types/utils";
import { navigateToOnboardingBancomatChooseBank } from "../../navigation/action";
import { isBpdEnabled } from "../../../../../bonus/bpd/saga/orchestration/onboarding/startOnboarding";
import {
navigateToActivateBpdOnNewBancomat,
navigateToOnboardingBancomatChooseBank,
navigateToSuggestBpdActivation
} from "../../navigation/action";
import WALLET_ONBOARDING_BANCOMAT_ROUTES from "../../navigation/routes";
import {
walletAddBancomatBack,
walletAddBancomatCancel,
walletAddBancomatCompleted
} from "../../store/actions";
import { onboardingBancomatAddedPansSelector } from "../../store/reducers/addedPans";

/**
* Define the workflow that allows the user to add a bancomat to the wallet.
Expand Down Expand Up @@ -40,7 +47,71 @@ export function* addBancomatToWalletGeneric() {
withResetNavigationStack,
bancomatWorkUnit
);
if (res !== ESagaResult.Back) {
if (res !== "back") {
yield put(navigateToWalletHome());
}
}

/**
* Chain the add bancomat to wallet with "activate bpd on the new bancomat"
*/
export function* addBancomatToWalletAndActivateBpd() {
const res: SagaCallReturnType<typeof executeWorkUnit> = yield call(
withResetNavigationStack,
bancomatWorkUnit
);
if (res !== "back") {
// integration with the legacy "Add a payment"
// If the payment starts from "WALLET_ADD_PAYMENT_METHOD", remove from stack
// This shouldn't happens if all the workflow will use the executeWorkUnit
const currentRoute: ReturnType<typeof navigationCurrentRouteSelector> = yield select(
navigationCurrentRouteSelector
);

if (
currentRoute.isSome() &&
currentRoute.value === "WALLET_ADD_PAYMENT_METHOD"
) {
yield put(NavigationActions.back());
}
}

if (res === "completed") {
yield call(activateBpdOnNewBancomat);
}
}

/**
* Allows the user to activate bpd on the new added bancomat
*/
function* activateBpdOnNewBancomat() {
// read the new added bancomat
const bancomatAdded: ReturnType<typeof onboardingBancomatAddedPansSelector> = yield select(
onboardingBancomatAddedPansSelector
);
// TODO: change enableableFunction with types representing the possibles functionalities
const atLeastOneBancomatWithBpdCapability = bancomatAdded.some(b =>
b.enableableFunctions?.includes("BPD")
);

// No bancomat with bpd capability added in the current workflow, return to wallet home
if (!atLeastOneBancomatWithBpdCapability) {
return yield put(navigateToWalletHome());
}
const isBpdEnabledResponse: SagaCallReturnType<typeof isBpdEnabled> = yield call(
isBpdEnabled
);

// Error while reading the bpdEnabled, return to wallet
if (isBpdEnabledResponse.isLeft()) {
yield put(navigateToWalletHome());
} else {
if (isBpdEnabledResponse.value) {
// navigate to onboarding new bancomat
yield put(navigateToActivateBpdOnNewBancomat());
} else {
// navigate to "ask if u want to start bpd onboarding"
yield put(navigateToSuggestBpdActivation());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const AddBancomatComponent: React.FunctionComponent<Props> = (props: Props) => {
return (
<BaseScreenComponent
customGoBack={<View hspacer={true} spacer={true} />}
headerTitle={I18n.t("wallet.addBancomat.title", {
headerTitle={I18n.t("wallet.onboarding.bancomat.add.title", {
current: props.currentIndex + 1,
length: props.pansNumber
})}
Expand All @@ -58,7 +58,7 @@ const AddBancomatComponent: React.FunctionComponent<Props> = (props: Props) => {
paddingHorizontal: customVariables.contentPadding
}}
>
<H1>{I18n.t("wallet.addBancomat.screenTitle")}</H1>
<H1>{I18n.t("wallet.onboarding.bancomat.add.screenTitle")}</H1>
<View spacer={true} large={true} />
<PanCardComponent
pan={props.pan}
Expand All @@ -72,21 +72,21 @@ const AddBancomatComponent: React.FunctionComponent<Props> = (props: Props) => {
<View spacer={true} large={true} />
<H4 color={"bluegrey"} weight={"Regular"}>
{props.pansNumber > 1
? I18n.t("wallet.addBancomat.bodyPlural", {
? I18n.t("wallet.onboarding.bancomat.add.bodyPlural", {
number: props.pansNumber
})
: I18n.t("wallet.addBancomat.bodySingular")}
: I18n.t("wallet.onboarding.bancomat.add.bodySingular")}
</H4>
</View>
<FooterWithButtons
type={"TwoButtonsInlineThird"}
leftButton={cancelButtonProps(
props.handleSkip,
I18n.t("wallet.addBancomat.skip")
I18n.t("global.buttons.skip")
)}
rightButton={confirmButtonProps(
props.handleContinue,
I18n.t("wallet.addBancomat.add")
I18n.t("global.buttons.add")
)}
/>
</SafeAreaView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LoadAddBancomatComponent: React.FunctionComponent<Props> = props => {
return (
<LoadingErrorComponent
{...props}
loadingCaption={I18n.t("wallet.onboarding.bancomat.loadingSearch.title")}
loadingCaption={I18n.t("wallet.onboarding.bancomat.add.loading")}
onAbort={props.onCancel}
onRetry={props.onRetry}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { View } from "native-base";
import * as React from "react";
import { SafeAreaView, ScrollView } from "react-native";
import { NavigationActions } from "react-navigation";
import { connect } from "react-redux";
import { Dispatch } from "redux";
import { Body } from "../../../../../../components/core/typography/Body";
import { H1 } from "../../../../../../components/core/typography/H1";
import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent";
import I18n from "../../../../../../i18n";
import { GlobalState } from "../../../../../../store/reducers/types";
import { FooterTwoButtons } from "../../../../../bonus/bonusVacanze/components/markdown/FooterTwoButtons";
import { PaymentMethodBpdList } from "../../../../../bonus/bpd/components/PaymentMethodBpdList";
import { onboardingBancomatAddedPansSelector } from "../../store/reducers/addedPans";

export type Props = ReturnType<typeof mapDispatchToProps> &
ReturnType<typeof mapStateToProps>;

const loadLocales = () => ({
headerTitle: I18n.t("wallet.onboarding.bancomat.headerTitle"),
title: I18n.t("wallet.onboarding.bancomat.bpd.activateNew.title"),
body1: I18n.t("wallet.onboarding.bancomat.bpd.activateNew.body1"),
body2: I18n.t("wallet.onboarding.bancomat.bpd.activateNew.body2"),
skip: I18n.t("wallet.onboarding.bancomat.bpd.activateNew.skip"),
continueStr: I18n.t("global.buttons.continue")
});

const ActivateBpdOnNewBancomatScreen: React.FunctionComponent<Props> = props => {
const { headerTitle, title, body1, body2, skip, continueStr } = loadLocales();
return (
<BaseScreenComponent headerTitle={headerTitle}>
<SafeAreaView style={IOStyles.flex}>
<ScrollView>
<View style={IOStyles.horizontalContentPadding}>
<View spacer={true} large={true} />
<H1>{title}</H1>
<View spacer={true} large={true} />
<Body>{body1}</Body>
<View spacer={true} large={true} />
<PaymentMethodBpdList paymentList={props.newBancomat} />
<View spacer={true} large={true} />
<Body>{body2}</Body>
</View>
</ScrollView>

<FooterTwoButtons
type={"TwoButtonsInlineHalf"}
onCancel={props.skip}
onRight={props.skip}
rightText={continueStr}
leftText={skip}
/>
</SafeAreaView>
</BaseScreenComponent>
);
};

const mapDispatchToProps = (dispatch: Dispatch) => ({
skip: () => dispatch(NavigationActions.back())
});

const mapStateToProps = (state: GlobalState) => ({
newBancomat: onboardingBancomatAddedPansSelector(state)
});

export default connect(
mapStateToProps,
mapDispatchToProps
)(ActivateBpdOnNewBancomatScreen);
Loading