diff --git a/locales/en/index.yml b/locales/en/index.yml index 51676d4edcb..c516b5f639c 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -1696,6 +1696,11 @@ bonus: failure: "We were unable to remove, please try again" earned: Collected Cashback onboarding: + alert: + title: Cashback is aleady active + body: You can find more details in your Wallet. + cancel: Close + confirm: Back to Wallet loadingActivationStatus: title: Loading activation status declaration: diff --git a/locales/it/index.yml b/locales/it/index.yml index 9bcf090ab9f..0590bc52c86 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -1728,6 +1728,11 @@ bonus: success: "La tua iscrizione al cashback è stata cancellata" failure: "Non siamo riusciti a cancellare la tua iscrizione, riprova per favore" onboarding: + alert: + title: Il cashback è già attivo + body: Puoi vedere maggiori dettagli nel tuo Portafoglio. + cancel: Chiudi + confirm: Torna al Portafoglio loadingActivationStatus: title: Verifico lo stato di attivazione declaration: diff --git a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts b/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts index 0320eb7517c..797a470400b 100644 --- a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts +++ b/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts @@ -12,7 +12,6 @@ import { } from "redux-saga/effects"; import { CitizenResource } from "../../../../../../../definitions/bpd/citizen/CitizenResource"; import ROUTES from "../../../../../../navigation/routes"; -import { navigateToWalletHome } from "../../../../../../store/actions/navigation"; import { navigationHistoryPop } from "../../../../../../store/actions/navigationHistory"; import { navigationCurrentRouteSelector } from "../../../../../../store/reducers/navigation"; import { SagaCallReturnType } from "../../../../../../types/utils"; @@ -83,24 +82,17 @@ export function* bpdStartOnboardingWorker() { ); if (isBpdActive.isRight()) { - if (isBpdActive.value) { - // The bpd is already active, go directly to the bpd details screen - // TODO: navigate to bpd details - yield put(navigateToWalletHome()); - yield put(navigationHistoryPop(1)); - } else { - // The bpd is not active, continue with the onboarding - yield put(navigateToBpdOnboardingInformationTos()); - yield put(navigationHistoryPop(1)); + yield put(navigateToBpdOnboardingInformationTos()); + yield put(navigationHistoryPop(1)); - // wait for the user that choose to continue - yield take(bpdUserActivate); + // wait for the user that choose to continue + yield take(bpdUserActivate); - // Navigate to the Onboarding Declaration and wait for the action that complete the saga - yield put(navigateToBpdOnboardingDeclaration()); - yield put(navigationHistoryPop(1)); - } + // Navigate to the Onboarding Declaration and wait for the action that complete the saga + yield put(navigateToBpdOnboardingDeclaration()); + yield put(navigationHistoryPop(1)); } + // The saga ends when the user accepts the declaration yield take(bpdOnboardingAcceptDeclaration); } diff --git a/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx b/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx index c45c3328bc3..13eab40d13d 100644 --- a/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx +++ b/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx @@ -1,14 +1,18 @@ import * as React from "react"; import { connect } from "react-redux"; +import I18n from "../../../../../i18n"; import { Dispatch } from "../../../../../store/actions/types"; import { GlobalState } from "../../../../../store/reducers/types"; +import { actionWithAlert } from "../../../bonusVacanze/components/alert/ActionWithAlert"; import { availableBonusTypesSelectorFromId } from "../../../bonusVacanze/store/reducers/availableBonusesTypes"; import { ID_BPD_TYPE } from "../../../bonusVacanze/utils/bonus"; import BonusInformationComponent from "../../../common/components/BonusInformationComponent"; +import { getValue } from "../../model/RemoteValue"; import { bpdOnboardingCancel, bpdUserActivate } from "../../store/actions/onboarding"; +import { bpdEnabledSelector } from "../../store/reducers/details/activation"; export type Props = ReturnType & ReturnType; @@ -17,21 +21,35 @@ export type Props = ReturnType & * This Screen shows all the information about the bpd program, with the rules and t&c. */ -const BpdInformationScreen: React.FunctionComponent = (props: Props) => ( - <> - {props.bonus ? ( - - ) : null} - -); +const BpdInformationScreen: React.FunctionComponent = (props: Props) => { + const onConfirm = () => + getValue(props.bpdActiveBonus) === true + ? actionWithAlert({ + title: I18n.t("bonus.bpd.onboarding.alert.title"), + body: I18n.t("bonus.bpd.onboarding.alert.body"), + cancelText: I18n.t("bonus.bpd.onboarding.alert.cancel"), + confirmText: I18n.t("bonus.bpd.onboarding.alert.confirm"), + onConfirmAction: props.onCancel + }) + : props.userActivateBpd(); + + return ( + <> + {props.bonus ? ( + + ) : null} + + ); +}; const mapStateToProps = (state: GlobalState) => ({ // display the error with the retry only in case of networking errors - bonus: availableBonusTypesSelectorFromId(ID_BPD_TYPE)(state) + bonus: availableBonusTypesSelectorFromId(ID_BPD_TYPE)(state), + bpdActiveBonus: bpdEnabledSelector(state) }); const mapDispatchToProps = (dispatch: Dispatch) => ({