>) =>
- async () => {
- const response = await options.fetchApi(
- `${options.baseUrl}/bpd/io/citizen`,
- {
- method: "patch",
- headers: { ...headers, Authorization: `Bearer ${token}` },
- body: JSON.stringify(payload)
- }
- );
- const decode = await patchIbanDecoders(PatchIban)(response);
- return (
- decode ??
- E.left([
- {
- context: [],
- value: response
- }
- ])
- );
- };
diff --git a/ts/features/bonus/bpd/api/citizen/v2.ts b/ts/features/bonus/bpd/api/citizen/v2.ts
deleted file mode 100644
index 8106223ef77..00000000000
--- a/ts/features/bonus/bpd/api/citizen/v2.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import {
- ApiHeaderJson,
- composeHeaderProducers,
- MapResponseType
-} from "@pagopa/ts-commons/lib/requests";
-import {
- enrollmentDecoder,
- EnrollmentT as EnrollmentTV2,
- findRankingUsingGETDefaultDecoder,
- FindRankingUsingGETT,
- findUsingGETDecoder,
- FindUsingGETT as FindUsingGETTV2
-} from "../../../../../../definitions/bpd/citizen_v2/requestTypes";
-import { bpdHeadersProducers } from "../common";
-import { PatchedCitizenV2Resource } from "../patchedTypes";
-
-type FindV2UsingGETTExtra = MapResponseType<
- FindUsingGETTV2,
- 200,
- PatchedCitizenV2Resource
->;
-
-const findUsingGETCustomDecoder = findUsingGETDecoder({
- 200: PatchedCitizenV2Resource
-});
-
-export const citizenV2FindGET: FindV2UsingGETTExtra = {
- method: "get",
- url: () => `/bpd/io/citizen/v2`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: findUsingGETCustomDecoder
-};
-
-type EnrollmentV2TTExtra = MapResponseType<
- EnrollmentTV2,
- 200,
- PatchedCitizenV2Resource
->;
-
-const enrollmentCustomDecoder = enrollmentDecoder({
- 200: PatchedCitizenV2Resource
-});
-
-export const citizenV2EnrollPUT: EnrollmentV2TTExtra = {
- method: "put",
- url: () => `/bpd/io/citizen/v2`,
- query: _ => ({}),
- body: ({ optInStatus }) => JSON.stringify(optInStatus ? { optInStatus } : {}),
- headers: composeHeaderProducers(bpdHeadersProducers(), ApiHeaderJson),
- response_decoder: enrollmentCustomDecoder
-};
-
-/**
- * Request the user ranking + milestone information, containing the trxPivot
- */
-export const citizenV2RankingGET: FindRankingUsingGETT = {
- method: "get",
- url: () => `/bpd/io/citizen/v2/ranking`,
- query: (_: { awardPeriodId?: string }) => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: findRankingUsingGETDefaultDecoder()
-};
diff --git a/ts/features/bonus/bpd/api/common.ts b/ts/features/bonus/bpd/api/common.ts
deleted file mode 100644
index 724ce4d892b..00000000000
--- a/ts/features/bonus/bpd/api/common.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { RequestHeaderProducer } from "@pagopa/ts-commons/lib/requests";
-
-/**
- * Produce a base header for the BPD API requests
- */
-export const bpdHeadersProducers = <
- P extends {
- readonly Authorization: string;
- }
->() =>
- ((p: P) => ({
- // since these headers are not correctly autogenerated we have to access them as an anonymous object
- Authorization: `Bearer ${(p as any).Bearer}`
- })) as RequestHeaderProducer;
diff --git a/ts/features/bonus/bpd/api/patchedTypes.ts b/ts/features/bonus/bpd/api/patchedTypes.ts
deleted file mode 100644
index 55475e84a8c..00000000000
--- a/ts/features/bonus/bpd/api/patchedTypes.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import * as t from "io-ts";
-import { enumType } from "@pagopa/ts-commons/lib/types";
-import { CitizenOptInStatusEnum } from "../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus";
-
-/**
- * patched version of CitizenResource
- * - payoffInstr and payoffInstrType must be optional
- */
-// required attributes
-const PatchedCitizenResourceR = t.interface({
- enabled: t.boolean,
-
- fiscalCode: t.string
-});
-
-// optional attributes
-const PatchedCitizenResourceO = t.partial({
- payoffInstr: t.string,
- payoffInstrType: t.string,
- optInStatus: enumType(
- CitizenOptInStatusEnum,
- "optInStatus"
- )
-});
-
-export const PatchedCitizenResource = t.intersection(
- [PatchedCitizenResourceR, PatchedCitizenResourceO],
- "PatchedCitizenResource"
-);
-
-export type PatchedCitizenResource = t.TypeOf;
-
-/**
- * patched version of CitizenV2Resource
- * - technicalAccount must be optional
- */
-// required attributes
-const PatchedCitizenV2ResourceO = t.partial({
- technicalAccount: t.string
-});
-
-export const PatchedCitizenV2Resource = t.intersection(
- [PatchedCitizenResourceR, PatchedCitizenResourceO, PatchedCitizenV2ResourceO],
- "PatchedCitizenResourceV2"
-);
-
-export type PatchedCitizenV2Resource = t.TypeOf<
- typeof PatchedCitizenV2Resource
->;
diff --git a/ts/features/bonus/bpd/api/payment-instrument/v1.ts b/ts/features/bonus/bpd/api/payment-instrument/v1.ts
deleted file mode 100644
index baad7fed209..00000000000
--- a/ts/features/bonus/bpd/api/payment-instrument/v1.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-/* PAYMENT (status, enroll, delete) */
-import * as r from "@pagopa/ts-commons/lib/requests";
-import {
- ApiHeaderJson,
- composeHeaderProducers
-} from "@pagopa/ts-commons/lib/requests";
-import {
- DeleteUsingDELETET,
- enrollmentPaymentInstrumentIOUsingPUTDefaultDecoder,
- EnrollmentPaymentInstrumentIOUsingPUTT,
- findUsingGETDefaultDecoder,
- FindUsingGETT as FindPaymentUsingGETT
-} from "../../../../../../definitions/bpd/payment/requestTypes";
-import { bpdHeadersProducers } from "../common";
-
-export const paymentInstrumentsFindGET: FindPaymentUsingGETT = {
- method: "get",
- url: ({ id }) => `/bpd/io/payment-instruments/${id}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: findUsingGETDefaultDecoder()
-};
-
-export const paymentInstrumentsEnrollPUT: EnrollmentPaymentInstrumentIOUsingPUTT =
- {
- method: "put",
- url: ({ id }) => `/bpd/io/payment-instruments/${id}`,
- query: _ => ({}),
- body: () => "",
- headers: composeHeaderProducers(ApiHeaderJson, bpdHeadersProducers()),
- response_decoder: enrollmentPaymentInstrumentIOUsingPUTDefaultDecoder()
- };
-
-const deletePaymentResponseDecoders = r.composeResponseDecoders(
- r.composeResponseDecoders(
- r.constantResponseDecoder(204, undefined),
- r.constantResponseDecoder(400, undefined)
- ),
- r.composeResponseDecoders(
- r.constantResponseDecoder(401, undefined),
- r.constantResponseDecoder(500, undefined)
- )
-);
-
-export const paymentInstrumentsDELETE: DeleteUsingDELETET = {
- method: "delete",
- url: ({ id }) => `/bpd/io/payment-instruments/${id}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: deletePaymentResponseDecoders
-};
diff --git a/ts/features/bonus/bpd/api/winning-transactions/patchedWinningTransactionPageResource.ts b/ts/features/bonus/bpd/api/winning-transactions/patchedWinningTransactionPageResource.ts
deleted file mode 100644
index 1ea68522929..00000000000
--- a/ts/features/bonus/bpd/api/winning-transactions/patchedWinningTransactionPageResource.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import * as t from "io-ts";
-import { DateFromString } from "@pagopa/ts-commons/lib/dates";
-import { DateFromISOString } from "../../../../../utils/dates";
-
-/**
- * We need to use a patched type because the response contains a date-time translated with the codec UTCISODateFromString
- * that fails to recognize the received format (used instead {@link DateFromISOString})
- */
-
-// required attributes
-const WinningTransactionMilestoneResourceR = t.interface({
- amount: t.number,
-
- awardPeriodId: t.Integer,
-
- cashback: t.number,
-
- circuitType: t.string,
-
- hashPan: t.string,
-
- idTrx: t.string,
-
- idTrxAcquirer: t.string,
-
- idTrxIssuer: t.string,
- // replaced from UTCISODateFromString
- trxDate: DateFromISOString
-});
-
-// optional attributes
-const WinningTransactionMilestoneResourceO = t.partial({});
-
-export const PatchedWinningTransactionMilestoneResource = t.intersection(
- [WinningTransactionMilestoneResourceR, WinningTransactionMilestoneResourceO],
- "PatchedWinningTransactionMilestoneResource"
-);
-
-export type PatchedWinningTransactionMilestoneResource = t.TypeOf<
- typeof PatchedWinningTransactionMilestoneResource
->;
-
-// required attributes
-const WinningTransactionsOfTheDayResourceR = t.interface({
- date: DateFromString,
-
- transactions: t.readonlyArray(
- PatchedWinningTransactionMilestoneResource,
- "array of WinningTransactionMilestoneResource"
- )
-});
-
-// optional attributes
-const WinningTransactionsOfTheDayResourceO = t.partial({});
-
-export const PatchedWinningTransactionsOfTheDayResource = t.intersection(
- [WinningTransactionsOfTheDayResourceR, WinningTransactionsOfTheDayResourceO],
- "PatchedWinningTransactionsOfTheDayResource"
-);
-
-export type PatchedWinningTransactionsOfTheDayResource = t.TypeOf<
- typeof PatchedWinningTransactionsOfTheDayResource
->;
-
-const WinningTransactionPageResourceR = t.interface({
- transactions: t.readonlyArray(
- PatchedWinningTransactionsOfTheDayResource,
- "array of WinningTransactionsOfTheDayResource"
- )
-});
-
-// optional attributes
-const WinningTransactionPageResourceO = t.partial({
- nextCursor: t.Integer,
-
- prevCursor: t.Integer
-});
-
-export const PatchedWinningTransactionPageResource = t.intersection(
- [WinningTransactionPageResourceR, WinningTransactionPageResourceO],
- "PatchedWinningTransactionPageResource"
-);
-
-export type PatchedWinningTransactionPageResource = t.TypeOf<
- typeof PatchedWinningTransactionPageResource
->;
diff --git a/ts/features/bonus/bpd/api/winning-transactions/v1.ts b/ts/features/bonus/bpd/api/winning-transactions/v1.ts
deleted file mode 100644
index 93c1316b7b0..00000000000
--- a/ts/features/bonus/bpd/api/winning-transactions/v1.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/* TOTAL CASHBACK */
-import * as O from "fp-ts/lib/Option";
-import * as r from "@pagopa/ts-commons/lib/requests";
-import { pipe } from "fp-ts/lib/function";
-import {
- findWinningTransactionsUsingGETDecoder,
- getTotalScoreUsingGETDefaultDecoder,
- GetTotalScoreUsingGETT
-} from "../../../../../../definitions/bpd/winning_transactions/requestTypes";
-import { PatchedBpdWinningTransactions } from "../../types/PatchedWinningTransactionResource";
-import { bpdHeadersProducers } from "../common";
-
-export const winningTransactionsTotalCashbackGET: GetTotalScoreUsingGETT = {
- method: "get",
- url: ({ awardPeriodId }) =>
- `/bpd/io/winning-transactions/total-cashback?awardPeriodId=${awardPeriodId}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: getTotalScoreUsingGETDefaultDecoder()
-};
-
-export type FindWinningTransactionsUsingGETTExtra = r.IGetApiRequestType<
- {
- readonly awardPeriodId: number;
- readonly hpan: string;
- readonly Authorization: string;
- },
- never,
- never,
- | r.IResponseType<200, PatchedBpdWinningTransactions>
- | r.IResponseType<401, undefined>
- | r.IResponseType<500, undefined>
->;
-
-const hPanToQueryString = (hPan: string) => `&hpan=${hPan}`;
-
-const findWinningTransactionsUsingGETCustomDecoder =
- findWinningTransactionsUsingGETDecoder({
- 200: PatchedBpdWinningTransactions
- });
-/**
- * @deprecated
- */
-export const winningTransactionsGET: FindWinningTransactionsUsingGETTExtra = {
- method: "get",
- url: ({ awardPeriodId, hpan }) =>
- `/bpd/io/winning-transactions?awardPeriodId=${awardPeriodId}${pipe(
- hpan,
- O.fromNullable,
- O.map(hPanToQueryString),
- O.getOrElse(() => "")
- )}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: findWinningTransactionsUsingGETCustomDecoder
-};
diff --git a/ts/features/bonus/bpd/api/winning-transactions/v2.ts b/ts/features/bonus/bpd/api/winning-transactions/v2.ts
deleted file mode 100644
index 6b4bb9f91ac..00000000000
--- a/ts/features/bonus/bpd/api/winning-transactions/v2.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import * as r from "@pagopa/ts-commons/lib/requests";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import {
- findWinningTransactionsUsingGETDecoder,
- getCountByDayGETDefaultDecoder,
- GetCountByDayGETT
-} from "../../../../../../definitions/bpd/winning_transactions_v2/requestTypes";
-import { bpdHeadersProducers } from "../common";
-import { PatchedWinningTransactionPageResource } from "./patchedWinningTransactionPageResource";
-
-export const winningTransactionsV2CountByDayGET: GetCountByDayGETT = {
- method: "get",
- url: ({ awardPeriodId }) =>
- `/bpd/io/winning-transactions/v2/countbyday?awardPeriodId=${awardPeriodId}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: getCountByDayGETDefaultDecoder()
-};
-
-/**
- * We need to use a patched type because the response contains a date-time translated with the codec UTCISODateFromString
- * that fails to recognize the received format (used instead {@link DateFromISOString})
- */
-export type PatchedFindWinningTransactionsUsingGETT = r.IGetApiRequestType<
- {
- readonly hpan?: string;
- readonly awardPeriodId: number;
- readonly limit?: number;
- readonly nextCursor?: number;
- readonly Authorization: string;
- },
- never,
- never,
- | r.IResponseType<200, PatchedWinningTransactionPageResource>
- | r.IResponseType<401, undefined>
- | r.IResponseType<500, undefined>
->;
-
-const cursorToQueryString = (cursor: number) => `&nextCursor=${cursor}`;
-
-const findWinningTransactionsUsingGETCustomDecoder =
- findWinningTransactionsUsingGETDecoder({
- 200: PatchedWinningTransactionPageResource
- });
-
-export const winningTransactionsV2GET: PatchedFindWinningTransactionsUsingGETT =
- {
- method: "get",
- url: ({ awardPeriodId, nextCursor }) =>
- `/bpd/io/winning-transactions/v2?awardPeriodId=${awardPeriodId}${pipe(
- nextCursor,
- O.fromNullable,
- O.map(cursorToQueryString),
- O.getOrElse(() => "")
- )}`,
- query: _ => ({}),
- headers: bpdHeadersProducers(),
- response_decoder: findWinningTransactionsUsingGETCustomDecoder
- };
diff --git a/ts/features/bonus/bpd/components/BaseDailyTransactionHeader.tsx b/ts/features/bonus/bpd/components/BaseDailyTransactionHeader.tsx
deleted file mode 100644
index c6decd1a018..00000000000
--- a/ts/features/bonus/bpd/components/BaseDailyTransactionHeader.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { IOColors, Icon } from "@pagopa/io-app-design-system";
-import I18n from "../../../../i18n";
-import { H3 } from "../../../../components/core/typography/H3";
-import { H5 } from "../../../../components/core/typography/H5";
-import { formatIntegerNumber } from "../../../../utils/stringBuilder";
-
-type Props = {
- date: string;
- transactionsNumber: number;
-};
-
-const styles = StyleSheet.create({
- row: {
- flexDirection: "row",
- alignItems: "center"
- },
- container: {
- justifyContent: "space-between"
- },
- whiteBg: {
- backgroundColor: IOColors.white
- }
-});
-
-const BaseDailyTransactionHeader: React.FunctionComponent = (
- props: Props
-) => (
-
-
- {props.date}
-
-
-
-
-
- {` ${I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.label",
- {
- defaultValue: I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.label.other",
- {
- transactions: formatIntegerNumber(props.transactionsNumber)
- }
- ),
- count: props.transactionsNumber,
- transactions: formatIntegerNumber(props.transactionsNumber)
- }
- )}`}
-
-
- {`${I18n.t("bonus.bpd.name")} (€)`}
-
-
-);
-
-export default BaseDailyTransactionHeader;
diff --git a/ts/features/bonus/bpd/components/BpdLastUpdateComponent.tsx b/ts/features/bonus/bpd/components/BpdLastUpdateComponent.tsx
deleted file mode 100644
index ecc7ae592df..00000000000
--- a/ts/features/bonus/bpd/components/BpdLastUpdateComponent.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import * as React from "react";
-import { useEffect, useState } from "react";
-import { View, StyleSheet } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { H4 } from "../../../../components/core/typography/H4";
-import { IOStyles } from "../../../../components/core/variables/IOStyles";
-import I18n from "../../../../i18n";
-import { GlobalState } from "../../../../store/reducers/types";
-import { format, formatDateAsLocal } from "../../../../utils/dates";
-import { showToast } from "../../../../utils/showToast";
-import { bpdAllData } from "../store/actions/details";
-import { bpdLastUpdateSelector } from "../store/reducers/details/lastUpdate";
-
-type Props = ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- row: {
- flexDirection: "row",
- justifyContent: "center"
- }
-});
-
-/**
- * This component show the last time in which the bpd periods are loaded correctly
- * and allow to request a refresh of the bpd periods data.
- * @param props
- */
-const BpdLastUpdateComponent: React.FunctionComponent = (
- props: Props
-) => {
- const [isFirstRender, setIsFirstRender] = useState(true);
- const { potLastUpdate } = props;
- useEffect(() => {
- if (!isFirstRender) {
- if (pot.isError(potLastUpdate)) {
- showToast(I18n.t("global.genericError"), "danger");
- }
- } else {
- setIsFirstRender(false);
- }
- }, [potLastUpdate, isFirstRender]);
-
- return (
-
- {!pot.isNone(props.potLastUpdate) && (
-
- {I18n.t("bonus.bpd.details.lastUpdate", {
- hour: format(props.potLastUpdate.value, "HH:mm"),
- date: formatDateAsLocal(props.potLastUpdate.value, true, true)
- })}
-
- )}
-
- );
-};
-
-const mapStateToProps = (state: GlobalState) => ({
- potLastUpdate: bpdLastUpdateSelector(state)
-});
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- loadBonus: () => dispatch(bpdAllData.request())
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdLastUpdateComponent);
diff --git a/ts/features/bonus/bpd/components/BpdTestOverlay.tsx b/ts/features/bonus/bpd/components/BpdTestOverlay.tsx
deleted file mode 100644
index 7db3b49f45c..00000000000
--- a/ts/features/bonus/bpd/components/BpdTestOverlay.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import * as React from "react";
-import { useState } from "react";
-import { View, Platform, StyleSheet } from "react-native";
-
-import { getStatusBarHeight, isIphoneX } from "react-native-iphone-x-helper";
-import { IOColors, hexToRgba } from "@pagopa/io-app-design-system";
-import { Body } from "../../../../components/core/typography/Body";
-import { Label } from "../../../../components/core/typography/Label";
-import {
- bpdApiSitUrlPrefix,
- bpdApiUatUrlPrefix,
- bpdApiUrlPrefix,
- pagoPaApiUrlPrefix,
- pagoPaApiUrlPrefixTest
-} from "../../../../config";
-import { getAppVersion } from "../../../../utils/appVersion";
-
-const opaqueBgColor = hexToRgba(IOColors.white, 0.67);
-
-const styles = StyleSheet.create({
- versionContainer: {
- position: "absolute",
- top: Platform.select({
- ios: 20 + (isIphoneX() ? getStatusBarHeight() : 0),
- android: 0
- }),
- left: 0,
- right: 0,
- bottom: 0,
- justifyContent: "flex-start",
- alignItems: "center",
- zIndex: 1000
- },
- versionText: {
- padding: 2,
- backgroundColor: opaqueBgColor
- }
-});
-
-/**
- * Temp overlay created to avoid ambiguity when test bpd versions are released.
- * TODO: remove after the release of bpd
- * @constructor
- */
-export const BpdTestOverlay: React.FunctionComponent = () => {
- const [enabled, setEnabled] = useState(true);
- const bpdEndpointStr =
- bpdApiUrlPrefix === bpdApiSitUrlPrefix
- ? "SIT"
- : bpdApiUrlPrefix === bpdApiUatUrlPrefix
- ? "UAT"
- : "PROD";
-
- const pmEndpointStr =
- pagoPaApiUrlPrefix === pagoPaApiUrlPrefixTest ? "UAT" : "PROD";
-
- return (
-
- {enabled ? (
- <>
-
- setEnabled(!enabled)}
- >{`${getAppVersion()} - bpd: ${bpdEndpointStr} - PM: ${pmEndpointStr}`}
- >
- ) : null}
-
- );
-};
diff --git a/ts/features/bonus/bpd/components/BpdTransactionSummaryComponent.tsx b/ts/features/bonus/bpd/components/BpdTransactionSummaryComponent.tsx
deleted file mode 100644
index 9fbe8b8a9e5..00000000000
--- a/ts/features/bonus/bpd/components/BpdTransactionSummaryComponent.tsx
+++ /dev/null
@@ -1,155 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { TouchableWithoutFeedback } from "@gorhom/bottom-sheet";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import { Body } from "../../../../components/core/typography/Body";
-import { H4 } from "../../../../components/core/typography/H4";
-import { InfoBox } from "../../../../components/box/InfoBox";
-import { useLegacyIOBottomSheetModal } from "../../../../utils/hooks/bottomSheet";
-import { Link } from "../../../../components/core/typography/Link";
-import { openWebUrl } from "../../../../utils/url";
-import Markdown from "../../../../components/ui/Markdown";
-import I18n from "../../../../i18n";
-import { localeDateFormat } from "../../../../utils/locale";
-import {
- formatIntegerNumber,
- formatNumberAmount
-} from "../../../../utils/stringBuilder";
-import { BpdAmount } from "../saga/networking/amount";
-import { BpdPeriod } from "../store/actions/periods";
-
-type Props = {
- lastUpdateDate: string;
- period: BpdPeriod;
- totalAmount: BpdAmount;
-};
-
-const styles = StyleSheet.create({
- row: {
- flexDirection: "row",
- alignItems: "center"
- },
- readMore: { marginLeft: 31, marginBottom: 24 }
-});
-
-const readMoreLink = "https://io.italia.it/cashback/acquirer/";
-
-const CSS_STYLE = `
-body {
- font-size: 16;
- color: ${IOColors.black}
-}
-`;
-
-export const BottomSheetBpdTransactionsBody: React.FunctionComponent = () => {
- const [CTAVisibility, setCTAVisibility] = React.useState(false);
-
- const setCTAVisible = () => setCTAVisibility(true);
-
- return (
- <>
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.bottomSheet.body"
- )}
-
- {CTAVisibility && (
- openWebUrl(readMoreLink)}>
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.bottomSheet.readMore"
- )}
-
-
- )}
- >
- );
-};
-
-const BpdTransactionSummaryComponent: React.FunctionComponent = (
- props: Props
-) => {
- const { present, bottomSheet } = useLegacyIOBottomSheetModal(
- <>
-
-
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text1"
- )}
-
- {" "}
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text2"
- )}
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text3"
- )}
-
-
-
-
-
- >,
- I18n.t("bonus.bpd.details.transaction.detail.summary.bottomSheet.title"),
- 600
- );
-
- return (
- <>
-
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.lastUpdated")}
- {props.lastUpdateDate}
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.link")}
-
-
-
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.body.text1")}
- {`${localeDateFormat(
- props.period.startDate,
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- )} - ${localeDateFormat(
- props.period.endDate,
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- )} `}
- {I18n.t("bonus.bpd.details.transaction.detail.summary.body.text2")}
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.body.text3", {
- defaultValue: I18n.t(
- "bonus.bpd.details.transaction.detail.summary.body.text3.other",
- {
- transactions: formatIntegerNumber(
- props.totalAmount.transactionNumber
- )
- }
- ),
- count: props.totalAmount.transactionNumber,
- transactions: formatIntegerNumber(
- props.totalAmount.transactionNumber
- )
- })}
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.body.text4")}
- {`${I18n.t(
- "bonus.bpd.details.transaction.detail.summary.body.text5"
- )}${formatNumberAmount(props.totalAmount.totalCashback)} euro.`}
-
- {bottomSheet}
- >
- );
-};
-
-export default BpdTransactionSummaryComponent;
diff --git a/ts/features/bonus/bpd/components/__test__/BottomSheetMethodsToDelete.test.tsx b/ts/features/bonus/bpd/components/__test__/BottomSheetMethodsToDelete.test.tsx
deleted file mode 100644
index 83fbf71e329..00000000000
--- a/ts/features/bonus/bpd/components/__test__/BottomSheetMethodsToDelete.test.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { render } from "@testing-library/react-native";
-import React from "react";
-import { BottomSheetMethodsToDelete } from "../optInStatus/BottomSheetMethodsToDelete";
-import { mockCreditCardPaymentMethod } from "../../../../../store/reducers/wallet/__mocks__/wallets";
-
-describe("BottomSheetMethodsToDelete", () => {
- jest.useFakeTimers();
- it(`component should be defined`, () => {
- const renderComponent = render(
-
- );
- expect(
- renderComponent.queryByTestId("BottomSheetMethodsToDeleteTestID")
- ).not.toBeNull();
- });
-
- describe("when some methods are available", () => {
- it(`should shown all these items`, () => {
- const paymentMethods = [
- { ...mockCreditCardPaymentMethod, idWallet: 1 },
- { ...mockCreditCardPaymentMethod, idWallet: 2 },
- { ...mockCreditCardPaymentMethod, idWallet: 3 }
- ];
- const renderComponent = render(
-
- );
- expect(
- renderComponent.queryByTestId("BottomSheetMethodsToDeleteTestID")
- ).not.toBeNull();
- paymentMethods.forEach(pm => {
- expect(
- renderComponent.queryByTestId(`payment_method_${pm.idWallet}`)
- ).not.toBeNull();
- });
- });
- });
-});
diff --git a/ts/features/bonus/bpd/components/bpdCardComponent/BpdCardComponent.tsx b/ts/features/bonus/bpd/components/bpdCardComponent/BpdCardComponent.tsx
deleted file mode 100644
index 1e3977c604f..00000000000
--- a/ts/features/bonus/bpd/components/bpdCardComponent/BpdCardComponent.tsx
+++ /dev/null
@@ -1,440 +0,0 @@
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import {
- Text,
- View,
- Image,
- ImageBackground,
- Platform,
- StyleSheet
-} from "react-native";
-import { widthPercentageToDP } from "react-native-responsive-screen";
-import {
- Icon,
- hexToRgba,
- IOColors,
- HSpacer
-} from "@pagopa/io-app-design-system";
-import bpdCardBgFull from "../../../../../../img/bonus/bpd/bonus_bg.png";
-import bpdCardBgPreview from "../../../../../../img/bonus/bpd/bonus_preview_bg.png";
-import bpdBonusLogo from "../../../../../../img/bonus/bpd/logo_BonusCashback_White.png";
-import { H2 } from "../../../../../components/core/typography/H2";
-import { H4 } from "../../../../../components/core/typography/H4";
-import { H5 } from "../../../../../components/core/typography/H5";
-import TouchableDefaultOpacity from "../../../../../components/TouchableDefaultOpacity";
-import I18n from "../../../../../i18n";
-import { localeDateFormat } from "../../../../../utils/locale";
-import { formatNumberAmount } from "../../../../../utils/stringBuilder";
-import { BpdAmount } from "../../saga/networking/amount";
-import { BpdPeriod, BpdPeriodStatus } from "../../store/actions/periods";
-import { makeFontStyleObject } from "../../../../../components/core/fonts";
-import { IOBadge } from "../../../../../components/core/IOBadge";
-
-type Props = {
- period: BpdPeriod;
- totalAmount: BpdAmount;
- preview?: boolean;
- onPress?: () => void;
-};
-
-const opaqueBorderColor = hexToRgba(IOColors.black, 0.1);
-
-const styles = StyleSheet.create({
- flex1: {
- flex: 1
- },
- flex2: {
- flex: 2
- },
- container: {
- flex: 1,
- height: 192
- },
- paddedContentFull: {
- paddingLeft: 16,
- paddingTop: 24,
- paddingRight: 20,
- paddingBottom: 16
- },
- paddedContentPreview: {
- paddingLeft: 18,
- paddingTop: 8,
- paddingRight: 22
- },
- row: {
- flexDirection: "row"
- },
- column: {
- flexDirection: "column"
- },
- spaced: {
- justifyContent: "space-between"
- },
- fullLogo: {
- resizeMode: "contain",
- height: 56,
- width: 56,
- alignSelf: "flex-end"
- },
- previewLogo: {
- resizeMode: "contain",
- height: 40,
- width: 40,
- alignSelf: "center"
- },
- preview: {
- marginBottom: -20,
- height: 88
- },
- imageFull: {
- resizeMode: "stretch",
- height: "100%"
- },
- imagePreview: {
- resizeMode: "stretch",
- height: 88,
- width: "100%"
- },
- amountTextBaseFull: {
- color: IOColors.white,
- fontSize: 24,
- lineHeight: 35,
- // solution taken from https://github.com/facebook/react-native/issues/7687#issuecomment-309168661
- paddingTop: Platform.select({
- ios: 0,
- android: 10
- }),
- marginBottom: -8,
- ...makeFontStyleObject("Bold")
- },
- amountTextUpperFull: {
- color: IOColors.white,
- fontSize: 32,
- ...makeFontStyleObject("Bold")
- },
- amountTextBasePreview: {
- fontSize: 16,
- lineHeight: 32,
- color: IOColors.white,
- ...makeFontStyleObject("Bold")
- },
- amountTextUpperPreview: {
- color: IOColors.white,
- fontSize: 24,
- ...makeFontStyleObject("Bold")
- },
- alignItemsCenter: {
- alignItems: "center"
- },
- justifyContentCenter: {
- justifyContent: "center"
- },
- upperShadowBox: {
- marginBottom: -13,
- borderRadius: 8,
- borderTopWidth: 13,
- borderTopColor: opaqueBorderColor,
- height: 17,
- width: "100%"
- },
- bottomShadowBox: {
- marginBottom: 6,
- borderRadius: 8,
- borderBottomWidth: 15,
- borderBottomColor: opaqueBorderColor,
- width: "100%"
- }
-});
-
-type BadgeDefinition = {
- label: string;
-};
-
-type IconType = "locked" | "unlocked" | "ok";
-
-type GraphicalState = {
- amount: ReadonlyArray;
- isInGracePeriod: boolean;
- iconName: IconType;
- statusBadge: BadgeDefinition;
-};
-
-const initialGraphicalState: GraphicalState = {
- amount: ["0", "00"],
- isInGracePeriod: false,
- iconName: "locked",
- statusBadge: {
- label: "-"
- }
-};
-
-/**
- * Closed lock must be shown if period is Inactive or the transactionNumber didn't reach the minimum target
- * Open lock must be shown if period is Closed or Active and the transactionNumber reach the minimum target
- * "Ok" (was Fireworks) must be shown if period is Closed or Active and the totalCashback reach the maxAmount
- *
- * @param period
- * @param totalAmount
- */
-const iconHandler = (period: BpdPeriod, totalAmount: BpdAmount): IconType => {
- const reachMinTransaction =
- totalAmount.transactionNumber >= period.minTransactionNumber;
- const reachMaxAmount = totalAmount.totalCashback >= period.maxPeriodCashback;
- switch (period.status) {
- case "Active":
- case "Closed":
- return reachMinTransaction && reachMaxAmount
- ? "ok"
- : reachMinTransaction
- ? "unlocked"
- : "locked";
- default:
- return "locked";
- }
-};
-
-const statusClosedHandler = (props: Props): GraphicalState => {
- const { period, totalAmount } = props;
-
- const actualDate = new Date();
- const endDate = new Date(period.endDate.getTime());
- endDate.setDate(endDate.getDate() + period.gracePeriod);
-
- const isInGracePeriod =
- actualDate.getTime() >= period.endDate.getTime() &&
- actualDate.getTime() <= endDate.getTime();
-
- return {
- ...initialGraphicalState,
- amount:
- totalAmount.transactionNumber < period.minTransactionNumber &&
- !isInGracePeriod
- ? ["0", "00"]
- : formatNumberAmount(props.totalAmount.totalCashback).split(
- I18n.t("global.localization.decimalSeparator")
- ),
- isInGracePeriod,
- iconName: iconHandler(props.period, props.totalAmount),
- // TODO: Add supercashback business logic
- statusBadge: isInGracePeriod
- ? {
- label: I18n.t("profile.preferences.list.wip")
- }
- : {
- label: I18n.t("bonus.bpd.details.card.status.closed")
- }
- };
-};
-
-const statusActiveHandler = (props: Props): GraphicalState => ({
- ...initialGraphicalState,
- statusBadge: {
- label: I18n.t("bonus.bpd.details.card.status.active")
- },
- amount: formatNumberAmount(props.totalAmount.totalCashback).split(
- I18n.t("global.localization.decimalSeparator")
- ),
- iconName: iconHandler(props.period, props.totalAmount)
-});
-
-const statusInactiveHandler = (props: Props): GraphicalState => ({
- ...initialGraphicalState,
- statusBadge: {
- label: I18n.t("bonus.bpd.details.card.status.inactive")
- },
- amount: formatNumberAmount(props.totalAmount.totalCashback).split(
- I18n.t("global.localization.decimalSeparator")
- )
-});
-
-const statusHandlersMap = new Map<
- BpdPeriodStatus,
- (props: Props) => GraphicalState
->([
- ["Closed", statusClosedHandler],
- ["Active", statusActiveHandler],
- ["Inactive", statusInactiveHandler]
-]);
-
-/**
- * if the period is Closed we must check if minimum number of transactions has been reached
- * Unless we'll show a Zero amount value
- *
- * GracePeriod: check if we are in the grace period to show an alert instead of the value
- * grace period is given adding the gracePeriod value of days to period.endDate
- */
-const calculateGraphicalState = (props: Props) =>
- pipe(
- statusHandlersMap.get(props.period.status),
- O.fromNullable,
- O.fold(
- () => initialGraphicalState,
- handler => handler(props)
- )
- );
-
-export const BpdCardComponent: React.FunctionComponent = (
- props: Props
-) => {
- const { amount, isInGracePeriod, iconName, statusBadge } =
- calculateGraphicalState(props);
-
- const isPeriodClosed = props.period.status === "Closed" && !isInGracePeriod;
- const isPeriodInactive = props.period.status === "Inactive";
-
- const FullCard = () => (
-
-
-
-
- {I18n.t("bonus.bpd.title")}
-
-
- {`${localeDateFormat(
- props.period.startDate,
- I18n.t("global.dateFormats.fullFormatShortMonthLiteral")
- )} - ${localeDateFormat(
- props.period.endDate,
- I18n.t("global.dateFormats.fullFormatShortMonthLiteral")
- )}`}
-
-
-
-
- {/* NBCard Text component */}
-
- {"€ "}
-
- {`${amount[0]}${I18n.t(
- "global.localization.decimalSeparator"
- )}`}
-
- {amount[1]}
-
-
-
-
-
- {I18n.t("bonus.bpd.earned")}
-
-
-
-
-
-
-
-
- );
-
- const PreviewCard = () => (
-
-
-
-
- {`${localeDateFormat(
- props.period.startDate,
- I18n.t("global.dateFormats.dayFullMonth")
- )} - ${localeDateFormat(
- props.period.endDate,
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- )}`}
-
-
- {isPeriodClosed && }
-
-
-
- {I18n.t("bonus.bpd.name")}
-
-
-
-
- {isInGracePeriod || isPeriodInactive ? (
-
- ) : (
-
- {"€ "}
-
- {`${amount[0]}${I18n.t(
- "global.localization.decimalSeparator"
- )}`}
-
- {amount[1]}
-
- )}
-
-
-
-
-
- );
-
- return (
- <>
- {Platform.OS === "android" && (
-
- )}
-
- {props.preview ? : }
-
- {Platform.OS === "android" && !props.preview && (
-
- )}
- >
- );
-};
diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx b/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx
deleted file mode 100644
index 811bfaa47ae..00000000000
--- a/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { useNavigation } from "@react-navigation/native";
-import * as React from "react";
-import { useContext, useEffect, useState } from "react";
-import { useDispatch } from "react-redux";
-import { isError, isReady } from "../../../../../common/model/RemoteValue";
-import LoadingSpinnerOverlay from "../../../../../components/LoadingSpinnerOverlay";
-import { LightModalContext } from "../../../../../components/ui/LightModal";
-import I18n from "../../../../../i18n";
-import { useIOSelector } from "../../../../../store/hooks";
-import { optInPaymentMethodsShowChoice } from "../../store/actions/optInPaymentMethods";
-import { showOptInChoiceSelector } from "../../store/reducers/details/activation/ui";
-import { bpdLastUpdateSelector } from "../../store/reducers/details/lastUpdate";
-
-const BpdOptInPaymentMethodsContainer = () => {
- const dispatch = useDispatch();
- const navigation = useNavigation();
- const { showModal, hideModal } = useContext(LightModalContext);
- const [showOptInChecked, setShowOptInChecked] = useState(false);
- const showOptInChoice = useIOSelector(showOptInChoiceSelector);
- const bpdLastUpdate = useIOSelector(bpdLastUpdateSelector);
-
- useEffect(() => {
- if (!showOptInChecked && !isReady(showOptInChoice)) {
- setShowOptInChecked(true);
- // Starts the optInShouldShowChoiceHandler saga
- dispatch(optInPaymentMethodsShowChoice.request());
- showModal(
-
- );
- }
- }, [dispatch, showOptInChecked, bpdLastUpdate, showModal, showOptInChoice]);
-
- useEffect(() => {
- if (isReady(showOptInChoice) || isError(showOptInChoice)) {
- hideModal();
- }
- }, [hideModal, showOptInChoice, navigation]);
-
- return <>>;
-};
-
-export default BpdOptInPaymentMethodsContainer;
diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/RetryAfterDeletionFailsComponent.tsx b/ts/features/bonus/bpd/components/optInPaymentMethods/RetryAfterDeletionFailsComponent.tsx
deleted file mode 100644
index 1ce4d767b83..00000000000
--- a/ts/features/bonus/bpd/components/optInPaymentMethods/RetryAfterDeletionFailsComponent.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import React from "react";
-import { SafeAreaView } from "react-native";
-import { useDispatch } from "react-redux";
-import { InfoScreenComponent } from "../../../../../components/infoScreen/InfoScreenComponent";
-import Error from "../../../../../../img/wallet/errors/generic-error-icon.svg";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import {
- cancelButtonProps,
- confirmButtonProps
-} from "../../../../../components/buttons/ButtonConfigurations";
-import {
- optInPaymentMethodsCompleted,
- optInPaymentMethodsDeletionChoice
-} from "../../store/actions/optInPaymentMethods";
-import FooterWithButtons from "../../../../../components/ui/FooterWithButtons";
-import I18n from "../../../../../i18n";
-
-const RetryAfterDeletionFailsComponent = () => {
- const dispatch = useDispatch();
-
- return (
-
- }
- title={I18n.t(
- "bonus.bpd.optInPaymentMethods.thankYouPage.retryAfterDeletion.title"
- )}
- body={I18n.t(
- "bonus.bpd.optInPaymentMethods.thankYouPage.retryAfterDeletion.body"
- )}
- />
- dispatch(optInPaymentMethodsDeletionChoice()),
- I18n.t("bonus.bpd.optInPaymentMethods.thankYouPage.cta.retry"),
- undefined,
- "retryButton"
- )}
- rightButton={cancelButtonProps(
- () => dispatch(optInPaymentMethodsCompleted()),
- I18n.t("bonus.bpd.optInPaymentMethods.thankYouPage.cta.goToWallet"),
- undefined,
- "goToWalletButton"
- )}
- />
-
- );
-};
-
-export default RetryAfterDeletionFailsComponent;
diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/ThankYouSuccessComponent.tsx b/ts/features/bonus/bpd/components/optInPaymentMethods/ThankYouSuccessComponent.tsx
deleted file mode 100644
index a0fe882e4ca..00000000000
--- a/ts/features/bonus/bpd/components/optInPaymentMethods/ThankYouSuccessComponent.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { useNavigation } from "@react-navigation/native";
-import React from "react";
-import { SafeAreaView } from "react-native";
-import Completed from "../../../../../../img/pictograms/payment-completed.svg";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import { InfoScreenComponent } from "../../../../../components/infoScreen/InfoScreenComponent";
-import FooterWithButtons from "../../../../../components/ui/FooterWithButtons";
-import I18n from "../../../../../i18n";
-import ROUTES from "../../../../../navigation/routes";
-import { useIODispatch } from "../../../../../store/hooks";
-import { cancelButtonProps } from "../../../../../components/buttons/ButtonConfigurations";
-import {
- optInPaymentMethodsCompleted,
- optInPaymentMethodsShowChoice
-} from "../../store/actions/optInPaymentMethods";
-
-const ThankYouSuccessComponent = () => {
- const navigation = useNavigation();
- const dispatch = useIODispatch();
- return (
-
- }
- title={I18n.t(
- "bonus.bpd.optInPaymentMethods.thankYouPage.success.title"
- )}
- body={I18n.t("bonus.bpd.optInPaymentMethods.thankYouPage.success.body")}
- />
- {
- dispatch(optInPaymentMethodsCompleted());
- dispatch(optInPaymentMethodsShowChoice.success(false));
- navigation.navigate(ROUTES.WALLET_HOME);
- },
- I18n.t("bonus.bpd.optInPaymentMethods.thankYouPage.cta.goToWallet"),
- undefined,
- "goToWalletButton"
- )}
- />
-
- );
-};
-
-export default ThankYouSuccessComponent;
diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/RetryAfterDeletionFailsComponent.test.ts b/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/RetryAfterDeletionFailsComponent.test.ts
deleted file mode 100644
index 61d07b36bf4..00000000000
--- a/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/RetryAfterDeletionFailsComponent.test.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { createStore, Store } from "redux";
-
-import { fireEvent, RenderAPI } from "@testing-library/react-native";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper";
-import ROUTES from "../../../../../../navigation/routes";
-import RetryAfterDeletionFailsComponent from "../RetryAfterDeletionFailsComponent";
-import { appReducer } from "../../../../../../store/reducers";
-import { applicationChangeState } from "../../../../../../store/actions/application";
-import * as optInPaymentMethodsActions from "../../../store/actions/optInPaymentMethods";
-
-jest.useFakeTimers();
-
-describe("the RetryAfterDeletionFailsComponent screen", () => {
- const globalState = appReducer(undefined, applicationChangeState("active"));
-
- it("Should call the optInPaymentMethodsCompleted functions when the goToWalletButton is pressed", () => {
- const optInPaymentMethodsCompletedSpy = jest.spyOn(
- optInPaymentMethodsActions,
- "optInPaymentMethodsCompleted"
- );
- const store: Store = createStore(
- appReducer,
- globalState as any
- );
- const component: RenderAPI = renderComponent(store);
- fireEvent.press(component.getByTestId("goToWalletButton"));
- expect(optInPaymentMethodsCompletedSpy).toBeCalledTimes(1);
- });
- it("Should call the optInPaymentMethodsDeletionChoice functions when the retryButton is pressed", () => {
- const optInPaymentMethodsDeletionChoiceSpy = jest.spyOn(
- optInPaymentMethodsActions,
- "optInPaymentMethodsDeletionChoice"
- );
- const store: Store = createStore(
- appReducer,
- globalState as any
- );
- const component: RenderAPI = renderComponent(store);
- fireEvent.press(component.getByTestId("retryButton"));
- expect(optInPaymentMethodsDeletionChoiceSpy).toBeCalledTimes(1);
- });
-});
-
-function renderComponent(store: Store) {
- return renderScreenWithNavigationStoreContext(
- RetryAfterDeletionFailsComponent,
- ROUTES.MAIN,
- {},
- store
- );
-}
diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/ThankYouSuccessComponent.test.ts b/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/ThankYouSuccessComponent.test.ts
deleted file mode 100644
index 01aafce5dc8..00000000000
--- a/ts/features/bonus/bpd/components/optInPaymentMethods/__tests__/ThankYouSuccessComponent.test.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { createStore, Store } from "redux";
-
-import { fireEvent, RenderAPI } from "@testing-library/react-native";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper";
-import ROUTES from "../../../../../../navigation/routes";
-import { appReducer } from "../../../../../../store/reducers";
-import { applicationChangeState } from "../../../../../../store/actions/application";
-import * as optInPaymentMethodsActions from "../../../store/actions/optInPaymentMethods";
-import ThankYouSuccessComponent from "../ThankYouSuccessComponent";
-
-jest.useFakeTimers();
-
-describe("the ThankYouSuccessComponent screen", () => {
- const globalState = appReducer(undefined, applicationChangeState("active"));
-
- it("Should call the optInPaymentMethodsCompleted functions when the goToWalletButton is pressed", () => {
- const optInPaymentMethodsCompletedSpy = jest.spyOn(
- optInPaymentMethodsActions,
- "optInPaymentMethodsCompleted"
- );
- const store: Store = createStore(
- appReducer,
- globalState as any
- );
- const component: RenderAPI = renderComponent(store);
- fireEvent.press(component.getByTestId("goToWalletButton"));
- expect(optInPaymentMethodsCompletedSpy).toBeCalledTimes(1);
- });
-});
-
-function renderComponent(store: Store) {
- return renderScreenWithNavigationStoreContext(
- ThankYouSuccessComponent,
- ROUTES.MAIN,
- {},
- store
- );
-}
diff --git a/ts/features/bonus/bpd/components/optInStatus/BottomSheetMethodsToDelete.tsx b/ts/features/bonus/bpd/components/optInStatus/BottomSheetMethodsToDelete.tsx
deleted file mode 100644
index 5c8d037a7ea..00000000000
--- a/ts/features/bonus/bpd/components/optInStatus/BottomSheetMethodsToDelete.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import { ListItem } from "native-base";
-import * as React from "react";
-import { View, Dimensions } from "react-native";
-import { useSelector } from "react-redux";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import { H3 } from "../../../../../components/core/typography/H3";
-import { Label } from "../../../../../components/core/typography/Label";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import FooterWithButtons from "../../../../../components/ui/FooterWithButtons";
-import I18n from "../../../../../i18n";
-import { getBPDMethodsVisibleInWalletSelector } from "../../../../../store/reducers/wallet/wallets";
-import { PaymentMethod } from "../../../../../types/pagopa";
-import { useLegacyIOBottomSheetModal } from "../../../../../utils/hooks/bottomSheet";
-import { PaymentMethodRepresentationComponent } from "../paymentMethodActivationToggle/base/PaymentMethodRepresentationComponent";
-
-type Props = {
- paymentMethods: ReadonlyArray;
-};
-
-export const BottomSheetMethodsToDelete = (props: Props) => (
-
-
-
- {props.paymentMethods.map(pm => (
-
-
-
- ))}
-
-);
-
-type BottomSheetReturnType = {
- presentBottomSheet: () => void;
- bottomSheet: React.ReactNode;
-};
-
-/**
- * return an hook that exposes presentBottomSheet function to imperative show a bottomsheet
- * containing the list of those payment methods that have BPD as function enabled
- * @param props
- */
-export const useBottomSheetMethodsToDelete = (props: {
- onDeletePress: () => void;
-}): BottomSheetReturnType => {
- const paymentMethods = useSelector(getBPDMethodsVisibleInWalletSelector);
- const snapPoint = Math.min(
- Dimensions.get("window").height * 0.8,
- // (subtitle + footer) + items
- 280 + paymentMethods.length * 58
- );
- const { present, bottomSheet, dismiss } = useLegacyIOBottomSheetModal(
- ,
-
-
- {I18n.t(
- "bonus.bpd.optInPaymentMethods.deletePaymentMethodsBottomSheet.title"
- )}
-
-
- ,
- snapPoint,
- {
- props.onDeletePress();
- dismiss();
- },
- title: I18n.t("global.buttons.delete")
- }}
- rightButton={{
- testID: "cancelButtonTestID",
- bordered: true,
- onPressWithGestureHandler: true,
- onPress: () => dismiss(),
- title: I18n.t("global.buttons.cancel")
- }}
- />
- );
-
- return {
- presentBottomSheet: present,
- bottomSheet
- };
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/BpdPaymentMethodToggleFactory.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/BpdPaymentMethodToggleFactory.tsx
deleted file mode 100644
index 5c677805e53..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/BpdPaymentMethodToggleFactory.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import * as React from "react";
-import { PaymentMethod } from "../../../../../types/pagopa";
-import { hasFunctionEnabled } from "../../../../../utils/walletv2";
-import { HPan } from "../../store/actions/paymentMethods";
-import { getPaymentMethodHash } from "../../../../../utils/paymentMethod";
-import { EnableableFunctionsEnum } from "../../../../../../definitions/pagopa/EnableableFunctions";
-import PaymentMethodBpdToggle from "./base/PaymentMethodBpdToggle";
-
-/**
- * Return a specific toggle based on the WalletTypeEnum
- * @param paymentMethod
- */
-export const bpdToggleFactory = (paymentMethod: PaymentMethod) => {
- const hash = getPaymentMethodHash(paymentMethod);
- return hash ? (
-
- ) : null;
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/BpdToggle.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/BpdToggle.tsx
deleted file mode 100644
index ed23b0c70c8..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/BpdToggle.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import * as React from "react";
-import { ActivityIndicator } from "react-native";
-import { Icon } from "@pagopa/io-app-design-system";
-import Switch from "../../../../../../components/ui/Switch";
-import TouchableDefaultOpacity from "../../../../../../components/TouchableDefaultOpacity";
-import { GraphicalValue } from "./PaymentMethodBpdToggle";
-
-type Props = {
- graphicalValue: GraphicalValue;
- // The use choose to change the value of the toggle
- onValueChanged?: (b: boolean) => void;
- // The user tap the "notice" icon when the graphical state is "notActivable"
- onPress?: () => void;
-};
-
-const iconSize = 24;
-
-/**
- * The toggle used in {@link PaymentMethodBpdToggle}.
- * @param props
- * @constructor
- */
-export const BpdToggle: React.FunctionComponent = props => {
- switch (props.graphicalValue.state) {
- case "loading":
- return (
-
- );
- case "ready":
- case "update":
- return props.graphicalValue.value === "notActivable" ? (
-
-
-
- ) : (
-
- );
- }
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodBpdToggle.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodBpdToggle.tsx
deleted file mode 100644
index 50a54b535ab..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodBpdToggle.tsx
+++ /dev/null
@@ -1,217 +0,0 @@
-/* eslint-disable functional/immutable-data */
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { useNavigation } from "@react-navigation/native";
-import * as React from "react";
-import { useCallback, useEffect, useRef, useState } from "react";
-import { View, ImageSourcePropType, StyleSheet } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { fetchPaymentManagerLongTimeout } from "../../../../../../config";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import {
- bpdPaymentMethodActivation,
- BpdPaymentMethodActivation,
- BpdPmActivationStatus,
- bpdUpdatePaymentMethodActivation,
- HPan
-} from "../../../store/actions/paymentMethods";
-import { bpdPaymentMethodValueSelector } from "../../../store/reducers/details/paymentMethods";
-import { useChangeActivationConfirmationBottomSheet } from "../bottomsheet/BpdChangeActivationConfirmationScreen";
-import {
- NotActivableType,
- useNotActivableInformationBottomSheet
-} from "../bottomsheet/BpdNotActivableInformation";
-import { BpdToggle } from "./BpdToggle";
-import { PaymentMethodRepresentationComponent } from "./PaymentMethodRepresentationComponent";
-
-// TODO: accept only hpan, read all the other information with a selector from payment methods
-export type BpdToggleProps = {
- hPan: HPan;
- icon: ImageSourcePropType;
- caption: string;
- hasBpdCapability: boolean;
-};
-
-export type Props = ReturnType &
- ReturnType &
- BpdToggleProps;
-
-type GraphicalState = "loading" | "ready" | "update";
-
-export type GraphicalValue = {
- state: GraphicalState;
- value: BpdPmActivationStatus | undefined;
-};
-
-const styles = StyleSheet.create({
- row: {
- flex: 1,
- flexDirection: "row",
- alignItems: "center",
- height: 48
- }
-});
-
-/**
- * This custom hook handles the load of the initial state and the retry in case of error.
- * TODO: refactor with {@link useLoadPotValue}
- * @deprecated
- * @param props
- */
-const useInitialValue = (props: Props) => {
- const timerRetry = useRef(undefined);
- const navigation = useNavigation();
- const isFocused = navigation.isFocused();
- const { bpdPotActivation, hPan, loadActualValue, hasBpdCapability } = props;
-
- const retry = useCallback(() => {
- timerRetry.current = undefined;
- if (hasBpdCapability) {
- loadActualValue(hPan);
- }
- }, [loadActualValue, hPan, hasBpdCapability]);
-
- /**
- * When the focus change, clear the timer (if any) and reset the value to undefined
- * focus: true -> a new schedule is allowed
- * focus: false -> clear all the pending schedule
- */
-
- useEffect(() => {
- clearTimeout(timerRetry.current);
- timerRetry.current = undefined;
- }, [isFocused]);
-
- useEffect(() => {
- if (!hasBpdCapability) {
- return;
- }
- // Initial state, request the state
- if (bpdPotActivation === pot.none) {
- loadActualValue(hPan);
- } else if (
- pot.isNone(bpdPotActivation) &&
- pot.isError(bpdPotActivation) &&
- timerRetry.current === undefined &&
- isFocused
- ) {
- // If the pot is NoneError, the navigation focus is on the element
- // and no other retry are scheduled
- timerRetry.current = setTimeout(retry, fetchPaymentManagerLongTimeout);
- }
- }, [
- bpdPotActivation,
- hPan,
- loadActualValue,
- retry,
- isFocused,
- hasBpdCapability
- ]);
-
- // Component unmount, clear scheduled
- useEffect(
- () => () => {
- clearTimeout(timerRetry.current);
- },
- []
- );
-};
-
-const loading: GraphicalValue = { state: "loading", value: undefined };
-
-/**
- * Calculate the graphical state based on the pot possible states
- * @param potBpdActivation
- */
-export const calculateBpdToggleGraphicalState = (
- potBpdActivation: pot.Pot
-): GraphicalValue =>
- pot.fold(
- potBpdActivation,
- () => loading,
- () => loading,
- _ => loading,
- _ => loading,
- value => ({ state: "ready", value: value.activationStatus }),
- value => ({ state: "loading", value: value.activationStatus }),
- (_, newValue) => ({
- state: "update",
- value: newValue.activationStatus
- }),
- value => ({ state: "ready", value: value.activationStatus })
- );
-
-/**
- * This component represents the activation state of bpd on a payment method.
- * - Load the initial value (is bpd active on the payment method)
- * - The toggle allows the user to enable or disable bpd on the payment method
- * - Sync the remote communication with the graphical states
- * Bpd can also be "not activable" on the payment method:
- * - The payment method doesn't have the capability
- * - Bpd is already activate on the payment method by another user
- * @constructor
- */
-const PaymentMethodActivationToggle: React.FunctionComponent = props => {
- // Calculate the graphical state based on the potActivation and capability
- const graphicalState: GraphicalValue = props.hasBpdCapability
- ? calculateBpdToggleGraphicalState(props.bpdPotActivation)
- : { state: "ready", value: "notActivable" };
-
- const [toggleValue, setToggleValue] = useState(
- graphicalState.value === "active"
- );
- // trigger the initial loading / retry
- useInitialValue(props);
-
- // a simplification because the onPress is dispatched only when is not activable / compatible
- const notActivableType: NotActivableType = !props.hasBpdCapability
- ? "NotCompatible"
- : "NotActivable";
-
- const {
- present: askConfirmation,
- bottomSheet: changeActivationConfirmationBS
- } = useChangeActivationConfirmationBottomSheet(props, toggleValue, () =>
- props.updateValue(props.hPan, toggleValue)
- );
-
- const { present: showExplanation, bottomSheet: notAvailableInformationBS } =
- useNotActivableInformationBottomSheet(props, notActivableType);
-
- return (
- <>
-
-
- {
- setToggleValue(newVal);
- askConfirmation();
- }}
- onPress={showExplanation}
- />
-
- {changeActivationConfirmationBS}
- {notAvailableInformationBS}
- >
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- loadActualValue: (hPan: HPan) =>
- dispatch(bpdPaymentMethodActivation.request(hPan)),
- updateValue: (hPan: HPan, value: boolean) =>
- dispatch(bpdUpdatePaymentMethodActivation.request({ hPan, value }))
-});
-
-const mapStateToProps = (state: GlobalState, props: BpdToggleProps) => ({
- bpdPotActivation: bpdPaymentMethodValueSelector(state, props.hPan)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(PaymentMethodActivationToggle);
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodRepresentationComponent.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodRepresentationComponent.tsx
deleted file mode 100644
index 15606135b8f..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/base/PaymentMethodRepresentationComponent.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import * as React from "react";
-import { View, Image, StyleSheet } from "react-native";
-import { HSpacer } from "@pagopa/io-app-design-system";
-import { Body } from "../../../../../../components/core/typography/Body";
-import { PaymentMethodRepresentation } from "../../../../../../types/pagopa";
-
-const styles = StyleSheet.create({
- row: {
- flex: 1,
- flexDirection: "row"
- },
- cardIcon: {
- width: 40,
- height: 25,
- overflow: "hidden",
- resizeMode: "contain"
- },
- text: {
- flex: 1,
- paddingRight: 16
- }
-});
-
-/**
- * Icon + text representation of a payment method
- * @param props
- * @constructor
- */
-export const PaymentMethodRepresentationComponent: React.FunctionComponent<
- PaymentMethodRepresentation
-> = props => (
-
-
-
-
- {props.caption}
-
-
-);
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdChangeActivationConfirmationScreen.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdChangeActivationConfirmationScreen.tsx
deleted file mode 100644
index 8ea2b5df5fb..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdChangeActivationConfirmationScreen.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../components/core/typography/Body";
-import FooterWithButtons from "../../../../../../components/ui/FooterWithButtons";
-import Markdown from "../../../../../../components/ui/Markdown";
-import I18n from "../../../../../../i18n";
-import { PaymentMethodRepresentation } from "../../../../../../types/pagopa";
-import { useLegacyIOBottomSheetModal } from "../../../../../../utils/hooks/bottomSheet";
-import {
- cancelButtonProps,
- confirmButtonProps
-} from "../../../../../../components/buttons/ButtonConfigurations";
-import { PaymentMethodRepresentationComponent } from "../base/PaymentMethodRepresentationComponent";
-
-export type ConfirmationType = "Activation" | "Deactivation";
-
-type Props = {
- onCancel: () => void;
- onConfirm: () => void;
- type: ConfirmationType;
- representation: PaymentMethodRepresentation;
-};
-
-const getText = (confirmationType: ConfirmationType) => ({
- cta:
- confirmationType === "Activation"
- ? I18n.t("global.buttons.activate")
- : I18n.t("global.buttons.deactivate"),
- body:
- confirmationType === "Activation"
- ? I18n.t("bonus.bpd.details.paymentMethods.activate.body")
- : I18n.t("bonus.bpd.details.paymentMethods.deactivate.body")
-});
-
-/**
- * Confirmation bottom sheet that informs the user about the consequences about the activation / deactivation
- * @param props
- * @constructor
- */
-export const BpdChangeActivationConfirmationScreen: React.FunctionComponent<
- Props
-> = props => {
- const { body } = getText(props.type);
-
- return (
-
-
-
-
- {body}
- {props.type === "Activation" && (
- <>
-
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.activate.disclaimer", {
- activate: I18n.t("global.buttons.activate")
- })}
-
-
- >
- )}
-
- );
-};
-
-export const useChangeActivationConfirmationBottomSheet = (
- representation: PaymentMethodRepresentation,
- newVal: boolean,
- onConfirm: () => void
-) => {
- const { cta } = getText(newVal ? "Activation" : "Deactivation");
-
- const { present, bottomSheet, dismiss } = useLegacyIOBottomSheetModal(
- dismiss()}
- onConfirm={() => {
- dismiss();
- onConfirm();
- }}
- type={newVal ? "Activation" : "Deactivation"}
- representation={{
- caption: representation.caption,
- icon: representation.icon
- }}
- />,
- newVal
- ? I18n.t("bonus.bpd.details.paymentMethods.activate.title")
- : I18n.t("bonus.bpd.details.paymentMethods.deactivate.title"),
- 466,
- dismiss()),
- onPressWithGestureHandler: true
- }}
- rightButton={{
- ...confirmButtonProps(() => {
- dismiss();
- onConfirm();
- }, cta),
- onPressWithGestureHandler: true
- }}
- />
- );
-
- return { present, bottomSheet, dismiss };
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdNotActivableInformation.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdNotActivableInformation.tsx
deleted file mode 100644
index d3384635993..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/BpdNotActivableInformation.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import Markdown from "../../../../../../components/ui/Markdown";
-import I18n from "../../../../../../i18n";
-import { PaymentMethodRepresentation } from "../../../../../../types/pagopa";
-import { PaymentMethodRepresentationComponent } from "../base/PaymentMethodRepresentationComponent";
-import { useLegacyIOBottomSheetModal } from "../../../../../../utils/hooks/bottomSheet";
-
-// NotActivable: already activated by someone else
-// NotCompatible: missing bpd capability
-export type NotActivableType = "NotActivable" | "NotCompatible";
-
-type Props = {
- type: NotActivableType;
- representation: PaymentMethodRepresentation;
-};
-
-const styles = StyleSheet.create({
- body: {
- flex: 1,
- backgroundColor: IOColors.white
- }
-});
-
-const getBody = (type: NotActivableType) => {
- switch (type) {
- case "NotActivable":
- return I18n.t("bonus.bpd.details.paymentMethods.notActivable.body");
- case "NotCompatible":
- return I18n.t("bonus.bpd.details.paymentMethods.notCompatible.body");
- }
-};
-
-const getTitle = (type: NotActivableType) => {
- switch (type) {
- case "NotActivable":
- return I18n.t("bonus.bpd.details.paymentMethods.notActivable.title");
- case "NotCompatible":
- return I18n.t("bonus.bpd.details.paymentMethods.notCompatible.title");
- }
-};
-
-export const BpdNotActivableInformation: React.FunctionComponent<
- Props
-> = props => (
-
-
-
-
- {getBody(props.type)}
-
-);
-
-export const useNotActivableInformationBottomSheet = (
- representation: PaymentMethodRepresentation,
- type: NotActivableType
-) => {
- const { present, bottomSheet, dismiss } = useLegacyIOBottomSheetModal(
- ,
- getTitle(type),
- 310
- );
-
- return { present, bottomSheet, dismiss };
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/OtherChannelInformation.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/OtherChannelInformation.tsx
deleted file mode 100644
index 8931210b3d3..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/bottomsheet/OtherChannelInformation.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { none } from "fp-ts/lib/Option";
-import { View } from "react-native";
-import * as React from "react";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import BlockButtons from "../../../../../../components/ui/BlockButtons";
-import Markdown from "../../../../../../components/ui/Markdown";
-import I18n from "../../../../../../i18n";
-import { navigateToWalletAddPaymentMethod } from "../../../../../../store/actions/navigation";
-import { useLegacyIOBottomSheetModal } from "../../../../../../utils/hooks/bottomSheet";
-
-// NotActivable: already activated by someone else
-// NotCompatible: missing bpd capability
-export type NotActivableType = "NotActivable" | "NotCompatible";
-
-type Props = { onAddPayment: () => void };
-
-const addPaymentMethodButton = (onPress: () => void) => (
-
-);
-
-export const OtherChannelInformation: React.FunctionComponent<
- Props
-> = props => (
-
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.activateOnOthersChannel.body")}
-
-
- {addPaymentMethodButton(props.onAddPayment)}
-
-);
-
-export const useOtherChannelInformationBottomSheet = () => {
- const { present, bottomSheet, dismiss } = useLegacyIOBottomSheetModal(
- {
- dismiss();
- navigateToWalletAddPaymentMethod({ inPayment: none });
- }}
- />,
- I18n.t("bonus.bpd.details.paymentMethods.activateOnOthersChannel.title"),
- 350
- );
- return { present, bottomSheet, dismiss };
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodGroupedList.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodGroupedList.tsx
deleted file mode 100644
index adabe6ae390..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodGroupedList.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { Body } from "../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../components/core/typography/H4";
-import { Link } from "../../../../../../components/core/typography/Link";
-import I18n from "../../../../../../i18n";
-import { hasFunctionEnabled } from "../../../../../../utils/walletv2";
-import { useWhyOtherCardsBottomSheet } from "../../../screens/details/components/bottomsheet/WhyOtherCards";
-import { PaymentMethodWithActivation } from "../../../store/reducers/details/combiner";
-import { useOtherChannelInformationBottomSheet } from "../bottomsheet/OtherChannelInformation";
-import { EnableableFunctionsEnum } from "../../../../../../../definitions/pagopa/EnableableFunctions";
-import { PaymentMethodRawList } from "./PaymentMethodRawList";
-
-type Props = { paymentList: ReadonlyArray };
-
-const styles = StyleSheet.create({
- row: { flexDirection: "row", justifyContent: "space-between" }
-});
-
-const isOtherChannel = (w: PaymentMethodWithActivation) =>
- w.onboardingChannel === "EXT";
-
-const isNotActivable = (w: PaymentMethodWithActivation) =>
- w.activationStatus === "notActivable" ||
- !hasFunctionEnabled(w, EnableableFunctionsEnum.BPD);
-
-/**
- * A quick solution, not the best but the cardinality of the entities
- * involved doesn't requires more efficient solutions
- * @param paymentList
- */
-const clusterizePaymentMethods = (
- paymentList: ReadonlyArray
-) => ({
- otherChannels: paymentList.filter(isOtherChannel),
- notActivable: paymentList.filter(isNotActivable),
- activables: paymentList.filter(v => !isNotActivable(v) && !isOtherChannel(v))
-});
-
-const OtherChannelsSection = (props: {
- paymentMethods: ReadonlyArray;
-}) => {
- const {
- present: presentOtherChannel,
- bottomSheet: otherChannelInformationBottomSheet
- } = useOtherChannelInformationBottomSheet();
- const {
- present: presentWhyOthersCard,
- bottomSheet: whyOtherCardsBottomSheet
- } = useWhyOtherCardsBottomSheet();
-
- return (
-
-
-
-
- {I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.text1"
- )}
-
- {I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.text2"
- )}
-
-
-
- {I18n.t("global.buttons.info").toLowerCase()}
-
-
-
-
-
-
- {I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.whyOtherCards.title"
- )}
-
- {otherChannelInformationBottomSheet}
- {whyOtherCardsBottomSheet}
-
- );
-};
-
-const NotActivablesSection = (props: {
- paymentMethods: ReadonlyArray;
-}) => (
-
-
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.notActivable.header")}
-
-
-
-
-
-);
-
-/**
- * Render an array of WalletV2WithActivation, grouping different category of payment methods.
- * @param props
- * @constructor
- */
-export const PaymentMethodGroupedList: React.FunctionComponent<
- Props
-> = props => {
- const { activables, otherChannels, notActivable } = clusterizePaymentMethods(
- props.paymentList
- );
- return (
-
-
- {otherChannels.length > 0 && (
-
- )}
- {notActivable.length > 0 && (
-
- )}
-
- );
-};
diff --git a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodRawList.tsx b/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodRawList.tsx
deleted file mode 100644
index 68a6ebce03e..00000000000
--- a/ts/features/bonus/bpd/components/paymentMethodActivationToggle/list/PaymentMethodRawList.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as React from "react";
-import { View } from "react-native";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { PaymentMethod } from "../../../../../../types/pagopa";
-import { bpdToggleFactory } from "../BpdPaymentMethodToggleFactory";
-
-type Props = {
- paymentList: ReadonlyArray;
-};
-
-/**
- * Render a {@link ReadOnlyArray} of {@link EnhancedPaymentMethod} using {@link PaymentMethodBpdToggle}
- * @param props
- * @constructor
- */
-export const PaymentMethodRawList: React.FunctionComponent = props => (
-
- {props.paymentList.map(pm => bpdToggleFactory(pm))}
-
-);
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/LastPositionItem.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/LastPositionItem.tsx
deleted file mode 100644
index dea180116a5..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/LastPositionItem.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import * as React from "react";
-import { formatNumberWithNoDigits } from "../../../../../utils/stringBuilder";
-import I18n from "../../../../../i18n";
-import RankPositionItem from "./RankPositionItem";
-
-type Props = {
- transactionsNumber: number;
- superCashbackAmount: number;
- lastAvailablePosition: number;
-};
-
-const THOUSAND_UNIT = 1000;
-
-const retrieveBoxedLabel = (lastAvailablePosition: number) =>
- lastAvailablePosition >= THOUSAND_UNIT
- ? `${Math.floor(lastAvailablePosition / THOUSAND_UNIT)}K`
- : `${lastAvailablePosition}`;
-
-export const LastPositionItem: React.FunctionComponent = (
- props: Props
-) => (
-
-);
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/RankPositionItem.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/RankPositionItem.tsx
deleted file mode 100644
index 7bc8bf1fb63..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/RankPositionItem.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { IOColors, HSpacer, VSpacer } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import { H5 } from "../../../../../components/core/typography/H5";
-import { H4 } from "../../../../../components/core/typography/H4";
-import {
- formatIntegerNumber,
- formatNumberWithNoDigits
-} from "../../../../../utils/stringBuilder";
-import I18n from "../../../../../i18n";
-import { IOBadge } from "../../../../../components/core/IOBadge";
-
-type Props = {
- transactionsNumber: number;
- superCashbackAmount: number;
- boxedLabel: string;
- rankingLabel: string;
- currentUserPosition?: boolean;
- hideBadge?: boolean;
-};
-
-const style = StyleSheet.create({
- positionBox: {
- paddingVertical: 8,
- width: 48,
- textAlign: "center"
- }
-});
-
-const RankPositionItem = (props: Props): React.ReactElement => (
- <>
-
-
-
- {props.boxedLabel}
-
-
-
-
-
- {props.rankingLabel}
- {!props.hideBadge && (
-
-
-
- )}
-
-
- {I18n.t("bonus.bpd.details.transaction.label", {
- defaultValue: I18n.t("bonus.bpd.details.transaction.label.other", {
- transactions: formatIntegerNumber(props.transactionsNumber)
- }),
- count: props.transactionsNumber,
- transactions: formatIntegerNumber(props.transactionsNumber)
- })}
-
-
-
-
- >
-);
-
-export default RankPositionItem;
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackHeader.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackHeader.tsx
deleted file mode 100644
index 3bee88f4be4..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackHeader.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { View } from "react-native";
-import { connect } from "react-redux";
-import { HSpacer, VSpacer } from "@pagopa/io-app-design-system";
-import { IOBadge } from "../../../../../components/core/IOBadge";
-import { H3 } from "../../../../../components/core/typography/H3";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../i18n";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { BpdPeriodWithInfo } from "../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../store/reducers/details/selectedPeriod";
-
-type Props = ReturnType;
-
-const isPeriodOnGoing = (period: BpdPeriodWithInfo | undefined) =>
- pipe(
- period,
- O.fromNullable,
- O.fold(
- () => false,
- p => {
- if (p.status !== "Closed") {
- return true;
- }
-
- const actualDate = new Date();
- const endDate = new Date(p.endDate.getTime());
- endDate.setDate(endDate.getDate() + p.gracePeriod);
-
- return (
- actualDate.getTime() >= p.endDate.getTime() &&
- actualDate.getTime() <= endDate.getTime()
- );
- }
- )
- );
-
-const SuperCashbackHeader: React.FunctionComponent = (props: Props) => (
-
- {isPeriodOnGoing(props.selectedPeriod) && (
- <>
-
-
- >
- )}
-
- {I18n.t("bonus.bpd.details.superCashback.rankTitle")}
-
-);
-
-const mapStateToProps = (state: GlobalState) => ({
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(mapStateToProps)(SuperCashbackHeader);
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackRanking.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackRanking.tsx
deleted file mode 100644
index 110da22ce20..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/SuperCashbackRanking.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import * as React from "react";
-import { connect } from "react-redux";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import { H3 } from "../../../../../components/core/typography/H3";
-import { H4 } from "../../../../../components/core/typography/H4";
-import ItemSeparatorComponent from "../../../../../components/ItemSeparatorComponent";
-import Markdown from "../../../../../components/ui/Markdown";
-import I18n from "../../../../../i18n";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { useLegacyIOBottomSheetModal } from "../../../../../utils/hooks/bottomSheet";
-import {
- formatIntegerNumber,
- formatNumberWithNoDigits
-} from "../../../../../utils/stringBuilder";
-import { isBpdRankingReady } from "../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../store/reducers/details/selectedPeriod";
-import { isInGracePeriod } from "../../utils/dates";
-import { LastPositionItem } from "./LastPositionItem";
-import SuperCashbackHeader from "./SuperCashbackHeader";
-import UserPositionItem from "./UserPositionItem";
-
-type Props = ReturnType;
-
-const RankingItems: React.FunctionComponent = (props: Props) => {
- if (props.selectedPeriod && isBpdRankingReady(props.selectedPeriod.ranking)) {
- const mapRankingItems: Map = new Map<
- number,
- React.ReactNode
- >([
- [
- props.selectedPeriod.minPosition,
-
- ],
- [
- props.selectedPeriod.ranking.ranking,
-
- props.selectedPeriod.minPosition
- }
- userPosition={props.selectedPeriod.ranking.ranking}
- />
- ]
- ]);
-
- const key = [...mapRankingItems.keys()].sort((a, b) => a - b);
-
- return <>{key.map(k => mapRankingItems.get(k))}>;
- }
-
- return null;
-};
-
-const CSS_STYLE = `
-body {
- color: ${IOColors.bluegreyDark}
-}
-`;
-
-const SuperCashbackBottomSheet: React.FunctionComponent = (
- props: Props
-) => (
- <>
-
-
-
-
-
- {I18n.t("bonus.bpd.details.superCashback.howItWorks.title")}
-
- {props.selectedPeriod && (
- <>
-
- {I18n.t("bonus.bpd.details.superCashback.howItWorks.body", {
- citizens: formatIntegerNumber(props.selectedPeriod.minPosition),
- amount: formatNumberWithNoDigits(
- props.selectedPeriod.superCashbackAmount
- )
- })}
-
-
- {props.selectedPeriod.status === "Active" ||
- isInGracePeriod(
- props.selectedPeriod.endDate,
- props.selectedPeriod.gracePeriod
- ) ? (
-
- {I18n.t("bonus.bpd.details.superCashback.howItWorks.status.active")}
-
- ) : (
-
- {I18n.t("bonus.bpd.details.superCashback.howItWorks.status.closed")}
-
- )}
- >
- )}
- >
-);
-
-const mapStateToProps = (state: GlobalState) => ({
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-const SuperCashbackRanking = connect(mapStateToProps)(SuperCashbackBottomSheet);
-
-export default SuperCashbackRanking;
-
-export const useSuperCashbackRankingBottomSheet = () =>
- useLegacyIOBottomSheetModal(
- ,
- ,
- 470
- );
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/UserPositionItem.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/UserPositionItem.tsx
deleted file mode 100644
index 2dd1e69ecf5..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/UserPositionItem.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import * as React from "react";
-import { connect } from "react-redux";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { profileNameSelector } from "../../../../../store/reducers/profile";
-import { formatNumberWithNoDigits } from "../../../../../utils/stringBuilder";
-import I18n from "../../../../../i18n";
-import RankPositionItem from "./RankPositionItem";
-
-type Props = {
- transactionsNumber: number;
- superCashbackAmount: number;
- userPosition: number;
- hideBadge?: boolean;
-} & ReturnType;
-
-const UserPositionItem: React.FunctionComponent = (props: Props) => (
-
-);
-
-const mapStateToProps = (state: GlobalState) => ({
- currentUser: profileNameSelector(state)
-});
-
-export default connect(mapStateToProps)(UserPositionItem);
diff --git a/ts/features/bonus/bpd/components/superCashbackRanking/__test__/RankPositionItem.test.tsx b/ts/features/bonus/bpd/components/superCashbackRanking/__test__/RankPositionItem.test.tsx
deleted file mode 100644
index 3a4b89ac6ac..00000000000
--- a/ts/features/bonus/bpd/components/superCashbackRanking/__test__/RankPositionItem.test.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-import { render } from "@testing-library/react-native";
-import * as React from "react";
-import { IOColors } from "@pagopa/io-app-design-system";
-import RankPositionItem from "../RankPositionItem";
-import I18n from "../../../../../../i18n";
-import { formatNumberWithNoDigits } from "../../../../../../utils/stringBuilder";
-
-describe("RankingPositionItem", () => {
- it("Expect an item representing user position with Super Cashback amount badge", () => {
- const userLabel = I18n.t("global.you");
- const rankingLabel = `${formatNumberWithNoDigits(5000)}º: Maria`;
-
- const component = render(
-
- );
-
- expect(component).not.toBeNull();
- expect(component.queryByTestId("PositionBoxContainer")).toHaveStyle({
- backgroundColor: IOColors.blue
- });
- expect(component.queryByTestId("PositionBoxedLabel")).toHaveTextContent(
- userLabel
- );
- expect(component.queryByTestId("RankingLabel")).toHaveTextContent(
- rankingLabel
- );
- expect(component.queryByTestId("SuperCashbackAmountBadge")).toBeDefined();
- });
-
- it("Expect an item representing user position without Super Cashback amount badge", () => {
- const userLabel = I18n.t("global.you");
- const rankingLabel = `${formatNumberWithNoDigits(5000)}º: Maria`;
-
- const component = render(
-
- );
-
- expect(component).not.toBeNull();
- expect(component.queryByTestId("PositionBoxContainer")).toHaveStyle({
- backgroundColor: IOColors.blue
- });
- expect(component.queryByTestId("PositionBoxedLabel")).toHaveTextContent(
- userLabel
- );
- expect(component.queryByTestId("RankingLabel")).toHaveTextContent(
- rankingLabel
- );
- expect(component.queryByTestId("SuperCashbackAmountBadge")).toBeNull();
- });
-
- it("Expect an item representing generic position", () => {
- const boxedLabel = "100K";
-
- const rankingLabel = I18n.t("bonus.bpd.details.superCashback.rankLabel", {
- position: formatNumberWithNoDigits(1000)
- });
-
- const component = render(
-
- );
-
- expect(component.queryByTestId("PositionBoxedLabel")).toHaveTextContent(
- boxedLabel
- );
- expect(component.queryByTestId("RankingLabel")).toHaveTextContent(
- rankingLabel
- );
- expect(component.queryByTestId("SuperCashbackAmountBadge")).toBeNull();
- });
-});
diff --git a/ts/features/bonus/bpd/components/transactionItem/BaseBpdTransactionItem.tsx b/ts/features/bonus/bpd/components/transactionItem/BaseBpdTransactionItem.tsx
deleted file mode 100644
index 3e8467db04b..00000000000
--- a/ts/features/bonus/bpd/components/transactionItem/BaseBpdTransactionItem.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import * as React from "react";
-import {
- View,
- Image,
- ImageSourcePropType,
- StyleSheet,
- TouchableOpacity,
- TouchableWithoutFeedbackProps
-} from "react-native";
-import { IOColors, HSpacer } from "@pagopa/io-app-design-system";
-import { H4 } from "../../../../../components/core/typography/H4";
-import { H5 } from "../../../../../components/core/typography/H5";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import { ShadowBox } from "../../screens/details/components/summary/base/ShadowBox";
-
-type Props = {
- image: ImageSourcePropType;
- title: string;
- subtitle: string;
- rightText: string;
-} & Pick;
-
-const styles = StyleSheet.create({
- baseRow: {
- flex: 1,
- flexDirection: "row",
- justifyContent: "space-between",
- backgroundColor: IOColors.white
- },
- leftRow: {
- flex: 1,
- flexDirection: "row",
- paddingRight: 16
- },
- cardIcon: {
- width: 40,
- height: 25,
- overflow: "hidden",
- resizeMode: "contain",
- alignSelf: "center"
- },
- rightText: { alignSelf: "center" }
-});
-
-/**
- * Graphical settings and layout for the BpdTransactionItem
- * @param props
- * @constructor
- */
-export const BaseBpdTransactionItem: React.FunctionComponent = props => (
-
-
- {/* The base row */}
-
- {/* The left side of the row (icon, space, top text, bottom text */}
-
-
-
-
-
- {props.title}
-
- {props.subtitle}
-
-
- {/* The right side of the row */}
-
- {props.rightText}
-
-
-
-
-);
diff --git a/ts/features/bonus/bpd/components/transactionItem/BpdTransactionItem.tsx b/ts/features/bonus/bpd/components/transactionItem/BpdTransactionItem.tsx
deleted file mode 100644
index d0cd2f803d4..00000000000
--- a/ts/features/bonus/bpd/components/transactionItem/BpdTransactionItem.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import * as React from "react";
-import { ImageSourcePropType } from "react-native";
-import I18n from "../../../../../i18n";
-import { useLegacyIOBottomSheetModal } from "../../../../../utils/hooks/bottomSheet";
-import { localeDateFormat } from "../../../../../utils/locale";
-import { formatNumberAmount } from "../../../../../utils/stringBuilder";
-import {
- BpdTransactionDetailComponent,
- BpdTransactionDetailRepresentation
-} from "../../screens/details/transaction/detail/BpdTransactionDetailComponent";
-import { BpdTransaction } from "../../store/actions/transactions";
-import { BaseBpdTransactionItem } from "./BaseBpdTransactionItem";
-
-export type EnhancedBpdTransaction = {
- image: ImageSourcePropType;
- title: string;
- keyId: string;
- maxCashbackForTransactionAmount: number | undefined;
-} & BpdTransaction;
-
-type Props = {
- transaction: BpdTransactionDetailRepresentation;
-};
-
-/**
- * Create the subtitle for the transaction item, based on the trx date and trx amount
- * TODO: move the get subtitle in the combiner and remove this component?
- * @param transaction
- */
-export const getSubtitle = (transaction: BpdTransaction) => {
- const isMidNight =
- transaction.trxDate.getHours() +
- transaction.trxDate.getMinutes() +
- transaction.trxDate.getSeconds() ===
- 0;
- return isMidNight
- ? `€ ${formatNumberAmount(transaction.amount)} · ${localeDateFormat(
- transaction.trxDate,
- I18n.t("global.dateFormats.dayMonthWithoutTime")
- )} `
- : `€ ${formatNumberAmount(transaction.amount)} · ${localeDateFormat(
- transaction.trxDate,
- I18n.t("global.dateFormats.dayMonthWithTime")
- )} `;
-};
-
-export const BpdTransactionItem: React.FunctionComponent = props => {
- const { present: openBottomSheet, bottomSheet } = useLegacyIOBottomSheetModal(
- ,
- I18n.t("bonus.bpd.details.transaction.detail.title"),
- 522
- );
-
- return (
- <>
-
- {bottomSheet}
- >
- );
-};
diff --git a/ts/features/bonus/bpd/components/transactionItem/__test__/BdpTransactionItem.test.tsx b/ts/features/bonus/bpd/components/transactionItem/__test__/BdpTransactionItem.test.tsx
deleted file mode 100644
index 18d354b89c8..00000000000
--- a/ts/features/bonus/bpd/components/transactionItem/__test__/BdpTransactionItem.test.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { getSubtitle } from "../BpdTransactionItem";
-import { EnhancedBpdTransaction } from "../../../components/transactionItem/BpdTransactionItem";
-import { HPan } from "../../../store/actions/paymentMethods";
-import { AwardPeriodId } from "../../../store/actions/periods";
-
-describe("Test how the transaction subtitle changes with different timestamps", () => {
- it("Subtitle shouldn't contain hours and minutes, when the transaction has a timestamp 00:00", () => {
- const myTransaction: EnhancedBpdTransaction = {
- hashPan:
- "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan,
- idTrxAcquirer: "10126487773E",
- idTrxIssuer: "R64692",
- amount: 87.79,
- awardPeriodId: 2 as AwardPeriodId,
- image: 29,
- maxCashbackForTransactionAmount: 15,
- title: "xxxxxxx",
- trxDate: new Date("2100-12-17T00:00"),
- keyId: "xxxxxxxxx",
- cashback: 8.779,
- circuitType: "Mastercard / Maestro"
- };
-
- expect(getSubtitle(myTransaction)).toMatch("€ 87.79 · 17 Dec ");
- });
-
- it("Subtitle should contain hours and minutes when the transaction has a timestamp 00:00", () => {
- const myTransaction: EnhancedBpdTransaction = {
- hashPan:
- "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan,
- idTrxAcquirer: "10126487773E",
- idTrxIssuer: "R64692",
- amount: 100000.79,
- awardPeriodId: 2 as AwardPeriodId,
- image: 29,
- maxCashbackForTransactionAmount: 15,
- title: "xxxxxxx",
- trxDate: new Date("2100-12-19T12:39"),
- keyId: "xxxxxxxxx",
- cashback: 8.779,
- circuitType: "Mastercard / Maestro"
- };
-
- expect(getSubtitle(myTransaction)).toMatch("€ 100,000.79 · 19 Dec, 12:39 ");
- });
-});
diff --git a/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx b/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx
deleted file mode 100644
index 5bf2e4268ae..00000000000
--- a/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import _ from "lodash";
-import { View } from "react-native";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { bpdSelectPeriod } from "../../store/actions/selectedPeriod";
-import { bpdPeriodsAmountWalletVisibleSelector } from "../../store/reducers/details/combiner";
-import { BpdPeriodWithInfo } from "../../store/reducers/details/periods";
-import { BpdCardComponent } from "../bpdCardComponent/BpdCardComponent";
-
-type Props = ReturnType &
- ReturnType;
-
-const BpdCardList = (props: Props) => (
-
- {pot.isSome(props.periodsWithAmount) &&
- props.periodsWithAmount.value.map(pa => (
- {
- props.navigateToCashbackDetails(pa);
- }}
- />
- ))}
-
-);
-
-const BpdCardListMemo = React.memo(
- BpdCardList,
- (prev: Props, curr: Props) =>
- pot.isSome(prev.periodsWithAmount) &&
- pot.isSome(curr.periodsWithAmount) &&
- _.isEqual(curr.periodsWithAmount.value, prev.periodsWithAmount.value)
-);
-
-/**
- * Render the bpd card in the wallet
- * //TODO: handle error, render only if some
- * @constructor
- */
-const BpdCardsInWalletContainer = (props: Props) => (
-
-);
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- navigateToCashbackDetails: (period: BpdPeriodWithInfo) => {
- dispatch(bpdSelectPeriod(period));
- }
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- periodsWithAmount: bpdPeriodsAmountWalletVisibleSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdCardsInWalletContainer);
diff --git a/ts/features/bonus/bpd/saga/index.ts b/ts/features/bonus/bpd/saga/index.ts
deleted file mode 100644
index f2ce5a2cdca..00000000000
--- a/ts/features/bonus/bpd/saga/index.ts
+++ /dev/null
@@ -1,132 +0,0 @@
-import { SagaIterator } from "redux-saga";
-import { takeEvery, takeLatest } from "typed-redux-saga/macro";
-import { getType } from "typesafe-actions";
-import { bpdApiUrlPrefix } from "../../../../config";
-import { BackendBpdClient } from "../api/backendBpdClient";
-import { bpdAllData, bpdLoadActivationStatus } from "../store/actions/details";
-import { bpdIbanInsertionStart, bpdUpsertIban } from "../store/actions/iban";
-import {
- bpdDeleteUserFromProgram,
- bpdEnrollUserToProgram,
- bpdOnboardingAcceptDeclaration,
- bpdOnboardingStart
-} from "../store/actions/onboarding";
-import {
- bpdPaymentMethodActivation,
- bpdUpdatePaymentMethodActivation
-} from "../store/actions/paymentMethods";
-import { bpdPeriodsAmountLoad } from "../store/actions/periods";
-import {
- bpdTransactionsLoadCountByDay,
- bpdTransactionsLoadMilestone,
- bpdTransactionsLoadPage,
- bpdTransactionsLoadRequiredData
-} from "../store/actions/transactions";
-import { deleteCitizen, getCitizenV2, putEnrollCitizenV2 } from "./networking";
-import { loadBpdData } from "./networking/loadBpdData";
-import { loadPeriodsWithInfo } from "./networking/loadPeriodsWithInfo";
-import { patchCitizenIban } from "./networking/patchCitizenIban";
-import {
- bpdLoadPaymentMethodActivationSaga,
- bpdUpdatePaymentMethodActivationSaga
-} from "./networking/paymentMethod";
-import { handleLoadMilestone } from "./networking/ranking";
-import { handleCountByDay } from "./networking/winning-transactions/countByDay";
-import { handleTransactionsLoadRequiredData } from "./networking/winning-transactions/loadTransactionsRequiredData";
-import { handleTransactionsPage } from "./networking/winning-transactions/transactionsPage";
-import { handleBpdIbanInsertion } from "./orchestration/insertIban";
-import { handleBpdEnroll } from "./orchestration/onboarding/enrollToBpd";
-import { handleBpdStartOnboardingSaga } from "./orchestration/onboarding/startOnboarding";
-
-// watch all events about bpd
-export function* watchBonusBpdSaga(bpdBearerToken: string): SagaIterator {
- const bpdBackendClient = BackendBpdClient(bpdApiUrlPrefix, bpdBearerToken);
-
- // load citizen details
- yield* takeLatest(
- bpdLoadActivationStatus.request,
- getCitizenV2,
- bpdBackendClient.findV2
- );
- // enroll citizen to the bpd
- yield* takeLatest(
- bpdEnrollUserToProgram.request,
- putEnrollCitizenV2,
- bpdBackendClient.enrollCitizenV2IO
- );
-
- // delete citizen from the bpd
- yield* takeLatest(
- bpdDeleteUserFromProgram.request,
- deleteCitizen,
- bpdBackendClient.deleteCitizenIO
- );
-
- // upsert citizen iban
- yield* takeLatest(
- bpdUpsertIban.request,
- patchCitizenIban,
- bpdBackendClient.updatePaymentMethod
- );
-
- // load bpd activation status for a specific payment method
- yield* takeEvery(
- bpdPaymentMethodActivation.request,
- bpdLoadPaymentMethodActivationSaga,
- bpdBackendClient.findPayment
- );
-
- // update bpd activation status for a specific payment method
- yield* takeEvery(
- bpdUpdatePaymentMethodActivation.request,
- bpdUpdatePaymentMethodActivationSaga,
- bpdBackendClient.enrollPayment,
- bpdBackendClient.deletePayment
- );
-
- // prefetch all the bpd data
- yield* takeEvery(bpdAllData.request, loadBpdData);
-
- // Load bpd periods with amount
- yield* takeEvery(
- bpdPeriodsAmountLoad.request,
- loadPeriodsWithInfo,
- bpdBackendClient
- );
-
- // Load count by day info for a period
- yield* takeEvery(
- bpdTransactionsLoadCountByDay.request,
- handleCountByDay,
- bpdBackendClient.winningTransactionsV2CountByDay
- );
-
- // Load the milestone (pivot) information for a period
- yield* takeEvery(
- bpdTransactionsLoadMilestone.request,
- handleLoadMilestone,
- bpdBackendClient.getRankingV2
- );
-
- // Load a transactions page for a period
- yield* takeEvery(
- bpdTransactionsLoadPage.request,
- handleTransactionsPage,
- bpdBackendClient.winningTransactionsV2
- );
-
- // Load all the required transactions data, for a period
- yield* takeEvery(
- bpdTransactionsLoadRequiredData.request,
- handleTransactionsLoadRequiredData
- );
-
- // First step of the onboarding workflow; check if the user is enrolled to the bpd program
- yield* takeLatest(getType(bpdOnboardingStart), handleBpdStartOnboardingSaga);
-
- // The user accepts the declaration, enroll the user to the bpd program
- yield* takeLatest(getType(bpdOnboardingAcceptDeclaration), handleBpdEnroll);
-
- // The user start the insertion / modification of the IBAN associated with bpd program
- yield* takeLatest(getType(bpdIbanInsertionStart), handleBpdIbanInsertion);
-}
diff --git a/ts/features/bonus/bpd/saga/networking/__test__/loadBpdData.test.ts b/ts/features/bonus/bpd/saga/networking/__test__/loadBpdData.test.ts
deleted file mode 100644
index 428152d161d..00000000000
--- a/ts/features/bonus/bpd/saga/networking/__test__/loadBpdData.test.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { testSaga } from "redux-saga-test-plan";
-import { abiSelector } from "../../../../../wallet/onboarding/store/abi";
-import { remoteReady } from "../../../../../../common/model/RemoteValue";
-import {
- bpdAllData,
- bpdLoadActivationStatus
-} from "../../../store/actions/details";
-import { bpdPeriodsAmountLoad } from "../../../store/actions/periods";
-import { loadBpdData, testableFunctions } from "../loadBpdData";
-
-// TODO: tested only two base case, add more if needed
-describe("loadBpdData", () => {
- it("Dispatch bpdAllData.success if the user is not enrolled", () => {
- testSaga(loadBpdData)
- .next()
- .select(abiSelector)
- .next(remoteReady({}))
- .call(testableFunctions.checkPreviousFailures!)
- .next()
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([bpdLoadActivationStatus.success, bpdLoadActivationStatus.failure])
- .next(
- bpdLoadActivationStatus.success({
- enabled: false,
- activationStatus: "never",
- payoffInstr: undefined
- })
- )
- .put(bpdAllData.success())
- .next()
- .isDone();
- });
- it("Dispatch bpdAllData.success if the user is enrolled and all subsequent requests are successful", () => {
- testSaga(loadBpdData)
- .next()
- .select(abiSelector)
- .next(remoteReady({}))
- .call(testableFunctions.checkPreviousFailures!)
- .next()
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([bpdLoadActivationStatus.success, bpdLoadActivationStatus.failure])
- .next(
- bpdLoadActivationStatus.success({
- enabled: true,
- activationStatus: "subscribed",
- payoffInstr: undefined
- })
- )
- .put(bpdPeriodsAmountLoad.request())
- .next()
- .take([bpdPeriodsAmountLoad.success, bpdPeriodsAmountLoad.failure])
- .next(bpdPeriodsAmountLoad.success([]))
- .put(bpdAllData.success())
- .next()
- .isDone();
- });
-});
diff --git a/ts/features/bonus/bpd/saga/networking/__test__/loadPeriodsAmount.test.ts b/ts/features/bonus/bpd/saga/networking/__test__/loadPeriodsAmount.test.ts
deleted file mode 100644
index 940eed1c7a5..00000000000
--- a/ts/features/bonus/bpd/saga/networking/__test__/loadPeriodsAmount.test.ts
+++ /dev/null
@@ -1,249 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { expectSaga } from "redux-saga-test-plan";
-import { call } from "redux-saga-test-plan/matchers";
-import {
- AwardPeriodId,
- BpdPeriod,
- bpdPeriodsAmountLoad
-} from "../../../store/actions/periods";
-import {
- notEligibleAmount,
- zeroAmount
-} from "../../../store/reducers/__mock__/amount";
-import {
- activePeriod,
- closedPeriod,
- inactivePeriod,
- withAwardPeriodId
-} from "../../../store/reducers/__mock__/periods";
-import {
- notReadyRanking,
- readyRanking
-} from "../../../store/reducers/__mock__/ranking";
-import { BpdAmount, bpdLoadAmountSaga } from "../amount";
-import { loadPeriodsWithInfo } from "../loadPeriodsWithInfo";
-import { bpdLoadPeriodsSaga } from "../periods";
-import { bpdLoadRakingV2 } from "../ranking";
-
-describe("loadPeriodsAmount, mock networking saga", () => {
- it("Dispatch failure if awardsPeriods fails", async () => {
- const awardPeriodFailure = new Error("Error while loading periods");
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.left(awardPeriodFailure)
- ]
- ])
- .put(bpdPeriodsAmountLoad.failure(awardPeriodFailure))
- .run();
- });
-
- it("Dispatch failure if a single totalCashback is left", async () => {
- const totalCashbackFailure = new Error("Error for a single amount");
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.right>([activePeriod, closedPeriod])
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 0),
- E.right(zeroAmount)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 1),
- E.left(totalCashbackFailure)
- ],
- [
- call(bpdLoadRakingV2, backendClient.getRankingV2),
- E.right([readyRanking])
- ]
- ])
- .put(
- bpdPeriodsAmountLoad.failure(new Error("Error while loading amounts"))
- )
- .run();
- });
- it("Dispatch failure if all the totalCashback are E.left", async () => {
- const totalCashbackFailure = new Error("Error for a single amount");
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.right>([activePeriod, closedPeriod])
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 0),
- E.left(totalCashbackFailure)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 1),
- E.left(totalCashbackFailure)
- ],
- [
- call(bpdLoadRakingV2, backendClient.getRankingV2),
- E.right([readyRanking])
- ]
- ])
- .put(
- bpdPeriodsAmountLoad.failure(new Error("Error while loading amounts"))
- )
- .run();
- });
-
- it("Dispatch failure if load ranking is E.left", async () => {
- const totalCashbackFailure = new Error("Error for a single amount");
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.right>([activePeriod, closedPeriod])
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 0),
- E.left(totalCashbackFailure)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 1),
- E.left(totalCashbackFailure)
- ],
- [
- call(bpdLoadRakingV2, backendClient.getRankingV2),
- E.left(new Error("error"))
- ]
- ])
- .put(
- bpdPeriodsAmountLoad.failure(new Error("Error while loading rankings"))
- )
- .run();
- });
-
- it("Dispatch success if all the totalCashback are E.right", async () => {
- const amountForPeriod0: BpdAmount = {
- ...zeroAmount,
- awardPeriodId: 0 as AwardPeriodId
- };
- const amountForPeriod1: BpdAmount = {
- ...notEligibleAmount,
- awardPeriodId: 1 as AwardPeriodId
- };
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.right>([activePeriod, closedPeriod])
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 0),
- E.right(amountForPeriod0)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 1),
- E.right(amountForPeriod1)
- ],
- [
- call(bpdLoadRakingV2, backendClient.getRankingV2),
- E.right([readyRanking])
- ]
- ])
- .put(
- bpdPeriodsAmountLoad.success([
- { ...activePeriod, amount: amountForPeriod1, ranking: readyRanking },
- {
- ...closedPeriod,
- amount: amountForPeriod0,
- ranking: notReadyRanking
- }
- ])
- )
- .run();
- });
- it("Dispatch success if all the totalCashback are E.right, do not request inactive periods", async () => {
- const amountForPeriod0: BpdAmount = {
- ...zeroAmount,
- awardPeriodId: 0 as AwardPeriodId
- };
- const amountForPeriod1: BpdAmount = {
- ...notEligibleAmount,
- awardPeriodId: 1 as AwardPeriodId
- };
- const amountForPeriod2: BpdAmount = {
- ...notEligibleAmount,
- awardPeriodId: 2 as AwardPeriodId
- };
- const backendClient = {
- totalCashback: jest.fn(),
- awardPeriods: jest.fn(),
- getRankingV2: jest.fn()
- };
- await expectSaga(loadPeriodsWithInfo, backendClient)
- .provide([
- [
- call(bpdLoadPeriodsSaga, backendClient.awardPeriods),
- E.right>([
- activePeriod,
- closedPeriod,
- inactivePeriod
- ])
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 0),
- E.right(amountForPeriod0)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 1),
- E.right(amountForPeriod1)
- ],
- [
- call(bpdLoadAmountSaga, backendClient.totalCashback, 2),
- E.right(amountForPeriod2)
- ],
- [
- call(bpdLoadRakingV2, backendClient.getRankingV2),
- E.right([readyRanking])
- ]
- ])
- .put(
- bpdPeriodsAmountLoad.success([
- {
- ...inactivePeriod,
- amount: { ...zeroAmount, awardPeriodId: 2 as AwardPeriodId },
- ranking: withAwardPeriodId(notReadyRanking, 2 as AwardPeriodId)
- },
- { ...activePeriod, amount: amountForPeriod1, ranking: readyRanking },
- {
- ...closedPeriod,
- amount: amountForPeriod0,
- ranking: notReadyRanking
- }
- ])
- )
- .run();
- });
-});
diff --git a/ts/features/bonus/bpd/saga/networking/amount.ts b/ts/features/bonus/bpd/saga/networking/amount.ts
deleted file mode 100644
index 3df0552cfc5..00000000000
--- a/ts/features/bonus/bpd/saga/networking/amount.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import { call } from "typed-redux-saga/macro";
-import { TotalCashbackResource } from "../../../../../../definitions/bpd/winning_transactions/TotalCashbackResource";
-import { mixpanelTrack } from "../../../../../mixpanel";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../types/utils";
-import { convertUnknownToError, getError } from "../../../../../utils/errors";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { AwardPeriodId, WithAwardPeriodId } from "../../store/actions/periods";
-
-export type BpdAmount = WithAwardPeriodId & {
- // The total cashback amount gained by the user in the period (without super cashback)
- totalCashback: number;
- // The total transaction number in the period for the user
- transactionNumber: number;
-};
-
-export type BpdAmountError = WithAwardPeriodId & {
- error: Error;
-};
-
-// convert a network payload amount into the relative app domain model
-const convertAmount = (
- networkAmount: TotalCashbackResource,
- awardPeriodId: AwardPeriodId
-): BpdAmount => ({
- totalCashback: networkAmount.totalCashback,
- transactionNumber: networkAmount.transactionNumber,
- awardPeriodId
-});
-
-const mixpanelActionRequest = "BPD_AMOUNT_REQUEST";
-const mixpanelActionSuccess = "BPD_AMOUNT_SUCCESS";
-const mixpanelActionFailure = "BPD_AMOUNT_FAILURE";
-
-/**
- * Networking code to request the amount for a specified period.
- * @param totalCashback
- * @param awardPeriodId
- */
-export function* bpdLoadAmountSaga(
- totalCashback: ReturnType["totalCashback"],
- awardPeriodId: AwardPeriodId
-): Generator<
- ReduxSagaEffect,
- E.Either,
- SagaCallReturnType
-> {
- void mixpanelTrack(mixpanelActionRequest, { awardPeriodId });
- try {
- const totalCashbackResult: SagaCallReturnType =
- yield* call(totalCashback, { awardPeriodId } as any);
- if (E.isRight(totalCashbackResult)) {
- if (totalCashbackResult.right.status === 200) {
- void mixpanelTrack(mixpanelActionSuccess, { awardPeriodId });
- return E.right(
- convertAmount(totalCashbackResult.right.value, awardPeriodId)
- );
- } else {
- throw new Error(`response status ${totalCashbackResult.right.status}`);
- }
- } else {
- throw new Error(readableReport(totalCashbackResult.left));
- }
- } catch (e) {
- void mixpanelTrack(mixpanelActionFailure, {
- awardPeriodId,
- reason: convertUnknownToError(e).message
- });
- return E.left({
- error: getError(e),
- awardPeriodId
- });
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/index.ts b/ts/features/bonus/bpd/saga/networking/index.ts
deleted file mode 100644
index af53a972b07..00000000000
--- a/ts/features/bonus/bpd/saga/networking/index.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import { SagaIterator } from "@redux-saga/core";
-import * as E from "fp-ts/lib/Either";
-import { call, put } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { convertUnknownToError, getError } from "../../../../../utils/errors";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { bpdLoadActivationStatus } from "../../store/actions/details";
-import {
- bpdDeleteUserFromProgram,
- bpdEnrollUserToProgram,
- bpdUpdateOptInStatusMethod
-} from "../../store/actions/onboarding";
-
-export function* executeAndDispatchV2(
- remoteCall:
- | ReturnType["enrollCitizenV2IO"]
- | ReturnType["findV2"],
- action: typeof bpdEnrollUserToProgram | typeof bpdLoadActivationStatus
-) {
- try {
- const enrollCitizenIOResult: SagaCallReturnType =
- yield* call(
- remoteCall,
- // due to avoid required headers coming from code autogenerate
- // (note the required header will be injected automatically)
- {} as any
- );
- if (E.isRight(enrollCitizenIOResult)) {
- if (enrollCitizenIOResult.right.status === 200) {
- const { enabled, payoffInstr, technicalAccount, optInStatus } =
- enrollCitizenIOResult.right.value;
- yield* put(
- action.success({
- enabled,
- activationStatus: enabled ? "subscribed" : "unsubscribed",
- payoffInstr,
- technicalAccount,
- optInStatus
- })
- );
- return;
- } else if (enrollCitizenIOResult.right.status === 404) {
- yield* put(
- action.success({
- enabled: false,
- activationStatus: "never",
- payoffInstr: undefined,
- technicalAccount: undefined
- })
- );
- return;
- }
- throw new Error(`response status ${enrollCitizenIOResult.right.status}`);
- } else {
- throw new Error(readableReport(enrollCitizenIOResult.left));
- }
- } catch (e) {
- yield* put(action.failure(convertUnknownToError(e)));
- }
-}
-
-export function* getCitizenV2(
- findCitizen: ReturnType["findV2"]
-): SagaIterator {
- yield* call(executeAndDispatchV2, findCitizen, bpdLoadActivationStatus);
-}
-
-export function* putEnrollCitizenV2(
- enrollCitizenIO: ReturnType["enrollCitizenV2IO"]
-): SagaIterator {
- yield* call(executeAndDispatchV2, enrollCitizenIO, bpdEnrollUserToProgram);
-}
-
-/**
- * update the citizen OptInStatus
- * @param updateCitizenIO
- * @param action
- */
-export function* putOptInStatusCitizenV2(
- updateCitizenIO: ReturnType["enrollCitizenV2IO"],
- action: ActionType
-) {
- try {
- const updateCitizenIOResult: SagaCallReturnType =
- yield* call(
- updateCitizenIO,
- // due to avoid required headers coming from code autogenerate
- // (note the required header will be injected automatically)
- { optInStatus: action.payload } as any
- );
-
- if (E.isRight(updateCitizenIOResult)) {
- if (updateCitizenIOResult.right.status === 200) {
- if (updateCitizenIOResult.right.value.optInStatus) {
- const { optInStatus } = updateCitizenIOResult.right.value;
- yield* put(bpdUpdateOptInStatusMethod.success(optInStatus));
- return;
- } else {
- // it should never happen
- bpdUpdateOptInStatusMethod.failure(
- new Error(`optInStatus is undefined`)
- );
- }
- } else {
- yield* put(
- bpdUpdateOptInStatusMethod.failure(
- new Error(`response status ${updateCitizenIOResult.right.status}`)
- )
- );
- }
- } else {
- yield* put(
- bpdUpdateOptInStatusMethod.failure(
- new Error(readableReport(updateCitizenIOResult.left))
- )
- );
- }
- } catch (e) {
- yield* put(bpdUpdateOptInStatusMethod.failure(getError(e)));
- }
-}
-
-/**
- * make a request to delete citizen from bpd program
- */
-export function* deleteCitizen(
- deleteCitizenIO: ReturnType["deleteCitizenIO"]
-): SagaIterator {
- try {
- const deleteCitizenIOResult: SagaCallReturnType =
- yield* call(deleteCitizenIO, {} as any);
- if (E.isRight(deleteCitizenIOResult)) {
- if (deleteCitizenIOResult.right.status === 204) {
- yield* put(bpdDeleteUserFromProgram.success());
- return;
- }
- throw new Error(`response status ${deleteCitizenIOResult.right.status}`);
- } else {
- throw new Error(readableReport(deleteCitizenIOResult.left));
- }
- } catch (e) {
- yield* put(bpdDeleteUserFromProgram.failure(convertUnknownToError(e)));
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/loadBpdData.ts b/ts/features/bonus/bpd/saga/networking/loadBpdData.ts
deleted file mode 100644
index a0e9907905f..00000000000
--- a/ts/features/bonus/bpd/saga/networking/loadBpdData.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-import { call, delay, put, select, take } from "typed-redux-saga/macro";
-import { ActionType, getType } from "typesafe-actions";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { getBackoffTime } from "../../../../../utils/backoffError";
-import { isTestEnv } from "../../../../../utils/environment";
-import { loadAbi } from "../../../../wallet/onboarding/bancomat/store/actions";
-import { abiSelector } from "../../../../wallet/onboarding/store/abi";
-import { isReady } from "../../../../../common/model/RemoteValue";
-import {
- bpdAllData,
- bpdLoadActivationStatus
-} from "../../store/actions/details";
-import { bpdPeriodsAmountLoad } from "../../store/actions/periods";
-
-/**
- * retrieve possible backoff waiting time and if there is, wait that time
- */
-function* checkPreviousFailures() {
- // wait if some previous errors occurred
- const loadActivationBackOff: SagaCallReturnType =
- yield* call(getBackoffTime, bpdLoadActivationStatus.failure);
- const loadPeriodsBackOff: SagaCallReturnType =
- yield* call(getBackoffTime, bpdPeriodsAmountLoad.failure);
- const waitingTime = Math.max(loadActivationBackOff, loadPeriodsBackOff);
- if (waitingTime > 0) {
- yield* delay(waitingTime);
- }
-}
-
-/**
- * Load all the BPD details data:
- * - Activation Status
- * - Abi list
- * - Periods
- * - Amount foreach period !== "Inactive"
- * - Transactions foreach period !== "Inactive"
- */
-export function* loadBpdData() {
- // TODO: move from here
- const abiList: ReturnType = yield* select(abiSelector);
-
- // The volatility of the bank list is extremely low.
- // There is no need to refresh it every time.
- // A further refinement could be to insert an expiring cache
- if (!isReady(abiList)) {
- yield* put(loadAbi.request());
- }
- yield* call(checkPreviousFailures);
- // First request the bpd activation status
- yield* put(bpdLoadActivationStatus.request());
-
- const activationStatus = yield* take<
- ActionType<
- | typeof bpdLoadActivationStatus.success
- | typeof bpdLoadActivationStatus.failure
- >
- >([bpdLoadActivationStatus.success, bpdLoadActivationStatus.failure]);
-
- if (activationStatus.type === getType(bpdLoadActivationStatus.success)) {
- // if the user is not registered with bpd,
- // there is no need to request other data as it is never allowed to view closed periods
- if (!activationStatus.payload.enabled) {
- yield* put(bpdAllData.success());
- return;
- }
-
- // In case of success, request the periods, amounts and ranking foreach required period
- yield* put(bpdPeriodsAmountLoad.request());
-
- const periods = yield* take<
- ActionType<
- | typeof bpdPeriodsAmountLoad.success
- | typeof bpdPeriodsAmountLoad.failure
- >
- >([bpdPeriodsAmountLoad.success, bpdPeriodsAmountLoad.failure]);
-
- if (periods.type === getType(bpdPeriodsAmountLoad.success)) {
- // The load of all the required data for bpd is now completed with success
- yield* put(bpdAllData.success());
- } else {
- // The load of all the required bpd data is failed
- yield* put(bpdAllData.failure(periods.payload));
- }
- } else {
- // The load of all the required bpd data is failed
- yield* put(bpdAllData.failure(activationStatus.payload));
- }
-}
-
-// to keep solid code encapsulation
-export const testableFunctions = {
- checkPreviousFailures: isTestEnv ? checkPreviousFailures : undefined
-};
diff --git a/ts/features/bonus/bpd/saga/networking/loadPeriodsWithInfo.ts b/ts/features/bonus/bpd/saga/networking/loadPeriodsWithInfo.ts
deleted file mode 100644
index 62aa95d5945..00000000000
--- a/ts/features/bonus/bpd/saga/networking/loadPeriodsWithInfo.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-import * as AR from "fp-ts/lib/Array";
-import * as E from "fp-ts/lib/Either";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import { all, call, put } from "typed-redux-saga/macro";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { bpdPeriodsAmountLoad } from "../../store/actions/periods";
-import {
- BpdPeriodWithInfo,
- BpdRanking,
- bpdRankingNotReady,
- BpdRankingReady
-} from "../../store/reducers/details/periods";
-import { BpdAmount, BpdAmountError, bpdLoadAmountSaga } from "./amount";
-import { bpdLoadPeriodsSaga } from "./periods";
-import { bpdLoadRakingV2 } from "./ranking";
-
-/**
- * Load the periods information list and adds the amount and ranking information
- * foreach period (active or closed)
- * @param bpdClient
- */
-export function* loadPeriodsWithInfo(
- bpdClient: Pick<
- ReturnType,
- "awardPeriods" | "totalCashback" | "getRankingV2"
- >
-) {
- // Request the period list
- const maybePeriods: SagaCallReturnType =
- yield* call(bpdLoadPeriodsSaga, bpdClient.awardPeriods);
-
- if (E.isLeft(maybePeriods)) {
- // Error while receiving the period list
- yield* put(bpdPeriodsAmountLoad.failure(maybePeriods.left));
- } else {
- const periods = maybePeriods.right;
-
- const rankings: E.Either<
- Error,
- ReadonlyArray
- > = yield* call(bpdLoadRakingV2, bpdClient.getRankingV2);
-
- if (E.isLeft(rankings)) {
- yield* put(
- bpdPeriodsAmountLoad.failure(new Error("Error while loading rankings"))
- );
- return;
- }
-
- // request the amounts for all the required periods
- const amounts: ReadonlyArray> =
- yield* all(
- periods
- // no need to request the inactive period, the amount and transaction number is always 0
- .filter(p => p.status !== "Inactive")
- .map(period =>
- call(
- bpdLoadAmountSaga,
- bpdClient.totalCashback,
- period.awardPeriodId
- )
- )
- );
-
- // Check if the required period amount are without error
- // With a single error, we can't display the periods list
- if (amounts.some(E.isLeft)) {
- yield* put(
- bpdPeriodsAmountLoad.failure(new Error("Error while loading amounts"))
- );
- return;
- }
-
- // the transactionNumber and totalCashback for inactive (future) period is 0, no need to request
- // creating the static response
- const amountWithInactivePeriod = [
- ...periods
- .filter(p => p.status === "Inactive")
- .map>(p =>
- E.right({
- awardPeriodId: p.awardPeriodId,
- transactionNumber: 0,
- totalCashback: 0
- })
- ),
- ...amounts
- ];
-
- // compose the period with the amount information
- const periodsWithAmount = amountWithInactivePeriod
- .filter(E.isRight)
- .reduce>(
- (acc, curr) =>
- pipe(
- [...periods],
- AR.findFirst(p => p.awardPeriodId === curr.right.awardPeriodId),
- O.foldW(
- () => acc,
- period => [
- ...acc,
- {
- ...period,
- amount: curr.right,
- ranking: pipe(
- [...rankings.right],
- AR.findFirst(
- r => r.awardPeriodId === curr.right.awardPeriodId
- ),
- O.getOrElseW(() =>
- bpdRankingNotReady(curr.right.awardPeriodId)
- )
- )
- }
- ]
- )
- ),
- []
- );
- yield* put(bpdPeriodsAmountLoad.success(periodsWithAmount));
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/patchCitizenIban.ts b/ts/features/bonus/bpd/saga/networking/patchCitizenIban.ts
deleted file mode 100644
index cb6c6884d7f..00000000000
--- a/ts/features/bonus/bpd/saga/networking/patchCitizenIban.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-import * as O from "fp-ts/lib/Option";
-import * as E from "fp-ts/lib/Either";
-import { call, put, select } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { pipe } from "fp-ts/lib/function";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { Iban } from "../../../../../../definitions/backend/Iban";
-import { bpdUpsertIban, IbanUpsertResult } from "../../store/actions/iban";
-import { profileSelector } from "../../../../../store/reducers/profile";
-import { readablePrivacyReport } from "../../../../../utils/reporters";
-import { convertUnknownToError } from "../../../../../utils/errors";
-// representation of iban status
-export enum IbanStatus {
- "OK" = "OK",
- "NOT_OWNED" = "NOT_OWNED",
- "CANT_VERIFY" = "CANT_VERIFY",
- "NOT_VALID" = "NOT_VALID",
- "UNKNOWN" = "UNKNOWN"
-}
-
-const ibanStatusMapping: Map = new Map([
- ["OK", IbanStatus.OK],
- ["KO", IbanStatus.NOT_OWNED],
- ["UNKNOWN_PSP", IbanStatus.CANT_VERIFY]
-]);
-
-const successCases = new Set([
- IbanStatus.OK,
- IbanStatus.CANT_VERIFY,
- IbanStatus.NOT_OWNED
-]);
-
-// convert the validation code coming from response to an internal logic status
-const fromValidationToStatus = (ibanOutcome: string): IbanStatus =>
- pipe(
- ibanStatusMapping.get(ibanOutcome),
- O.fromNullable,
- O.getOrElseW(() => IbanStatus.UNKNOWN)
- );
-
-const transformIbanOutCome = (
- ibanStatus: IbanStatus,
- iban: Iban
-): IbanUpsertResult => ({
- // don't store iban if the outcome is a failure
- payoffInstr: successCases.has(ibanStatus) ? iban : undefined,
- status: ibanStatus
-});
-
-/**
- * upsert the citizen iban
- */
-export function* patchCitizenIban(
- updatePaymentMethod: ReturnType<
- typeof BackendBpdClient
- >["updatePaymentMethod"],
- action: ActionType
-) {
- try {
- const profileState: ReturnType = yield* select(
- profileSelector
- );
- if (pot.isNone(profileState)) {
- // it should never happen
- throw new Error(`profile is None`);
- }
- const iban: Iban = action.payload;
- const updatePaymentMethodResult: SagaCallReturnType<
- ReturnType
- > = yield* call(updatePaymentMethod(iban, profileState.value), {});
- if (E.isRight(updatePaymentMethodResult)) {
- const statusCode = updatePaymentMethodResult.right.status;
- if (statusCode === 200 && updatePaymentMethodResult.right.value) {
- const validationStatus =
- updatePaymentMethodResult.right.value.validationStatus;
- yield* put(
- bpdUpsertIban.success(
- transformIbanOutCome(fromValidationToStatus(validationStatus), iban)
- )
- );
- return;
- }
- // iban not valid
- else if (statusCode === 400) {
- yield* put(
- bpdUpsertIban.success(
- transformIbanOutCome(IbanStatus.NOT_VALID, iban)
- )
- );
- return;
- }
- throw new Error(
- `response status ${updatePaymentMethodResult.right.status}`
- );
- } else {
- throw new Error(readablePrivacyReport(updatePaymentMethodResult.left));
- }
- } catch (e) {
- yield* put(bpdUpsertIban.failure(convertUnknownToError(e)));
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/paymentMethod.ts b/ts/features/bonus/bpd/saga/networking/paymentMethod.ts
deleted file mode 100644
index 36c0be12c73..00000000000
--- a/ts/features/bonus/bpd/saga/networking/paymentMethod.ts
+++ /dev/null
@@ -1,194 +0,0 @@
-import { call, put } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import * as O from "fp-ts/lib/Option";
-import * as E from "fp-ts/lib/Either";
-import { pipe } from "fp-ts/lib/function";
-import {
- BpdPaymentMethodActivation,
- bpdPaymentMethodActivation,
- BpdPmActivationStatus,
- bpdUpdatePaymentMethodActivation,
- HPan
-} from "../../store/actions/paymentMethods";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { getError } from "../../../../../utils/errors";
-import {
- PaymentInstrumentResource,
- StatusEnum
-} from "../../../../../../definitions/bpd/payment/PaymentInstrumentResource";
-import { getPaymentStatus } from "../../store/reducers/details/paymentMethods";
-
-const mapStatus: Map = new Map<
- StatusEnum,
- BpdPmActivationStatus
->([
- [StatusEnum.ACTIVE, "active"],
- [StatusEnum.INACTIVE, "inactive"]
-]);
-
-// convert the network payload to the logical app representation of it
-const convertNetworkPayload = (
- networkPayload: PaymentInstrumentResource
-): BpdPaymentMethodActivation => ({
- hPan: networkPayload.hpan as HPan,
- activationStatus: pipe(
- mapStatus.get(networkPayload.Status),
- O.fromNullable,
- O.getOrElseW(() => "notActivable" as const)
- ),
- activationDate: networkPayload.activationDate,
- deactivationDate: networkPayload.deactivationDate
-});
-
-/**
- * return {@link BpdPaymentMethodActivation} when network response is conflict (409)
- */
-const whenConflict = (hPan: HPan): BpdPaymentMethodActivation => ({
- hPan,
- activationStatus: "notActivable"
-});
-
-/**
- * Request the actual state of bpd on a payment method
- */
-export function* bpdLoadPaymentMethodActivationSaga(
- findPaymentMethod: ReturnType["findPayment"],
- action: ActionType
-) {
- try {
- const findPaymentMethodResult: SagaCallReturnType<
- typeof findPaymentMethod
- > = yield* call(findPaymentMethod, { id: action.payload } as any);
- if (E.isRight(findPaymentMethodResult)) {
- if (findPaymentMethodResult.right.status === 200) {
- yield* put(
- bpdPaymentMethodActivation.success(
- convertNetworkPayload(findPaymentMethodResult.right.value)
- )
- );
- return;
- } else if (findPaymentMethodResult.right.status === 409) {
- // conflict means not activable
- yield* put(
- bpdPaymentMethodActivation.success(whenConflict(action.payload))
- );
- return;
- } else if (findPaymentMethodResult.right.status === 404) {
- yield* put(
- bpdPaymentMethodActivation.success({
- hPan: action.payload,
- activationStatus: "inactive"
- })
- );
- return;
- }
- throw new Error(
- `response status ${findPaymentMethodResult.right.status}`
- );
- } else {
- throw new Error(readableReport(findPaymentMethodResult.left));
- }
- } catch (e) {
- yield* put(
- bpdPaymentMethodActivation.failure({
- hPan: action.payload,
- error: getError(e)
- })
- );
- }
-}
-
-/**
- * Change the activation state on a payment method
- * action.payload.value: if true it enrolls the method otherwise it deletes it
- */
-export function* bpdUpdatePaymentMethodActivationSaga(
- enrollPayment: ReturnType["enrollPayment"],
- deletePayment: ReturnType["deletePayment"],
- action: ActionType
-) {
- if (action.payload.value) {
- yield* call(enrollPaymentMethod, enrollPayment, action);
- } else {
- yield* call(deletePaymentMethod, deletePayment, action);
- }
-}
-
-function* enrollPaymentMethod(
- enrollPaymentMethod: ReturnType["enrollPayment"],
- action: ActionType
-) {
- try {
- const enrollPaymentMethodResult: SagaCallReturnType<
- typeof enrollPaymentMethod
- > = yield* call(enrollPaymentMethod, { id: action.payload.hPan } as any);
- if (E.isRight(enrollPaymentMethodResult)) {
- if (enrollPaymentMethodResult.right.status === 200) {
- const responsePayload = enrollPaymentMethodResult.right.value;
- yield* put(
- bpdUpdatePaymentMethodActivation.success({
- hPan: action.payload.hPan,
- activationDate: responsePayload.activationDate,
- activationStatus: getPaymentStatus(action.payload.value)
- })
- );
- return;
- } else if (enrollPaymentMethodResult.right.status === 409) {
- yield* put(
- bpdUpdatePaymentMethodActivation.success(
- whenConflict(action.payload.hPan)
- )
- );
- return;
- }
- throw new Error(
- `response status ${enrollPaymentMethodResult.right.status}`
- );
- } else {
- throw new Error(readableReport(enrollPaymentMethodResult.left));
- }
- } catch (e) {
- yield* put(
- bpdUpdatePaymentMethodActivation.failure({
- hPan: action.payload.hPan,
- error: getError(e)
- })
- );
- }
-}
-
-function* deletePaymentMethod(
- deletePaymentMethod: ReturnType["deletePayment"],
- action: ActionType
-) {
- try {
- const deletePaymentMethodResult: SagaCallReturnType<
- typeof deletePaymentMethod
- > = yield* call(deletePaymentMethod, { id: action.payload.hPan } as any);
- if (E.isRight(deletePaymentMethodResult)) {
- if (deletePaymentMethodResult.right.status === 204) {
- yield* put(
- bpdUpdatePaymentMethodActivation.success({
- hPan: action.payload.hPan,
- activationStatus: getPaymentStatus(action.payload.value)
- })
- );
- return;
- }
- throw new Error(
- `response status ${deletePaymentMethodResult.right.status}`
- );
- } else {
- throw new Error(readableReport(deletePaymentMethodResult.left));
- }
- } catch (e) {
- yield* put(
- bpdUpdatePaymentMethodActivation.failure({
- hPan: action.payload.hPan,
- error: getError(e)
- })
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/periods.ts b/ts/features/bonus/bpd/saga/networking/periods.ts
deleted file mode 100644
index 8ec66a13d36..00000000000
--- a/ts/features/bonus/bpd/saga/networking/periods.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import * as O from "fp-ts/lib/Option";
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import { call } from "typed-redux-saga/macro";
-import { pipe } from "fp-ts/lib/function";
-import { AwardPeriodResource } from "../../../../../../definitions/bpd/award_periods/AwardPeriodResource";
-import { mixpanelTrack } from "../../../../../mixpanel";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../types/utils";
-import { convertUnknownToError, getError } from "../../../../../utils/errors";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import {
- AwardPeriodId,
- BpdPeriod,
- BpdPeriodStatus
-} from "../../store/actions/periods";
-
-// mapping between network payload status and app domain model status
-const periodStatusMap: Map = new Map<
- string,
- BpdPeriodStatus
->([
- ["ACTIVE", "Active"],
- ["INACTIVE", "Inactive"],
- ["CLOSED", "Closed"]
-]);
-
-// convert a network payload award period into the relative app domain model
-const convertPeriod = (
- networkPeriod: AwardPeriodResource,
- statusFallback: BpdPeriodStatus = "Inactive"
-): BpdPeriod => ({
- ...networkPeriod,
- awardPeriodId: networkPeriod.awardPeriodId as AwardPeriodId,
- superCashbackAmount: networkPeriod.maxAmount,
- status: pipe(
- periodStatusMap.get(networkPeriod.status),
- O.fromNullable,
- O.getOrElse(() => statusFallback)
- )
-});
-
-const mixpanelActionRequest = "BPD_PERIODS_REQUEST";
-const mixpanelActionSuccess = "BPD_PERIODS_SUCCESS";
-const mixpanelActionFailure = "BPD_PERIODS_FAILURE";
-
-/**
- * Networking logic to request the periods list
- * @param awardPeriods
- */
-export function* bpdLoadPeriodsSaga(
- awardPeriods: ReturnType["awardPeriods"]
-): Generator<
- ReduxSagaEffect,
- E.Either>,
- SagaCallReturnType
-> {
- void mixpanelTrack(mixpanelActionRequest);
- try {
- const awardPeriodsResult: SagaCallReturnType =
- yield* call(awardPeriods, {} as any);
- if (E.isRight(awardPeriodsResult)) {
- if (awardPeriodsResult.right.status === 200) {
- const periods = awardPeriodsResult.right.value;
- void mixpanelTrack(mixpanelActionSuccess, {
- count: periods.length
- });
- // convert data into app domain model
- return E.right>(
- periods.map(p => convertPeriod(p))
- );
- } else {
- throw new Error(`response status ${awardPeriodsResult.right.status}`);
- }
- } else {
- throw new Error(readableReport(awardPeriodsResult.left));
- }
- } catch (e) {
- void mixpanelTrack(mixpanelActionFailure, {
- reason: convertUnknownToError(e).message
- });
- return E.left>(getError(e));
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/ranking.ts b/ts/features/bonus/bpd/saga/networking/ranking.ts
deleted file mode 100644
index 372deb4e8a1..00000000000
--- a/ts/features/bonus/bpd/saga/networking/ranking.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import * as E from "fp-ts/lib/Either";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as RA from "fp-ts/lib/ReadonlyArray";
-import { call, put } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { CitizenRankingMilestoneResourceArray } from "../../../../../../definitions/bpd/citizen_v2/CitizenRankingMilestoneResourceArray";
-import { MilestoneResource } from "../../../../../../definitions/bpd/citizen_v2/MilestoneResource";
-import { mixpanelTrack } from "../../../../../mixpanel";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../types/utils";
-import { getError } from "../../../../../utils/errors";
-import { BackendBpdClient } from "../../api/backendBpdClient";
-import { AwardPeriodId } from "../../store/actions/periods";
-import {
- BpdTransactionId,
- bpdTransactionsLoadMilestone
-} from "../../store/actions/transactions";
-import { BpdRankingReady } from "../../store/reducers/details/periods";
-import { BpdPivotTransaction } from "../../store/reducers/details/transactionsv2/entities";
-
-const version = "_V2";
-
-const mixpanelActionRequest = `BPD_RANKING${version}_REQUEST`;
-const mixpanelActionSuccess = `BPD_RANKING${version}_SUCCESS`;
-const mixpanelActionFailure = `BPD_RANKING${version}_FAILURE`;
-
-// convert the network payload ranking into the relative app domain model
-const convertRankingArrayV2 = (
- rankings: CitizenRankingMilestoneResourceArray
-): ReadonlyArray =>
- rankings.map(rr => ({
- ...rr,
- awardPeriodId: rr.awardPeriodId as AwardPeriodId,
- pivot: extractPivot(rr.milestoneResource),
- kind: "ready"
- }));
-
-const extractPivot = (
- mr: MilestoneResource | undefined
-): BpdPivotTransaction | undefined => {
- if (mr?.idTrxPivot !== undefined && mr?.cashbackNorm !== undefined) {
- return {
- amount: mr.cashbackNorm,
- idTrx: mr.idTrxPivot as BpdTransactionId
- };
- }
- return undefined;
-};
-
-/**
- * Load the ranking for all the periods
- * @param getRanking
- */
-export function* bpdLoadRakingV2(
- getRanking: ReturnType["getRankingV2"]
-): Generator<
- ReduxSagaEffect,
- E.Either>,
- any
-> {
- try {
- void mixpanelTrack(mixpanelActionRequest);
- const getRankingResult: SagaCallReturnType = yield* call(
- getRanking,
- {} as any
- );
- if (E.isRight(getRankingResult)) {
- if (getRankingResult.right.status === 200) {
- void mixpanelTrack(mixpanelActionSuccess, {
- count: getRankingResult.right.value?.length
- });
- return E.right>(
- convertRankingArrayV2(getRankingResult.right.value)
- );
- } else if (getRankingResult.right.status === 404) {
- void mixpanelTrack(mixpanelActionSuccess, {
- count: 0
- });
- return E.right>([]);
- } else {
- return E.left>(
- new Error(`response status ${getRankingResult.right.status}`)
- );
- }
- } else {
- return E.left>(
- new Error(readableReport(getRankingResult.left))
- );
- }
- } catch (e) {
- void mixpanelTrack(mixpanelActionFailure, {
- reason: getError(e).message
- });
- return E.left>(getError(e));
- }
-}
-
-/**
- * Handle the action bpdTransactionsLoadMilestone.request
- * @param getRanking
- * @param action
- */
-export function* handleLoadMilestone(
- getRanking: ReturnType["getRankingV2"],
- action: ActionType
-) {
- // get the results
- const result: SagaCallReturnType = yield* call(
- bpdLoadRakingV2,
- getRanking
- );
-
- const extractMilestonePivot = pipe(
- result,
- E.chain(x =>
- E.fromOption(
- () =>
- new Error(
- `Period ${action.payload} not found in the ranking response`
- )
- )(
- pipe(
- x,
- RA.findFirst(el => el.awardPeriodId === action.payload),
- O.map(el => el.pivot)
- )
- )
- )
- );
-
- // dispatch the related action
- if (E.isRight(extractMilestonePivot)) {
- yield* put(
- bpdTransactionsLoadMilestone.success({
- awardPeriodId: action.payload,
- result: extractMilestonePivot.right
- })
- );
- } else {
- yield* put(
- bpdTransactionsLoadMilestone.failure({
- awardPeriodId: action.payload,
- error: extractMilestonePivot.left
- })
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/transactions.ts b/ts/features/bonus/bpd/saga/networking/transactions.ts
deleted file mode 100644
index 540d4f64fe2..00000000000
--- a/ts/features/bonus/bpd/saga/networking/transactions.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import { CircuitType } from "../../store/actions/transactions";
-
-/**
- * convert a network circuit into the relative app domain model
- * TODO we don't know which values circuit type could have
- * see https://docs.google.com/document/d/1LNbuPEeqyyt9fsJ8yAOOLQG1xLERO6nOdtlnG95cj74/edit#bookmark=id.nzho5vra0820
- */
-const mapNetworkCircuitType: Map = new Map<
- string,
- CircuitType
->([
- ["00", "PagoBancomat"],
- ["01", "Visa"],
- ["02", "Mastercard / Maestro"],
- ["03", "Amex"],
- ["04", "JCB"],
- ["05", "UnionPay"],
- ["06", "Diners"],
- ["07", "PostePay"],
- ["08", "BancomatPay"],
- ["10", "Private"]
-]);
-
-export const convertCircuitTypeCode = (code: string): CircuitType =>
- pipe(
- mapNetworkCircuitType.get(code),
- O.fromNullable,
- O.getOrElse(() => "Unknown" as CircuitType)
- );
diff --git a/ts/features/bonus/bpd/saga/networking/winning-transactions/countByDay.ts b/ts/features/bonus/bpd/saga/networking/winning-transactions/countByDay.ts
deleted file mode 100644
index 7927f59ab57..00000000000
--- a/ts/features/bonus/bpd/saga/networking/winning-transactions/countByDay.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import { call, put } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { mixpanelTrack } from "../../../../../../mixpanel";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../../types/utils";
-import { getError } from "../../../../../../utils/errors";
-import { BackendBpdClient } from "../../../api/backendBpdClient";
-import { AwardPeriodId } from "../../../store/actions/periods";
-import {
- bpdTransactionsLoadCountByDay,
- TrxCountByDayResource
-} from "../../../store/actions/transactions";
-
-const mixpanelActionRequest = `BPD_COUNT_BY_DAY_REQUEST`;
-const mixpanelActionSuccess = `BPD_COUNT_BY_DAY_SUCCESS`;
-const mixpanelActionFailure = `BPD_COUNT_BY_DAY_FAILURE`;
-
-/**
- * Load the countByDay for a period
- * @param getCountByDay
- * @param awardPeriodId
- */
-export function* bpdLoadCountByDay(
- getCountByDay: ReturnType<
- typeof BackendBpdClient
- >["winningTransactionsV2CountByDay"],
- awardPeriodId: AwardPeriodId
-): Generator<
- ReduxSagaEffect,
- E.Either,
- SagaCallReturnType
-> {
- try {
- void mixpanelTrack(mixpanelActionRequest, { awardPeriodId });
- const getCountByDayResults = yield* call(getCountByDay, {
- awardPeriodId
- } as any);
- if (E.isRight(getCountByDayResults)) {
- if (getCountByDayResults.right.status === 200) {
- void mixpanelTrack(mixpanelActionSuccess, {
- awardPeriodId,
- count: getCountByDayResults.right.value?.length
- });
- return E.right({
- awardPeriodId,
- results: getCountByDayResults.right.value
- });
- } else {
- return E.left(
- new Error(`response status ${getCountByDayResults.right.status}`)
- );
- }
- } else {
- return E.left(
- new Error(readableReport(getCountByDayResults.left))
- );
- }
- } catch (e) {
- void mixpanelTrack(mixpanelActionFailure, {
- awardPeriodId,
- reason: getError(e).message
- });
- return E.left(getError(e));
- }
-}
-
-/**
- * handle the action bpdTransactionsLoadCountByDay.request
- * @param getCountByDay
- * @param action
- */
-export function* handleCountByDay(
- getCountByDay: ReturnType<
- typeof BackendBpdClient
- >["winningTransactionsV2CountByDay"],
- action: ActionType
-) {
- // get the results
- const result: SagaCallReturnType = yield* call(
- bpdLoadCountByDay,
- getCountByDay,
- action.payload
- );
-
- // dispatch the related action
- if (E.isRight(result)) {
- yield* put(bpdTransactionsLoadCountByDay.success(result.right));
- } else {
- yield* put(
- bpdTransactionsLoadCountByDay.failure({
- awardPeriodId: action.payload,
- error: result.left
- })
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/winning-transactions/loadTransactionsRequiredData.ts b/ts/features/bonus/bpd/saga/networking/winning-transactions/loadTransactionsRequiredData.ts
deleted file mode 100644
index 25f370d8e46..00000000000
--- a/ts/features/bonus/bpd/saga/networking/winning-transactions/loadTransactionsRequiredData.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { call, put, take } from "typed-redux-saga/macro";
-import { ActionType, getType } from "typesafe-actions";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../../types/utils";
-import { waitBackoffError } from "../../../../../../utils/backoffError";
-import { AwardPeriodId } from "../../../store/actions/periods";
-import {
- BpdTransactionsError,
- bpdTransactionsLoadCountByDay,
- bpdTransactionsLoadMilestone,
- bpdTransactionsLoadPage,
- bpdTransactionsLoadRequiredData
-} from "../../../store/actions/transactions";
-
-/**
- * Load all the information required to render the transactions list :
- * - Milestone Pivot
- * - CountByDay
- * - First transaction page
- * These are the required information in order to do the first render for the transaction page
- */
-export function* loadTransactionsRequiredData(
- periodId: AwardPeriodId
-): Generator, any> {
- // We check if there is a failure on the whole loadTransactionsRequiredData block
- yield* call(waitBackoffError, bpdTransactionsLoadRequiredData.failure);
-
- // First request the Milestone Pivot
- yield* put(bpdTransactionsLoadMilestone.request(periodId));
-
- const milestoneResponse = yield* take<
- ActionType<
- | typeof bpdTransactionsLoadMilestone.success
- | typeof bpdTransactionsLoadMilestone.failure
- >
- >([
- bpdTransactionsLoadMilestone.success,
- bpdTransactionsLoadMilestone.failure
- ]);
-
- if (
- milestoneResponse.type === getType(bpdTransactionsLoadMilestone.failure)
- ) {
- return E.left({
- awardPeriodId: periodId,
- error: new Error("Failed to load bpd transactions milestone")
- });
- }
-
- // Request CountByDay
- yield* put(bpdTransactionsLoadCountByDay.request(periodId));
-
- const countByDayResponse = yield* take<
- ActionType<
- | typeof bpdTransactionsLoadCountByDay.success
- | typeof bpdTransactionsLoadCountByDay.failure
- >
- >([
- bpdTransactionsLoadCountByDay.success,
- bpdTransactionsLoadCountByDay.failure
- ]);
-
- if (
- countByDayResponse.type === getType(bpdTransactionsLoadCountByDay.failure)
- ) {
- return E.left({
- awardPeriodId: periodId,
- error: new Error("Failed to load bpd transactions countByDay")
- });
- }
-
- // Request first transaction page for the period
- yield* put(bpdTransactionsLoadPage.request({ awardPeriodId: periodId }));
-
- const firstPageResponse = yield* take<
- ActionType<
- | typeof bpdTransactionsLoadPage.success
- | typeof bpdTransactionsLoadPage.failure
- >
- >([bpdTransactionsLoadPage.success, bpdTransactionsLoadPage.failure]);
- if (firstPageResponse.type === getType(bpdTransactionsLoadPage.failure)) {
- return E.left({
- awardPeriodId: periodId,
- error: new Error("Failed to load the first transactions page")
- });
- }
- return E.right(true);
-}
-
-/**
- * Handle the trigger action bpdTransactionsLoadRequiredData.request
- * @param action
- */
-export function* handleTransactionsLoadRequiredData(
- action: ActionType
-) {
- // get the results
- const result: SagaCallReturnType =
- yield* call(loadTransactionsRequiredData, action.payload);
-
- if (E.isRight(result)) {
- yield* put(bpdTransactionsLoadRequiredData.success(action.payload));
- } else {
- yield* put(bpdTransactionsLoadRequiredData.failure(result.left));
- }
-}
diff --git a/ts/features/bonus/bpd/saga/networking/winning-transactions/transactionsPage.ts b/ts/features/bonus/bpd/saga/networking/winning-transactions/transactionsPage.ts
deleted file mode 100644
index 54cbcdfa6d1..00000000000
--- a/ts/features/bonus/bpd/saga/networking/winning-transactions/transactionsPage.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { readableReport } from "@pagopa/ts-commons/lib/reporters";
-import { call, put } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { mixpanelTrack } from "../../../../../../mixpanel";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../../types/utils";
-import { waitBackoffError } from "../../../../../../utils/backoffError";
-import { getError } from "../../../../../../utils/errors";
-import { BackendBpdClient } from "../../../api/backendBpdClient";
-import { AwardPeriodId } from "../../../store/actions/periods";
-import {
- BpdTransactionPageSuccessPayload,
- bpdTransactionsLoadPage
-} from "../../../store/actions/transactions";
-
-const mixpanelActionRequest = `BPD_TRANSACTIONS_PAGE_REQUEST`;
-const mixpanelActionSuccess = `BPD_TRANSACTIONS_PAGE_SUCCESS`;
-const mixpanelActionFailure = `BPD_TRANSACTIONS_PAGE_FAILURE`;
-
-/**
- * Load a page of transactions for a period
- * @param getTransactionPage
- * @param awardPeriodId
- * @param cursor
- */
-export function* bpdLoadTransactionsPage(
- getTransactionPage: ReturnType<
- typeof BackendBpdClient
- >["winningTransactionsV2"],
- awardPeriodId: AwardPeriodId,
- cursor?: number
-): Generator<
- ReduxSagaEffect,
- E.Either,
- SagaCallReturnType
-> {
- try {
- void mixpanelTrack(mixpanelActionRequest, { awardPeriodId, cursor });
- const getTransactionsPageResults = yield* call(getTransactionPage, {
- awardPeriodId,
- nextCursor: cursor
- } as any);
- if (E.isRight(getTransactionsPageResults)) {
- if (getTransactionsPageResults.right.status === 200) {
- void mixpanelTrack(mixpanelActionSuccess, {
- awardPeriodId,
- cursor,
- count: getTransactionsPageResults.right.value?.transactions.length
- });
- return E.right({
- awardPeriodId,
- results: getTransactionsPageResults.right.value
- });
- } else {
- return E.left(
- new Error(
- `response status ${getTransactionsPageResults.right.status}`
- )
- );
- }
- } else {
- return E.left(
- new Error(readableReport(getTransactionsPageResults.left))
- );
- }
- } catch (e) {
- void mixpanelTrack(mixpanelActionFailure, {
- awardPeriodId,
- cursor,
- reason: getError(e).message
- });
- return E.left(getError(e));
- }
-}
-
-/**
- * handle the action bpdTransactionsLoadCountByDay.request
- * @param getTransactionsPage
- * @param action
- */
-export function* handleTransactionsPage(
- getTransactionsPage: ReturnType<
- typeof BackendBpdClient
- >["winningTransactionsV2"],
- action: ActionType
-) {
- yield* call(waitBackoffError, bpdTransactionsLoadPage.failure);
- // get the results
- const result: SagaCallReturnType =
- yield* call(
- bpdLoadTransactionsPage,
- getTransactionsPage,
- action.payload.awardPeriodId,
- action.payload.nextCursor
- );
-
- // dispatch the related action
- if (E.isRight(result)) {
- yield* put(bpdTransactionsLoadPage.success(result.right));
- } else {
- yield* put(
- bpdTransactionsLoadPage.failure({
- awardPeriodId: action.payload.awardPeriodId,
- error: result.left
- })
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts b/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts
deleted file mode 100644
index 8c2b6aa8aba..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import * as E from "fp-ts/lib/Either";
-import { call } from "typed-redux-saga/macro";
-import { EnableableFunctionsEnum } from "../../../../../../definitions/pagopa/EnableableFunctions";
-import { navigateToWalletHome } from "../../../../../store/actions/navigation";
-import { PaymentMethod } from "../../../../../types/pagopa";
-import { SagaCallReturnType } from "../../../../../types/utils";
-import { hasFunctionEnabled } from "../../../../../utils/walletv2";
-import { isBpdEnabled } from "./onboarding/startOnboarding";
-
-/**
- * Allows the user to activate bpd on a set of new added payment methods
- */
-export function* activateBpdOnNewPaymentMethods(
- paymentMethods: ReadonlyArray,
- navigateToActivateNewMethods: () => void
-) {
- const atLeastOnePaymentMethodWithBpdCapability = paymentMethods.some(b =>
- hasFunctionEnabled(b, EnableableFunctionsEnum.BPD)
- );
-
- // No payment method with bpd capability added in the current workflow, return to wallet home
- if (!atLeastOnePaymentMethodWithBpdCapability) {
- return yield* call(navigateToWalletHome);
- }
- const isBpdEnabledResponse: SagaCallReturnType =
- yield* call(isBpdEnabled);
-
- // Error while reading the bpdEnabled, return to wallet
- if (E.isLeft(isBpdEnabledResponse)) {
- yield* call(navigateToWalletHome);
- } else {
- if (isBpdEnabledResponse.right) {
- // navigate to activate cashback on new payment methods if the user is onboarded to the program and is active
- yield* call(navigateToActivateNewMethods);
- }
- }
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/insertIban.ts b/ts/features/bonus/bpd/saga/orchestration/insertIban.ts
deleted file mode 100644
index e5e723e1bdf..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/insertIban.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { SagaIterator } from "redux-saga";
-import { call, put, select, take } from "typed-redux-saga/macro";
-import { ActionType, isActionOf } from "typesafe-actions";
-import {
- navigateBack,
- navigateToWalletHome
-} from "../../../../../store/actions/navigation";
-import { paymentMethodsSelector } from "../../../../../store/reducers/wallet/wallets";
-import {
- bpdIbanInsertionCancel,
- bpdIbanInsertionContinue
-} from "../../store/actions/iban";
-import { bpdOnboardingCompleted } from "../../store/actions/onboarding";
-import { isBpdOnboardingOngoing } from "../../store/reducers/onboarding/ongoing";
-
-// TODO: if isOnboarding===true, change with an action that triggers a saga that choose
-// which screen to display, (the user already have payment methods or not)
-
-/**
- * Old style orchestrator, please don't use this as reference for future development
- * @deprecated
- */
-export function* bpdIbanInsertionWorker() {
- const onboardingOngoing: ReturnType =
- yield* select(isBpdOnboardingOngoing);
- // ensure the first screen of the saga is the iban main screen.
-
- // wait for the user iban insertion o cancellation
- const nextAction = yield* take<
- ActionType
- >([bpdIbanInsertionCancel, bpdIbanInsertionContinue]);
- if (isActionOf(bpdIbanInsertionCancel, nextAction)) {
- yield* call(onboardingOngoing ? navigateToWalletHome : navigateBack);
- } else {
- if (onboardingOngoing) {
- const paymentMethods: ReturnType =
- yield* select(paymentMethodsSelector);
-
- // Error while loading the wallet, display a message that informs the user about the error
- if (paymentMethods.kind === "PotNoneError") {
- yield* put(bpdOnboardingCompleted());
- return;
- }
-
- yield* put(bpdOnboardingCompleted());
- } else {
- yield* call(navigateBack);
- }
- }
-}
-
-/**
- * This saga start the workflow that allows the user to insert / modify the IBAN associated to bpd.
- * In this first phase subject to changes, the call to the bpdIbanInsertionWorker is preserved,
- * instead of removing the call.
- */
-export function* handleBpdIbanInsertion(): SagaIterator {
- yield* call(bpdIbanInsertionWorker);
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts b/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts
deleted file mode 100644
index cd34de7c194..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { CommonActions } from "@react-navigation/native";
-import { call, put, race, take } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import NavigationService from "../../../../../../navigation/NavigationService";
-import { bpdAllData } from "../../../store/actions/details";
-import { bpdIbanInsertionStart } from "../../../store/actions/iban";
-import {
- bpdEnrollUserToProgram,
- bpdOnboardingCancel
-} from "../../../store/actions/onboarding";
-
-export const isLoadingScreen = () => true;
-
-/**
- * Old style orchestrator, please don't use this as reference for future development
- * @deprecated
- */
-function* enrollToBpdWorker() {
- const currentRoute: ReturnType =
- yield* call(NavigationService.getCurrentRouteName);
-
- if (currentRoute !== undefined && !isLoadingScreen()) {
- // show the loading page while communicate with the server for the activation
- throw new Error("Not in the loading screen");
- }
-
- // enroll the user and wait for the result
- yield* put(bpdEnrollUserToProgram.request());
-
- const enrollResult: ActionType =
- yield* take(bpdEnrollUserToProgram.success);
-
- if (enrollResult.payload.enabled) {
- yield* put(bpdAllData.request());
- yield* put(bpdIbanInsertionStart());
- }
- // TODO: handle false case to avoid making the user remain blocked in case of malfunction
-}
-
-/**
- * This saga enroll the user to the bpd
- */
-export function* handleBpdEnroll() {
- const { cancelAction } = yield* race({
- enroll: call(enrollToBpdWorker),
- cancelAction: take(bpdOnboardingCancel)
- });
-
- if (cancelAction) {
- yield* call(
- NavigationService.dispatchNavigationAction,
- CommonActions.goBack()
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts b/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts
deleted file mode 100644
index 78012d3cbb6..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { StackActions } from "@react-navigation/native";
-import * as E from "fp-ts/lib/Either";
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { call, put, select, take, race } from "typed-redux-saga/macro";
-import { ActionType } from "typesafe-actions";
-import { pipe } from "fp-ts/lib/function";
-import NavigationService from "../../../../../../navigation/NavigationService";
-import { navigateBack } from "../../../../../../store/actions/navigation";
-import { fetchWalletsRequest } from "../../../../../../store/actions/wallet/wallets";
-import {
- ReduxSagaEffect,
- SagaCallReturnType
-} from "../../../../../../types/utils";
-import { getAsyncResult } from "../../../../../../utils/saga";
-import { bpdLoadActivationStatus } from "../../../store/actions/details";
-import {
- bpdOnboardingAcceptDeclaration,
- bpdOnboardingCancel,
- bpdUserActivate
-} from "../../../store/actions/onboarding";
-import { bpdEnabledSelector } from "../../../store/reducers/details/activation";
-
-export const isLoadingScreen = () => true;
-
-export function* getActivationStatus() {
- return yield* call(() => getAsyncResult(bpdLoadActivationStatus, undefined));
-}
-
-export function* isBpdEnabled(): Generator<
- ReduxSagaEffect,
- E.Either,
- any
-> {
- const remoteActive: ReturnType = yield* select(
- bpdEnabledSelector
- );
- if (pot.isSome(remoteActive)) {
- return E.right(remoteActive.value);
- } else {
- const activationStatus = yield* call(getActivationStatus);
- return pipe(
- activationStatus,
- E.map(citizen => citizen.enabled)
- );
- }
-}
-
-/**
- * Old style orchestrator, please don't use this as reference for future development
- * @deprecated
- */
-export function* bpdStartOnboardingWorker() {
- const currentRoute: ReturnType =
- yield* call(NavigationService.getCurrentRouteName);
-
- // go to the loading page (if I'm not on that screen)
- if (currentRoute !== undefined && !isLoadingScreen()) {
- throw new Error("Not in the loading screen");
- }
-
- // read if the bpd is active for the user
- const isBpdActive: SagaCallReturnType = yield* call(
- isBpdEnabled
- );
-
- if (E.isRight(isBpdActive)) {
- // Refresh the wallets to prevent that added cards are not visible
- yield* put(fetchWalletsRequest());
-
- // 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
- }
-
- // The saga ends when the user accepts the declaration
- yield* take(bpdOnboardingAcceptDeclaration);
-}
-
-/**
- * This saga check if the bpd is active for the user and choose if start the onboarding or go directly to the bpd details
- */
-export function* handleBpdStartOnboardingSaga() {
- const { cancelAction } = yield* race({
- onboarding: call(bpdStartOnboardingWorker),
- cancelAction:
- take>(bpdOnboardingCancel)
- });
-
- if (cancelAction) {
- yield* call(
- NavigationService.dispatchNavigationAction,
- StackActions.popToTop()
- );
- yield* call(navigateBack);
- }
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInDeletionChoiceHandler.test.ts b/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInDeletionChoiceHandler.test.ts
deleted file mode 100644
index 2cb01d01737..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInDeletionChoiceHandler.test.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { testSaga } from "redux-saga-test-plan";
-import { optInDeletionChoiceHandler } from "../optInDeletionChoiceHandler";
-import {
- DeleteAllByFunctionSuccess,
- deleteAllPaymentMethodsByFunction
-} from "../../../../../../../store/actions/wallet/delete";
-import { EnableableFunctionsEnum } from "../../../../../../../../definitions/pagopa/EnableableFunctions";
-import { bpdUpdateOptInStatusMethod } from "../../../../store/actions/onboarding";
-import { CitizenOptInStatusEnum } from "../../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus";
-
-describe("optInDeletionChoiceHandler saga", () => {
- jest.useFakeTimers();
-
- it("If deleteAllPaymentMethodsByFunction fails, should return", () => {
- testSaga(optInDeletionChoiceHandler)
- .next()
- .put(
- deleteAllPaymentMethodsByFunction.request(EnableableFunctionsEnum.BPD)
- )
- .next()
- .take([
- deleteAllPaymentMethodsByFunction.success,
- deleteAllPaymentMethodsByFunction.failure
- ])
- .next(deleteAllPaymentMethodsByFunction.failure({ error: new Error() }))
- .isDone();
- });
-
- it("If deleteAllPaymentMethodsByFunction succeed, should put the bpdUpdateOptInStatusMethod.request action", () => {
- testSaga(optInDeletionChoiceHandler)
- .next()
- .put(
- deleteAllPaymentMethodsByFunction.request(EnableableFunctionsEnum.BPD)
- )
- .next()
- .take([
- deleteAllPaymentMethodsByFunction.success,
- deleteAllPaymentMethodsByFunction.failure
- ])
- .next(
- deleteAllPaymentMethodsByFunction.success(
- {} as DeleteAllByFunctionSuccess
- )
- )
- .put(bpdUpdateOptInStatusMethod.request(CitizenOptInStatusEnum.DENIED))
- .next()
- .isDone();
- });
-});
diff --git a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInShouldShowChoiceHandler.test.ts b/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInShouldShowChoiceHandler.test.ts
deleted file mode 100644
index 31950c6dd24..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/__tests__/optInShouldShowChoiceHandler.test.ts
+++ /dev/null
@@ -1,199 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { testSaga } from "redux-saga-test-plan";
-import { getType } from "typesafe-actions";
-import { CitizenOptInStatusEnum } from "../../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus";
-import {
- fetchWalletsFailure,
- fetchWalletsRequestWithExpBackoff,
- fetchWalletsSuccess
-} from "../../../../../../../store/actions/wallet/wallets";
-import {
- getBPDMethodsVisibleInWalletSelector,
- pagoPaCreditCardWalletV1Selector
-} from "../../../../../../../store/reducers/wallet/wallets";
-import {
- remoteReady,
- remoteUndefined
-} from "../../../../../../../common/model/RemoteValue";
-import {
- BpdActivationPayload,
- bpdLoadActivationStatus
-} from "../../../../store/actions/details";
-import { optInPaymentMethodsShowChoice } from "../../../../store/actions/optInPaymentMethods";
-import {
- activationStatusSelector,
- optInStatusSelector
-} from "../../../../store/reducers/details/activation";
-import { optInShouldShowChoiceHandler } from "../optInShouldShowChoiceHandler";
-
-const mockActivationStatus: BpdActivationPayload = {
- enabled: true,
- activationStatus: "never",
- payoffInstr: undefined,
- optInStatus: CitizenOptInStatusEnum.NOREQ
-};
-
-describe("optInShouldShowChoiceHandler saga", () => {
- jest.useFakeTimers();
-
- it("If bpdAllData fails, should dispatch the optInPaymentMethodsShowChoice.failure action and return", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.failure(new Error()))
- .put(optInPaymentMethodsShowChoice.failure(new Error()))
- .next()
- .isDone();
- });
-
- it("If bpdEnabled is not potSome, should dispatch the optInPaymentMethodsShowChoice.failure action and return", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(
- optInPaymentMethodsShowChoice.failure(
- new Error("The bpdEnabled value is not potSome")
- )
- )
- .next()
- .isDone();
- });
-
- it("If bpdEnabled is potSome with the value false, should dispatch the optInPaymentMethodsShowChoice.success action with payload false and return", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteReady("never"))
- .put(optInPaymentMethodsShowChoice.success(false))
- .next()
- .isDone();
- });
-
- it("If optInStatus is not potSome, should dispatch the optInPaymentMethodsShowChoice.failure action and return", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteReady("subscribed"))
- .select(optInStatusSelector)
- .next(pot.none)
- .put(
- optInPaymentMethodsShowChoice.failure(
- new Error("The optInStatus value is not potSome")
- )
- )
- .next()
- .isDone();
- });
-
- it("If optInStatus is potSome with value different from NOREQ, should dispatch the optInPaymentMethodsShowChoice.success action with payload false and return", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteReady("subscribed"))
- .select(optInStatusSelector)
- .next(pot.some(CitizenOptInStatusEnum.DENIED))
- .put(optInPaymentMethodsShowChoice.success(false))
- .next()
- .isDone();
- });
-
- it("If fetchWallets fails, should dispatch the optInPaymentMethodsShowChoice.failure action", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteReady("subscribed"))
- .select(optInStatusSelector)
- .next(pot.some(CitizenOptInStatusEnum.NOREQ))
- .select(pagoPaCreditCardWalletV1Selector)
- .next(pot.none)
- .put(fetchWalletsRequestWithExpBackoff())
- .next()
- .take([getType(fetchWalletsSuccess), getType(fetchWalletsFailure)])
- .next(fetchWalletsFailure(new Error()))
- .put(optInPaymentMethodsShowChoice.failure(new Error()))
- .next()
- .isDone();
- });
-
- it("If fetchWallets succeed, should dispatch the optInPaymentMethodsShowChoice.success action", () => {
- testSaga(optInShouldShowChoiceHandler)
- .next()
- .select(activationStatusSelector)
- .next(remoteUndefined)
- .put(bpdLoadActivationStatus.request())
- .next()
- .take([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ])
- .next(bpdLoadActivationStatus.success(mockActivationStatus))
- .select(activationStatusSelector)
- .next(remoteReady("subscribed"))
- .select(optInStatusSelector)
- .next(pot.some(CitizenOptInStatusEnum.NOREQ))
- .select(pagoPaCreditCardWalletV1Selector)
- .next(pot.none)
- .put(fetchWalletsRequestWithExpBackoff())
- .next()
- .take([getType(fetchWalletsSuccess), getType(fetchWalletsFailure)])
- .next(fetchWalletsSuccess([]))
- .select(getBPDMethodsVisibleInWalletSelector)
- .next([])
- .put(optInPaymentMethodsShowChoice.success(false))
- .next()
- .isDone();
- });
-});
diff --git a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInDeletionChoiceHandler.ts b/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInDeletionChoiceHandler.ts
deleted file mode 100644
index 05db6adfe00..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInDeletionChoiceHandler.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { put, take } from "typed-redux-saga/macro";
-import { ActionType, isActionOf } from "typesafe-actions";
-import { deleteAllPaymentMethodsByFunction } from "../../../../../../store/actions/wallet/delete";
-import { EnableableFunctionsEnum } from "../../../../../../../definitions/pagopa/EnableableFunctions";
-import { bpdUpdateOptInStatusMethod } from "../../../store/actions/onboarding";
-import { CitizenOptInStatusEnum } from "../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus";
-import { ReduxSagaEffect } from "../../../../../../types/utils";
-
-/**
- * This saga orchestrate the choice of the user to delete the payment methods added during the cashback.
- * This saga execute 2 actions:
- * - delete all the payment methods with the BPD capability
- * - store the user choice
- */
-
-export function* optInDeletionChoiceHandler(): Generator<
- ReduxSagaEffect,
- void,
- any
-> {
- // Perform the payment methods deletion
- yield* put(
- deleteAllPaymentMethodsByFunction.request(EnableableFunctionsEnum.BPD)
- );
- const deleteAllPaymentMethodsByFunctionStatus = yield* take<
- ActionType<
- | typeof deleteAllPaymentMethodsByFunction.success
- | typeof deleteAllPaymentMethodsByFunction.failure
- >
- >([
- deleteAllPaymentMethodsByFunction.success,
- deleteAllPaymentMethodsByFunction.failure
- ]);
- if (
- isActionOf(
- deleteAllPaymentMethodsByFunction.success,
- deleteAllPaymentMethodsByFunctionStatus
- )
- ) {
- // If the payment methods deletion succeeded, perform the opt-in update
- yield* put(
- bpdUpdateOptInStatusMethod.request(CitizenOptInStatusEnum.DENIED)
- );
- }
-}
diff --git a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInShouldShowChoiceHandler.ts b/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInShouldShowChoiceHandler.ts
deleted file mode 100644
index 171c7b86ca8..00000000000
--- a/ts/features/bonus/bpd/saga/orchestration/optInPaymentMethods/optInShouldShowChoiceHandler.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { put, select, take } from "typed-redux-saga/macro";
-import { ActionType, getType, isActionOf } from "typesafe-actions";
-import { CitizenOptInStatusEnum } from "../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus";
-import {
- fetchWalletsFailure,
- fetchWalletsRequestWithExpBackoff,
- fetchWalletsSuccess
-} from "../../../../../../store/actions/wallet/wallets";
-import {
- getBPDMethodsVisibleInWalletSelector,
- pagoPaCreditCardWalletV1Selector
-} from "../../../../../../store/reducers/wallet/wallets";
-import { ReduxSagaEffect } from "../../../../../../types/utils";
-import {
- isLoading,
- isReady,
- RemoteValue
-} from "../../../../../../common/model/RemoteValue";
-import {
- ActivationStatus,
- bpdLoadActivationStatus
-} from "../../../store/actions/details";
-import { optInPaymentMethodsShowChoice } from "../../../store/actions/optInPaymentMethods";
-import {
- activationStatusSelector,
- optInStatusSelector
-} from "../../../store/reducers/details/activation";
-
-/**
- * This saga manage the flow that checks if a user has already take a choice about the opt-in of the payment methods.
- *
- * The saga follows this flow:
- * - check if the user participate or not in the cashback program
- * - check if the user has already taken the opt-in payment methods choice
- * - request the user's payment methods
- * - check if the loading of the payment method succeed
- * - if succeed start the saga
- */
-export function* optInShouldShowChoiceHandler(): Generator<
- ReduxSagaEffect,
- void,
- any
-> {
- const bpdActivationInitialStatus: RemoteValue =
- yield* select(activationStatusSelector);
-
- // Check is needed to avoid to spawn multiple request if the status
- // is already loading
- if (!isLoading(bpdActivationInitialStatus)) {
- // Load the information about the participation of the user to the bpd program
- yield* put(bpdLoadActivationStatus.request());
- }
- const bpdLoadActivationStatusResponse = yield* take<
- ActionType<
- | typeof bpdLoadActivationStatus.success
- | typeof bpdLoadActivationStatus.failure
- >
- >([
- getType(bpdLoadActivationStatus.success),
- getType(bpdLoadActivationStatus.failure)
- ]);
-
- // If the bpdAllData request fail report the error
- if (
- isActionOf(bpdLoadActivationStatus.failure, bpdLoadActivationStatusResponse)
- ) {
- yield* put(
- optInPaymentMethodsShowChoice.failure(
- bpdLoadActivationStatusResponse.payload
- )
- );
- return;
- }
-
- const activationStatus: RemoteValue = yield* select(
- activationStatusSelector
- );
-
- // Safety check on field returned in @link{activationStatus} and managed by @{activationStatusReducer}
- if (!isReady(activationStatus)) {
- yield* put(
- optInPaymentMethodsShowChoice.failure(
- new Error("The bpdEnabled value is not potSome")
- )
- );
- return;
- }
-
- // If the user is never been enrolled in the bpd program returns with value false
- if (activationStatus.kind === "ready" && activationStatus.value === "never") {
- yield* put(optInPaymentMethodsShowChoice.success(false));
- return;
- }
-
- const optInStatus: pot.Pot = yield* select(
- optInStatusSelector
- );
-
- // Safety check on field returned in @link{optInStatus} and managed by @{optInStatusReducer}
- if (optInStatus.kind !== "PotSome") {
- yield* put(
- optInPaymentMethodsShowChoice.failure(
- new Error("The optInStatus value is not potSome")
- )
- );
- return;
- }
-
- // If the user already take a choice returns with value false
- if (optInStatus.value !== CitizenOptInStatusEnum.NOREQ) {
- yield* put(optInPaymentMethodsShowChoice.success(false));
- return;
- }
-
- // Check if wallets are already loaded
- // this check is needed becaus the exponential backoff would raise an error cause of the spawning of multiple requests
- const potWallets = yield* select(pagoPaCreditCardWalletV1Selector);
-
- if (!pot.isLoading(potWallets)) {
- // Load the user payment methods
- yield* put(fetchWalletsRequestWithExpBackoff());
- }
- const fetchWalletsResultAction = yield* take<
- ActionType
- >([getType(fetchWalletsSuccess), getType(fetchWalletsFailure)]);
-
- // If the loading work successfully starts the OptInPaymentMethods saga
- if (isActionOf(fetchWalletsSuccess, fetchWalletsResultAction)) {
- const bpdPaymentMethods = yield* select(
- getBPDMethodsVisibleInWalletSelector
- );
-
- if (bpdPaymentMethods.length > 0) {
- yield* put(optInPaymentMethodsShowChoice.success(true));
- return;
- }
- yield* put(optInPaymentMethodsShowChoice.success(false));
- } else {
- yield* put(
- optInPaymentMethodsShowChoice.failure(fetchWalletsResultAction.payload)
- );
- }
-}
diff --git a/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx b/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx
deleted file mode 100644
index 12d88cd55ce..00000000000
--- a/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx
+++ /dev/null
@@ -1,167 +0,0 @@
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { useEffect } from "react";
-import { StyleSheet, View } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import LoadingSpinnerOverlay from "../../../../../components/LoadingSpinnerOverlay";
-import DarkLayout from "../../../../../components/screens/DarkLayout";
-import SectionStatusComponent from "../../../../../components/SectionStatus";
-import I18n from "../../../../../i18n";
-import { navigateBack } from "../../../../../store/actions/navigation";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { emptyContextualHelp } from "../../../../../utils/emptyContextualHelp";
-import { showToast } from "../../../../../utils/showToast";
-import { useHardwareBackButton } from "../../../../../hooks/useHardwareBackButton";
-import BpdLastUpdateComponent from "../../components/BpdLastUpdateComponent";
-import {
- isError,
- isLoading,
- isReady
-} from "../../../../../common/model/RemoteValue";
-import { bpdAllData } from "../../store/actions/details";
-import {
- bpdUnsubscribeCompleted,
- bpdUnsubscribeFailure
-} from "../../store/actions/onboarding";
-import { bpdUnsubscriptionSelector } from "../../store/reducers/details/activation";
-import { bpdSelectedPeriodSelector } from "../../store/reducers/details/selectedPeriod";
-import { bpdTransactionsForSelectedPeriod } from "../../store/reducers/details/transactions";
-import BpdPeriodSelector from "./BpdPeriodSelector";
-import BpdPeriodDetail from "./periods/BpdPeriodDetail";
-import GoToTransactions from "./transaction/GoToTransactions";
-
-export type Props = ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- headerSpacer: {
- height: 172
- },
- selector: {
- // TODO: temp, as placeholder from invision, waiting for the components
- height: 192 + 10 + 16 + 16,
- width: "100%",
- position: "absolute",
- top: 16,
- zIndex: 7,
- elevation: 7
- },
- selectorSpacer: {
- height: 60
- }
-});
-
-/**
- * The screen that allows the user to see all the details related to the bpd.
- * @constructor
- */
-const BpdDetailsScreen: React.FunctionComponent = props => {
- const loading = isLoading(props.unsubscription);
- const {
- unsubscription,
- completeUnsubscriptionSuccess,
- completeUnsubscriptionFailure
- } = props;
-
- useEffect(() => {
- if (isError(unsubscription)) {
- showToast(I18n.t("bonus.bpd.unsubscribe.failure"), "danger");
- completeUnsubscriptionFailure();
- } else if (isReady(unsubscription)) {
- showToast(I18n.t("bonus.bpd.unsubscribe.success"), "success");
- completeUnsubscriptionSuccess();
- }
- }, [
- unsubscription,
- completeUnsubscriptionSuccess,
- completeUnsubscriptionFailure
- ]);
-
- useHardwareBackButton(() => {
- props.goBack();
- return true;
- });
-
- /**
- * Display the transactions button when:
- * - Period is closed and transactions number is > 0
- * - Period is active
- * never displays for inactive/incoming period
- */
- const canRenderButton = pipe(
- props.selectedPeriod,
- O.fromNullable,
- O.fold(
- () => false,
- sp => {
- switch (sp.status) {
- case "Closed":
- return pipe(
- props.selectedPeriod?.amount?.transactionNumber,
- O.fromNullable,
- O.map(trx => trx > 0),
- O.getOrElse(() => false)
- );
- case "Inactive":
- return false;
- default:
- return true;
- }
- }
- )
- );
- return (
-
- }
- gradientHeader={true}
- hideHeader={true}
- contextualHelp={emptyContextualHelp}
- footerContent={
- canRenderButton ? (
-
- ) : (
- // We need to render a footer element in order to have the right spacing when the device has the notch
-
- )
- }
- footerFullWidth={}
- >
-
-
-
-
-
-
-
-
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- completeUnsubscriptionSuccess: () => {
- dispatch(bpdAllData.request());
- dispatch(bpdUnsubscribeCompleted());
- navigateBack();
- },
- goToTransactions: () => null,
- goBack: () => navigateBack(),
- completeUnsubscriptionFailure: () => dispatch(bpdUnsubscribeFailure())
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- unsubscription: bpdUnsubscriptionSelector(state),
- transactions: bpdTransactionsForSelectedPeriod(state),
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdDetailsScreen);
diff --git a/ts/features/bonus/bpd/screens/details/BpdPeriodSelector.tsx b/ts/features/bonus/bpd/screens/details/BpdPeriodSelector.tsx
deleted file mode 100644
index d4770d5a015..00000000000
--- a/ts/features/bonus/bpd/screens/details/BpdPeriodSelector.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import * as AR from "fp-ts/lib/Array";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { useEffect, useState } from "react";
-import { View, StyleSheet } from "react-native";
-import { widthPercentageToDP } from "react-native-responsive-screen";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { IOColors } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../components/core/variables/IOStyles";
-import { HorizontalScroll } from "../../../../../components/HorizontalScroll";
-import { GlobalState } from "../../../../../store/reducers/types";
-import { BpdCardComponent } from "../../components/bpdCardComponent/BpdCardComponent";
-import { bpdSelectPeriod } from "../../store/actions/selectedPeriod";
-import { bpdPeriodsAmountWalletVisibleSelector } from "../../store/reducers/details/combiner";
-import { BpdPeriodWithInfo } from "../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../store/reducers/details/selectedPeriod";
-
-export type Props = ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- cardWrapper: {
- width: widthPercentageToDP("100%"),
- shadowColor: IOColors.black,
- shadowOffset: {
- width: 0,
- height: 7
- },
- shadowOpacity: 0.29,
- shadowRadius: 4.65,
- height: 192
- }
-});
-
-/**
- * An horizontal snap scroll view used to select a specific period of bpd.
- * Each period is represented as a BpdPeriodCard.
- * @constructor
- */
-const BpdPeriodSelector: React.FunctionComponent = props => {
- const periodWithAmountList = pot.getOrElse(props.periodsWithAmount, []);
- const [initialPeriod, setInitialperiod] = useState();
- const constructPeriodList = () =>
- periodWithAmountList.map((periodWithAmount, i) => (
-
-
-
- ));
-
- const selectPeriod = (index: number) =>
- pipe(
- periodWithAmountList[index],
- O.fromNullable,
- O.map(currentItem => {
- if (currentItem.awardPeriodId === props.selectedPeriod?.awardPeriodId) {
- return;
- }
- props.changeSelectPeriod(currentItem);
- })
- );
-
- useEffect(() => {
- if (initialPeriod === undefined) {
- setInitialperiod(
- pipe(
- periodWithAmountList,
- AR.findIndex(
- elem => elem.awardPeriodId === props.selectedPeriod?.awardPeriodId
- ),
- O.getOrElse(() => 0)
- )
- );
- }
- }, [
- initialPeriod,
- periodWithAmountList,
- props.selectedPeriod?.awardPeriodId
- ]);
-
- return (
-
- {pot.isSome(props.periodsWithAmount) &&
- props.periodsWithAmount.value.length > 0 && (
-
- )}
-
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- changeSelectPeriod: (period: BpdPeriodWithInfo) =>
- dispatch(bpdSelectPeriod(period))
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- // ATM the rules of visualization of a period in the selector is the same of the wallet
- periodsWithAmount: bpdPeriodsAmountWalletVisibleSelector(state),
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdPeriodSelector);
diff --git a/ts/features/bonus/bpd/screens/details/components/bottomsheet/HowItWorks.tsx b/ts/features/bonus/bpd/screens/details/components/bottomsheet/HowItWorks.tsx
deleted file mode 100644
index 4b970249384..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/bottomsheet/HowItWorks.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import Markdown from "../../../../../../../components/ui/Markdown";
-import I18n from "../../../../../../../i18n";
-import { localeDateFormat } from "../../../../../../../utils/locale";
-import { BpdPeriod } from "../../../../store/actions/periods";
-
-type Props = {
- period: BpdPeriod;
-};
-
-/**
- * Display information about the current period
- * @constructor
- */
-export const HowItWorks: React.FunctionComponent = props => (
-
-
-
-
- {I18n.t("bonus.bpd.details.howItWorks.body", {
- ...props.period,
- startDate: localeDateFormat(
- props.period.startDate,
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- ),
- endDate: localeDateFormat(
- props.period.endDate,
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- )
- })}
-
-
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/bottomsheet/WhyOtherCards.tsx b/ts/features/bonus/bpd/screens/details/components/bottomsheet/WhyOtherCards.tsx
deleted file mode 100644
index 73cc3570d60..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/bottomsheet/WhyOtherCards.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
-import ButtonDefaultOpacity from "../../../../../../../components/ButtonDefaultOpacity";
-import { Body } from "../../../../../../../components/core/typography/Body";
-import { Link } from "../../../../../../../components/core/typography/Link";
-import I18n from "../../../../../../../i18n";
-import { useLegacyIOBottomSheetModal } from "../../../../../../../utils/hooks/bottomSheet";
-import { openWebUrl } from "../../../../../../../utils/url";
-
-const styles = StyleSheet.create({
- link: {
- backgroundColor: IOColors.white,
- borderColor: IOColors.white,
- paddingRight: 0,
- paddingLeft: 0
- }
-});
-
-const findOutMore = "https://io.italia.it/cashback/faq/#n3_11";
-
-/**
- * Explains why there are other cards
- * @constructor
- */
-export const WhyOtherCards = () => (
-
-
-
-
- {I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.whyOtherCards.body"
- )}
-
- openWebUrl(findOutMore)}
- onPressWithGestureHandler={true}
- style={styles.link}
- >
-
- {I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.whyOtherCards.cta"
- )}
-
-
-
-
-);
-
-export const useWhyOtherCardsBottomSheet = () =>
- useLegacyIOBottomSheetModal(
- ,
- I18n.t(
- "bonus.bpd.details.paymentMethods.activateOnOthersChannel.whyOtherCards.title"
- ),
- 300
- );
diff --git a/ts/features/bonus/bpd/screens/details/components/iban/BaseIbanInformationComponent.tsx b/ts/features/bonus/bpd/screens/details/components/iban/BaseIbanInformationComponent.tsx
deleted file mode 100644
index 5ec7171ae5b..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/iban/BaseIbanInformationComponent.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import { Button } from "native-base";
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../../components/core/typography/H4";
-import { Label } from "../../../../../../../components/core/typography/Label";
-import { Link } from "../../../../../../../components/core/typography/Link";
-import { Monospace } from "../../../../../../../components/core/typography/Monospace";
-import { IOStyles } from "../../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../../i18n";
-import { isStringNullyOrEmpty } from "../../../../../../../utils/strings";
-import {
- isReady,
- RemoteValue
-} from "../../../../../../../common/model/RemoteValue";
-
-export type BaseIbanProps = {
- iban: string | undefined;
- technicalAccount: RemoteValue;
- onInsertIban: () => void;
-};
-
-const styles = StyleSheet.create({
- row: { flexDirection: "row", justifyContent: "space-between" },
- insertIbanButton: { width: "100%" }
-});
-
-/**
- * Render a Infobox that warns the user that should insert the IBAN to receive
- * the cashback amount
- * @param props
- * @constructor
- */
-const NoIbanComponent = (props: { onPress: () => void }) => (
- <>
-
- {I18n.t("bonus.bpd.details.components.iban.noIbanBody")}
-
-
-
- >
-);
-
-/**
- * Display the current IBAN
- * @constructor
- */
-const IbanComponent = (props: { iban: string }) => (
- {props.iban}
-);
-
-/**
- * Display the technical IBAN message
- * @constructor
- */
-const TechnicalIbanComponent = (props: { technicalIban: string }) => (
- {props.technicalIban}
-);
-
-export const BaseIbanInformationComponent: React.FunctionComponent<
- BaseIbanProps
-> = props => (
-
-
- {I18n.t("bonus.bpd.details.components.iban.title")}
- {!isStringNullyOrEmpty(props.iban) && (
-
- {I18n.t("global.buttons.edit").toLowerCase()}
-
- )}
-
-
- {/* Also if it is a technical IBAN the field IBAN is filled (with a fake IBAN). */}
- {props.iban ? (
- isReady(props.technicalAccount) &&
- props.technicalAccount.value !== undefined ? (
-
- ) : (
-
- )
- ) : (
-
- )}
-
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/iban/IbanInformationComponent.tsx b/ts/features/bonus/bpd/screens/details/components/iban/IbanInformationComponent.tsx
deleted file mode 100644
index 0ae8417a91f..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/iban/IbanInformationComponent.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import Placeholder from "rn-placeholder";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import {
- fold,
- RemoteValue
-} from "../../../../../../../common/model/RemoteValue";
-import { bpdIbanInsertionStart } from "../../../../store/actions/iban";
-import { bpdIbanSelector } from "../../../../store/reducers/details/activation";
-import { bpdTechnicalAccountSelector } from "../../../../store/reducers/details/activation/technicalAccount";
-import {
- BaseIbanInformationComponent,
- BaseIbanProps
-} from "./BaseIbanInformationComponent";
-
-export type Props = ReturnType &
- ReturnType;
-
-const LoadingIban = () => ;
-
-/**
- * Render the Iban based on the RemoteValue.
- * For safeness, even undefined, remote and error cases are managed, although the iban detail
- * screen is only accessible if bpd has been activated.
- * @param props
- * @constructor
- */
-const RenderRemoteIban = (
- props: {
- iban: RemoteValue;
- } & Omit
-) =>
- fold(
- props.iban,
- () => null,
- () => ,
- value => (
-
- ),
- _ => null
- );
-
-/**
- * Link {@link BaseIbanInformationComponent} to the business logic
- * Read the iban RemoteValue from the store
- * Dispatch bpdIbanInsertionStart() in case of new iban insertion (or modification
- * @param props
- * @constructor
- */
-const IbanInformationComponent: React.FunctionComponent = props => (
-
-);
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- startIbanOnboarding: () => dispatch(bpdIbanInsertionStart())
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- iban: bpdIbanSelector(state),
- technicalAccount: bpdTechnicalAccountSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(IbanInformationComponent);
diff --git a/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx b/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx
deleted file mode 100644
index e05b0760ad5..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/paymentMethod/WalletPaymentMethodBpdList.tsx
+++ /dev/null
@@ -1,207 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { useEffect, useState } from "react";
-import { View, ActivityIndicator, Alert, StyleSheet } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../../components/core/typography/H4";
-import { Link } from "../../../../../../../components/core/typography/Link";
-import I18n from "../../../../../../../i18n";
-import { navigateToWalletAddPaymentMethod } from "../../../../../../../store/actions/navigation";
-import { fetchWalletsRequestWithExpBackoff } from "../../../../../../../store/actions/wallet/wallets";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { showToast } from "../../../../../../../utils/showToast";
-import { PaymentMethodGroupedList } from "../../../../components/paymentMethodActivationToggle/list/PaymentMethodGroupedList";
-import {
- atLeastOnePaymentMethodHasBpdEnabledSelector,
- paymentMethodsWithActivationStatusSelector
-} from "../../../../store/reducers/details/combiner";
-
-type Props = ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- row: {
- flexDirection: "row",
- justifyContent: "space-between"
- }
-});
-
-const Spinner = () => (
-
-);
-
-const UpdateLabel = (props: Props & { caption: string }) =>
- pot.isLoading(props.potWallets) ? (
-
- ) : (
- {props.caption}
- );
-
-/**
- * No payment methods are active
- * @constructor
- */
-const NoPaymentMethodAreActiveWarning = () => (
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.noActiveMethod")}
-
-
-
-);
-
-/**
- * No payment methods are found
- * @constructor
- */
-const NoPaymentMethodFound = () => (
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.noPaymentMethods")}
-
-
-);
-
-/**
- * The wallet is none
- * @param props
- * @constructor
- */
-const PaymentMethodNone = (props: Props) => (
- <>
-
- {I18n.t("wallet.paymentMethods")}
-
-
- >
-);
-
-/**
- * The wallet is error
- * @param props
- * @constructor
- */
-const PaymentMethodError = (props: Props) => (
- <>
-
- {I18n.t("wallet.paymentMethods")}
-
-
-
-
- {I18n.t("bonus.bpd.details.paymentMethods.error")}
-
- >
-);
-
-/**
- * The wallet is some
- * @param props
- * @constructor
- */
-const PaymentMethodSome = (props: Props) =>
- pot.isSome(props.potWallets) ? (
-
-
- {I18n.t("wallet.paymentMethods")}
-
-
-
- {!props.atLeastOnePaymentMethodActive &&
- props.potWallets.value.length > 0 && (
-
- )}
-
- {props.potWallets.value.length > 0 ? (
-
- ) : (
-
- )}
-
- ) : null;
-
-const addPaymentMethod = (action: () => void) =>
- Alert.alert(
- I18n.t("global.genericAlert"),
- I18n.t("bonus.bpd.details.paymentMethods.add.alertBody"),
- [
- {
- text: I18n.t("global.buttons.continue"),
- onPress: action
- },
- {
- text: I18n.t("global.buttons.cancel"),
- style: "cancel"
- }
- ]
- );
-
-/**
- * Render all the wallet v2 as bpd toggle
- * @param props
- * @constructor
- */
-const WalletPaymentMethodBpdList: React.FunctionComponent = props => {
- const [potState, setPotCurrentState] = useState(props.potWallets.kind);
- const { potWallets } = props;
-
- useEffect(() => {
- if (potWallets.kind !== potState) {
- setPotCurrentState(potWallets.kind);
- if (pot.isError(potWallets)) {
- showToast(I18n.t("global.genericError"), "danger");
- }
- }
- }, [potWallets, potState]);
-
- return pot.fold(
- props.potWallets,
- () => ,
- () => ,
- _ => ,
- _ => ,
- _ => ,
- _ => ,
- _ => ,
- _ =>
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- addPaymentMethod: () => {
- addPaymentMethod(() =>
- navigateToWalletAddPaymentMethod({ inPayment: O.none })
- );
- },
- loadWallets: () => dispatch(fetchWalletsRequestWithExpBackoff())
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- potWallets: paymentMethodsWithActivationStatusSelector(state),
- atLeastOnePaymentMethodActive:
- atLeastOnePaymentMethodHasBpdEnabledSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(WalletPaymentMethodBpdList);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/BpdSummaryComponent.tsx b/ts/features/bonus/bpd/screens/details/components/summary/BpdSummaryComponent.tsx
deleted file mode 100644
index 32c9f8e9760..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/BpdSummaryComponent.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { View, StyleSheet } from "react-native";
-import { HSpacer, VSpacer } from "@pagopa/io-app-design-system";
-import { profileNameSelector } from "../../../../../../../store/reducers/profile";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { BpdPeriod } from "../../../../store/actions/periods";
-import { BpdPeriodWithInfo } from "../../../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../../../store/reducers/details/selectedPeriod";
-import SuperCashbackRankingSummary from "./ranking/SuperCashbackRankingSummary";
-import { TextualSummary } from "./textualSummary/TextualSummary";
-import TransactionsGraphicalSummary from "./TransactionsGraphicalSummary";
-
-type Props = ReturnType &
- ReturnType;
-
-type SummaryData = {
- period: BpdPeriodWithInfo;
- name: string | undefined;
-};
-
-const styles = StyleSheet.create({
- row: {
- flex: 1,
- flexDirection: "row"
- }
-});
-
-/**
- * The graphical summary is visible only when the period is closed or when the period is Active
- * and transactionNumber > 0
- * @param period
- */
-const isGraphicalSummaryVisible = (period: BpdPeriodWithInfo) =>
- period.status === "Closed" ||
- (period.status === "Active" && period.amount.transactionNumber > 0);
-
-/**
- * Return true if the SuperCashback is visible for the specified period
- * @param period
- */
-const isSuperCashbackVisible = (period: BpdPeriod) => period.minPosition > 0;
-
-const Content = (sd: SummaryData) => (
-
- {isGraphicalSummaryVisible(sd.period) ? (
-
-
- {isSuperCashbackVisible(sd.period) ? (
- <>
-
-
- >
- ) : null}
-
- ) : null}
-
-
-
-);
-
-/**
- * Display a summary with a graphical and textual information about the minimum transaction
- * and the amount earned for the period.
- * @constructor
- */
-const BpdSummaryComponent: React.FunctionComponent = props =>
- props.currentPeriod ? (
-
- ) : null;
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (state: GlobalState) => ({
- currentPeriod: bpdSelectedPeriodSelector(state),
- name: profileNameSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdSummaryComponent);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx
deleted file mode 100644
index 1086496f9f4..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import * as React from "react";
-import { StyleSheet, TouchableOpacity } from "react-native";
-import { connect } from "react-redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { H2 } from "../../../../../../../components/core/typography/H2";
-import { H5 } from "../../../../../../../components/core/typography/H5";
-import { IOStyles } from "../../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../../i18n";
-import { Dispatch } from "../../../../../../../store/actions/types";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { formatIntegerNumber } from "../../../../../../../utils/stringBuilder";
-import { BpdPeriod } from "../../../../store/actions/periods";
-import { BpdBaseShadowBoxLayout } from "./base/BpdBaseShadowBoxLayout";
-import { ProgressBar } from "./base/ProgressBar";
-
-type Props = {
- transactions: number;
- minTransactions: number;
- period: BpdPeriod;
-} & ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- title: {
- textAlign: "center"
- }
-});
-
-const loadLocales = () => ({
- title: I18n.t("bonus.bpd.details.components.transactionsCountOverview.title"),
- of: I18n.t("bonus.bpd.details.components.transactionsCountOverview.of")
-});
-
-/**
- * When transactions < minTransactions, display a progress bar with the related information
- * @param props
- * @deprecated not used anymore, it is kept for some time in case of second thoughts
- */
-export const PercentageTransactionsSummary = (props: Props) => {
- const { title, of } = loadLocales();
- return (
-
- {title}
-
- }
- row2={
-
-
- {formatIntegerNumber(props.transactions)}
-
{" "}
- {of} {formatIntegerNumber(props.minTransactions)}
-
- }
- row3={
- <>
-
-
- >
- }
- />
- );
-};
-
-/**
- * When transactions >= minTransactions, display only a textual summary
- * @param props
- * @constructor
- */
-const TextualTransactionsSummary = (props: Props) => {
- const { title, of } = loadLocales();
- return (
- {title}}
- row2={
-
- {formatIntegerNumber(props.transactions)}
-
- }
- row3={
-
- {of} {formatIntegerNumber(props.minTransactions)}
-
- }
- />
- );
-};
-
-/**
- * Displays to the user a summary of the transactions and how many are missing
- * to reach the minimum necessary to receive the cashback.
- * @param props
- * @constructor
- */
-const TransactionsGraphicalSummary = (props: Props) => (
-
-
-
-);
-
-const mapStateToProps = (_: GlobalState) => ({});
-
-const mapDispatchToProps = (_: Dispatch) => ({
- goToTransactions: () => null
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(TransactionsGraphicalSummary);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/base/BpdBaseShadowBoxLayout.tsx b/ts/features/bonus/bpd/screens/details/components/summary/base/BpdBaseShadowBoxLayout.tsx
deleted file mode 100644
index f3f0a76e69b..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/base/BpdBaseShadowBoxLayout.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { ShadowBox } from "./ShadowBox";
-
-type Props = {
- row1: React.ReactNode;
- row2: React.ReactNode;
- row3: React.ReactNode;
-};
-
-/**
- * Define a base layout for a bpd infobox, using a {@link ShadowBox}
- * @param props
- * @constructor
- */
-export const BpdBaseShadowBoxLayout: React.FunctionComponent = props => (
-
- {props.row1}
-
- {props.row2}
- {props.row3}
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/base/ShadowBox.tsx b/ts/features/bonus/bpd/screens/details/components/summary/base/ShadowBox.tsx
deleted file mode 100644
index d70870060db..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/base/ShadowBox.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { IOColors } from "@pagopa/io-app-design-system";
-import * as React from "react";
-import { View, StyleSheet } from "react-native";
-
-const styles = StyleSheet.create({
- body: {
- borderRadius: 8,
- backgroundColor: IOColors.white,
- shadowColor: IOColors.bluegreyDark,
- shadowOffset: {
- width: 0,
- height: 3
- },
- shadowOpacity: 0.2,
- shadowRadius: 2.0,
- elevation: 4,
- flex: 1,
- marginHorizontal: 2
- },
- container: {
- paddingVertical: 12,
- paddingHorizontal: 16
- }
-});
-
-/**
- * A base shadowed box with a content
- * @param props
- * @constructor
- */
-export const ShadowBox: React.FunctionComponent = props => (
-
- {props.children}
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/ranking/RankingNotReadyBottomSheet.tsx b/ts/features/bonus/bpd/screens/details/components/summary/ranking/RankingNotReadyBottomSheet.tsx
deleted file mode 100644
index 1bc966cf071..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/ranking/RankingNotReadyBottomSheet.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import I18n from "../../../../../../../../i18n";
-import Markdown from "../../../../../../../../components/ui/Markdown";
-import { useLegacyIOBottomSheetModal } from "../../../../../../../../utils/hooks/bottomSheet";
-
-/**
- * Display information about the current period
- * @constructor
- */
-const RankingNotReady = (): React.ReactElement => (
-
-
-
-
- {I18n.t("bonus.bpd.details.components.ranking.notReady.body")}
-
-
-
-);
-
-export const useRankingNotReadyBottomSheet = () =>
- useLegacyIOBottomSheetModal(
- ,
- I18n.t("bonus.bpd.details.components.ranking.notReady.title"),
- 450
- );
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx
deleted file mode 100644
index 1d8e852dd8a..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx
+++ /dev/null
@@ -1,154 +0,0 @@
-import { Icon, VSpacer } from "@pagopa/io-app-design-system";
-import * as React from "react";
-import { StyleSheet, TouchableOpacity, View } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { H2 } from "../../../../../../../../components/core/typography/H2";
-import { H5 } from "../../../../../../../../components/core/typography/H5";
-import { IOStyles } from "../../../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../../../i18n";
-import { GlobalState } from "../../../../../../../../store/reducers/types";
-import { formatIntegerNumber } from "../../../../../../../../utils/stringBuilder";
-import { useSuperCashbackRankingBottomSheet } from "../../../../../components/superCashbackRanking/SuperCashbackRanking";
-import {
- BpdPeriodWithInfo,
- BpdRanking,
- BpdRankingReady,
- isBpdRankingReady
-} from "../../../../../store/reducers/details/periods";
-import { BpdBaseShadowBoxLayout } from "../base/BpdBaseShadowBoxLayout";
-import { useRankingNotReadyBottomSheet } from "./RankingNotReadyBottomSheet";
-
-const loadLocales = () => ({
- title: I18n.t("bonus.bpd.details.components.ranking.title"),
- of: I18n.t("bonus.bpd.details.components.transactionsCountOverview.of"),
- wip: I18n.t("profile.preferences.list.wip")
-});
-
-const styles = StyleSheet.create({
- title: {
- textAlign: "center"
- }
-});
-
-type OwnProps = {
- period: BpdPeriodWithInfo;
-};
-
-type Props = ReturnType &
- ReturnType &
- OwnProps;
-
-const SuperCashbackRankingReady = (props: {
- ranking: number;
- minRanking: number;
-}): React.ReactElement => {
- const { title, of } = loadLocales();
- const { present, bottomSheet } = useSuperCashbackRankingBottomSheet();
- return (
- <>
- {bottomSheet}
-
-
- {title}
-
- }
- row2={
-
- {formatIntegerNumber(props.ranking)}°
-
- }
- row3={
-
- {of} {formatIntegerNumber(props.minRanking)}
-
- }
- />
-
- >
- );
-};
-
-const SuperCashbackRankingNotReady = (): React.ReactElement => {
- const { title, wip } = loadLocales();
- const { present, bottomSheet } = useRankingNotReadyBottomSheet();
- return (
- <>
- {bottomSheet}
-
-
- {title}
-
- }
- row2={
- <>
-
-
-
-
-
- >
- }
- row3={
-
- {wip}
-
- }
- />
-
- >
- );
-};
-
-/**
- * The ranking should be visible only when the remoteRanking is enabled && isBpdRankingReady
- * @param ranking
- * @param remoteEnabled
- */
-const shouldDisplayRankingReady = (
- ranking: BpdRanking,
- remoteEnabled: boolean | undefined
-): ranking is BpdRankingReady =>
- remoteEnabled === true && isBpdRankingReady(ranking);
-
-/**
- * Choose the right super cashback ranking representation:
- * 1) The ranking is ready: SuperCashbackRankingReady
- * 2) The ranking is not ready: TBD
- * TODO: the cashback ranking should also be remotely activable
- * @param props
- * @constructor
- */
-const SuperCashbackRankingSummary = (props: Props): React.ReactElement =>
- shouldDisplayRankingReady(props.period.ranking, undefined) ? (
-
- ) : (
-
- );
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (_: GlobalState) => ({});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(SuperCashbackRankingSummary);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ActiveTextualSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ActiveTextualSummary.tsx
deleted file mode 100644
index c4ad08c57c5..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ActiveTextualSummary.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import * as React from "react";
-import { InfoBox } from "../../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../../../components/core/typography/H4";
-import I18n from "../../../../../../../../i18n";
-import { formatNumberAmount } from "../../../../../../../../utils/stringBuilder";
-import { BpdPeriod } from "../../../../../store/actions/periods";
-import { isBpdRankingReady } from "../../../../../store/reducers/details/periods";
-import { TextualSummary } from "./TextualSummary";
-
-type Props = React.ComponentProps;
-
-/**
- * Display a warning for the current period if transactions < minTransaction and status === "Active"
- */
-const Warning = (props: { period: BpdPeriod }) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodKOBody.one"
- )}
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodKOBody.two",
- {
- transactions: props.period.minTransactionNumber
- }
- )}
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodKOBody.three"
- )}
-
-
-);
-
-/**
- * Display a message informing the user that the cashback is unlocked for the current period
- */
-const Unlock = (props: Props) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodUnlockBody",
- {
- transactions: props.period.minTransactionNumber,
- name: props.name
- }
- )}
-
-
-);
-
-/**
- * Display a message informing the user that he reached the max cashback amount for the current period
- */
-const MaxAmount = (props: { name: string | undefined }) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodMaxAmount",
- {
- name: props.name
- }
- )}
-
-
-);
-
-/**
- * Display a message informing the user that at the moment he may be eligible for supercashback
- */
-const SuperCashback = (props: { superCashbackAmount: number }) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.currentPeriodSuperCashback",
- { superCashbackAmount: formatNumberAmount(props.superCashbackAmount) }
- )}
-
-
-);
-
-export const ActiveTextualSummary = (props: Props) => {
- // active period but still not enough transaction
- if (
- props.period.amount.transactionNumber < props.period.minTransactionNumber &&
- props.period.amount.totalCashback > 0
- ) {
- return ;
- }
- if (
- props.period.amount.transactionNumber >= props.period.minTransactionNumber
- ) {
- // The user is in the supercashback ranking atm
- if (
- isBpdRankingReady(props.period.ranking) &&
- props.period.ranking.ranking <= props.period.minPosition
- ) {
- return (
-
- );
- }
- // The max cashback amount is reached
- if (props.period.amount.totalCashback >= props.period.maxPeriodCashback) {
- return ;
- }
- // Cashback unlocked! visible for the next 10 transaction only
- if (
- props.period.amount.transactionNumber <=
- props.period.minTransactionNumber + 10
- ) {
- return ;
- }
- }
- return null;
-};
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ClosedTextualSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ClosedTextualSummary.tsx
deleted file mode 100644
index 3948b728777..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/ClosedTextualSummary.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { InfoBox } from "../../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../../components/core/typography/Body";
-import I18n from "../../../../../../../../i18n";
-import { dateToAccessibilityReadableFormat } from "../../../../../../../../utils/accessibility";
-import { localeDateFormat } from "../../../../../../../../utils/locale";
-import {
- formatIntegerNumber,
- formatNumberAmount
-} from "../../../../../../../../utils/stringBuilder";
-import { BpdPeriod } from "../../../../../store/actions/periods";
-import { isGracePeriod } from "../../../../../store/reducers/details/periods";
-import { TextualSummary } from "./TextualSummary";
-
-type Props = React.ComponentProps;
-
-/**
- * We await receipt of the latest transactions to consolidate the count
- * @param props
- * @constructor
- */
-const GracePeriod = (props: { period: BpdPeriod }) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.gracePeriodBody",
- {
- date: dateToAccessibilityReadableFormat(props.period.endDate),
- endGracePeriodDate: dateToAccessibilityReadableFormat(
- endGracePeriod(props.period)
- )
- }
- )}
-
-
-);
-
-/**
- * The user doesn't receive the amount (not enough transactions for the closed period)
- * @param props
- * @constructor
- */
-const KO = (props: Props) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.closedPeriodKOBody",
- {
- transactions: formatIntegerNumber(props.period.minTransactionNumber),
- amount: formatNumberAmount(props.period.amount.totalCashback)
- }
- )}
-
-
-);
-
-const transferDate = (period: BpdPeriod) => {
- const endDate = new Date(period.endDate);
-
- // 60: max days to receive the money transfer
- endDate.setDate(period.endDate.getDate() + 60);
- return endDate;
-};
-
-const endGracePeriod = (period: BpdPeriod) => {
- const endDate = new Date(period.endDate);
-
- endDate.setDate(period.endDate.getDate() + period.gracePeriod);
- return endDate;
-};
-
-/**
- * Enriches the text in case of Super Cashback or max amount
- * @param props
- */
-const enhanceOkText = (props: Props): O.Option => {
- // the user earned the super cashback
- if (
- props.period.superCashbackAmount > 0 &&
- props.period.amount.totalCashback >= props.period.superCashbackAmount
- ) {
- return O.some(
- I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.closedPeriodSuperCashback",
- {
- amount: formatNumberAmount(props.period.superCashbackAmount)
- }
- )
- );
- }
- // the user earned the max amount
- else if (
- props.period.amount.totalCashback >= props.period.maxPeriodCashback
- ) {
- return O.some(
- I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.closedPeriodMaxAmount"
- )
- );
- }
- return O.none;
-};
-
-/**
- * The user will receive the refund!
- * @param props
- * @constructor
- */
-const OK = (props: Props) => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.closedPeriodOKBody",
- {
- name: props.name,
- amount: formatNumberAmount(props.period.amount.totalCashback)
- }
- )}
- {pipe(
- enhanceOkText(props),
- O.getOrElse(() => "")
- ) + "!\n"}
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.moneyTransfer",
- {
- date: localeDateFormat(
- transferDate(props.period),
- I18n.t("global.dateFormats.fullFormatFullMonthLiteral")
- )
- }
- )}
-
-
-);
-
-/**
- * Return a textual summary for a closed period
- * @param props
- * @constructor
- */
-export const ClosedTextualSummary = (props: Props) => {
- // we are still in the grace period and warns the user that some transactions
- // may still be pending
- if (isGracePeriod(props.period)) {
- return ;
- }
- // not enough transaction to receive the cashback
- if (
- props.period.amount.transactionNumber < props.period.minTransactionNumber
- ) {
- return ;
- }
- // Congratulation! cashback received
- return ;
-};
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/InactiveTextualSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/InactiveTextualSummary.tsx
deleted file mode 100644
index 5652f19b4d7..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/InactiveTextualSummary.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import * as React from "react";
-import { InfoBox } from "../../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../../components/core/typography/Body";
-import I18n from "../../../../../../../../i18n";
-import { dateToAccessibilityReadableFormat } from "../../../../../../../../utils/accessibility";
-import { BpdPeriod } from "../../../../../store/actions/periods";
-
-/**
- * Inform the user about the start date of the next period
- * @param props
- * @constructor
- */
-export const InactiveTextualSummary = (props: {
- period: BpdPeriod;
-}): React.ReactElement => (
-
-
- {I18n.t(
- "bonus.bpd.details.components.transactionsCountOverview.inactivePeriodBody",
- {
- date: dateToAccessibilityReadableFormat(props.period.startDate)
- }
- )}
-
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/TextualSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/TextualSummary.tsx
deleted file mode 100644
index be6e7bde7d4..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/summary/textualSummary/TextualSummary.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import * as React from "react";
-import { BpdPeriodWithInfo } from "../../../../../store/reducers/details/periods";
-import { ActiveTextualSummary } from "./ActiveTextualSummary";
-import { ClosedTextualSummary } from "./ClosedTextualSummary";
-import { InactiveTextualSummary } from "./InactiveTextualSummary";
-
-type Props = {
- period: BpdPeriodWithInfo;
- name: string | undefined;
-};
-
-/**
- * Render additional text information for the user, related to the transactions and cashback amount
- * Choose the textual infobox based on period and amount values
- * @param props
- * @constructor
- */
-export const TextualSummary = (props: Props): React.ReactElement => {
- switch (props.period.status) {
- case "Inactive":
- return ;
- case "Closed":
- return ;
- case "Active":
- return ;
- }
-};
diff --git a/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeComponent.tsx b/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeComponent.tsx
deleted file mode 100644
index 92c50fe7bd7..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeComponent.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { IOIconSizeScale, Icon, VSpacer } from "@pagopa/io-app-design-system";
-import { H3 } from "../../../../../../../components/core/typography/H3";
-import Markdown from "../../../../../../../components/ui/Markdown";
-import I18n from "../../../../../../../i18n";
-
-const iconSize: IOIconSizeScale = 48;
-
-/**
- * Informs the user about the consequences of the cashback unsubscription
- * @constructor
- */
-export const UnsubscribeComponent = (): React.ReactElement => (
-
-
-
-
- {I18n.t("bonus.bpd.unsubscribe.body1")}
-
- {I18n.t("bonus.bpd.unsubscribe.body2")}
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeToBpd.tsx b/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeToBpd.tsx
deleted file mode 100644
index b0005d0bf2d..00000000000
--- a/ts/features/bonus/bpd/screens/details/components/unsubscribe/UnsubscribeToBpd.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import * as React from "react";
-import { StyleSheet } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { IOColors } from "@pagopa/io-app-design-system";
-import ButtonDefaultOpacity from "../../../../../../../components/ButtonDefaultOpacity";
-import { Label } from "../../../../../../../components/core/typography/Label";
-import I18n from "../../../../../../../i18n";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { bpdDeleteUserFromProgram } from "../../../../store/actions/onboarding";
-import { identificationRequest } from "../../../../../../../store/actions/identification";
-import { shufflePinPadOnPayment } from "../../../../../../../config";
-import { useLegacyIOBottomSheetModal } from "../../../../../../../utils/hooks/bottomSheet";
-import {
- cancelButtonProps,
- errorButtonProps
-} from "../../../../../../../components/buttons/ButtonConfigurations";
-import FooterWithButtons from "../../../../../../../components/ui/FooterWithButtons";
-import { UnsubscribeComponent } from "./UnsubscribeComponent";
-
-type Props = ReturnType &
- ReturnType;
-
-const styles = StyleSheet.create({
- button: {
- width: "100%",
- borderColor: IOColors.red,
- borderWidth: 1,
- backgroundColor: IOColors.white
- }
-});
-
-/**
- * Allow the user to unsubscribe from bpd
- * @constructor
- */
-const UnsubscribeToBpd: React.FunctionComponent = props => {
- const { present, bottomSheet, dismiss } = useLegacyIOBottomSheetModal(
- ,
- I18n.t("bonus.bpd.unsubscribe.title"),
- 582,
- dismiss()),
- onPressWithGestureHandler: true
- }}
- rightButton={{
- ...errorButtonProps(() => {
- dismiss();
- props.cancelBpd();
- }, I18n.t("bonus.bpd.unsubscribe.confirmCta")),
- onPressWithGestureHandler: true
- }}
- />
- );
-
- return (
- <>
-
-
-
- {bottomSheet}
- >
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- cancelBpd: () => {
- const onSuccess = () => dispatch(bpdDeleteUserFromProgram.request());
- dispatch(
- identificationRequest(
- false,
- true,
- undefined,
- {
- label: I18n.t("global.buttons.cancel"),
- onCancel: () => undefined
- },
- {
- onSuccess
- },
- shufflePinPadOnPayment
- )
- );
- }
-});
-
-const mapStateToProps = (_: GlobalState) => ({});
-
-export default connect(mapStateToProps, mapDispatchToProps)(UnsubscribeToBpd);
diff --git a/ts/features/bonus/bpd/screens/details/periods/BpdActivePeriod.tsx b/ts/features/bonus/bpd/screens/details/periods/BpdActivePeriod.tsx
deleted file mode 100644
index bd8329460e6..00000000000
--- a/ts/features/bonus/bpd/screens/details/periods/BpdActivePeriod.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import IbanInformationComponent from "../components/iban/IbanInformationComponent";
-import BpdSummaryComponent from "../components/summary/BpdSummaryComponent";
-import UnsubscribeToBpd from "../components/unsubscribe/UnsubscribeToBpd";
-import WalletPaymentMethodBpdList from "../components/paymentMethod/WalletPaymentMethodBpdList";
-
-export type Props = ReturnType &
- ReturnType;
-
-/**
- * Render the details for a current active cashback period
- * @constructor
- */
-const BpdActivePeriod: React.FunctionComponent = () => (
-
-
-
-
-
-
-
-
-
-
-
-);
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (_: GlobalState) => ({});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdActivePeriod);
diff --git a/ts/features/bonus/bpd/screens/details/periods/BpdClosedPeriod.tsx b/ts/features/bonus/bpd/screens/details/periods/BpdClosedPeriod.tsx
deleted file mode 100644
index 1dddc2e798e..00000000000
--- a/ts/features/bonus/bpd/screens/details/periods/BpdClosedPeriod.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import {
- BpdPeriodWithInfo,
- isGracePeriod
-} from "../../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../../store/reducers/details/selectedPeriod";
-import IbanInformationComponent from "../components/iban/IbanInformationComponent";
-import BpdSummaryComponent from "../components/summary/BpdSummaryComponent";
-
-export type Props = ReturnType &
- ReturnType;
-
-const shouldRenderIbanComponent = (period: BpdPeriodWithInfo) =>
- isGracePeriod(period) ||
- (period.status === "Closed" &&
- period.amount.transactionNumber >= period.minTransactionNumber);
-
-/**
- * Render the details for a completed and closed cashback periods
- * @constructor
- */
-const BpdClosedPeriod = (props: Props): React.ReactElement => (
-
-
-
-
- {props.currentPeriod && shouldRenderIbanComponent(props.currentPeriod) && (
- <>
-
-
- >
- )}
-
-);
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (state: GlobalState) => ({
- currentPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdClosedPeriod);
diff --git a/ts/features/bonus/bpd/screens/details/periods/BpdInactivePeriod.tsx b/ts/features/bonus/bpd/screens/details/periods/BpdInactivePeriod.tsx
deleted file mode 100644
index cd4a9300d54..00000000000
--- a/ts/features/bonus/bpd/screens/details/periods/BpdInactivePeriod.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import IbanInformationComponent from "../components/iban/IbanInformationComponent";
-import BpdSummaryComponent from "../components/summary/BpdSummaryComponent";
-import UnsubscribeToBpd from "../components/unsubscribe/UnsubscribeToBpd";
-import WalletPaymentMethodBpdList from "../components/paymentMethod/WalletPaymentMethodBpdList";
-
-export type Props = ReturnType &
- ReturnType;
-
-/**
- * Render the details for a future cashback period
- * @constructor
- */
-const BpdInactivePeriod: React.FunctionComponent = () => (
-
-
-
-
-
-
-
-
-
-
-
-);
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (_: GlobalState) => ({});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdInactivePeriod);
diff --git a/ts/features/bonus/bpd/screens/details/periods/BpdPeriodDetail.tsx b/ts/features/bonus/bpd/screens/details/periods/BpdPeriodDetail.tsx
deleted file mode 100644
index 4ab0821aeb7..00000000000
--- a/ts/features/bonus/bpd/screens/details/periods/BpdPeriodDetail.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import { BpdPeriodWithInfo } from "../../../store/reducers/details/periods";
-import { bpdSelectedPeriodSelector } from "../../../store/reducers/details/selectedPeriod";
-import BpdActivePeriod from "./BpdActivePeriod";
-import BpdClosedPeriod from "./BpdClosedPeriod";
-import BpdInactivePeriod from "./BpdInactivePeriod";
-
-export type Props = ReturnType &
- ReturnType;
-
-const selectPeriodScreen = (period: BpdPeriodWithInfo) => {
- switch (period.status) {
- case "Active":
- return ;
- case "Closed":
- return ;
- case "Inactive":
- return ;
- }
-};
-
-/**
- * The body and details for a specific cashback period. Will change if is Active, Inactive or Closed
- * @constructor
- */
-const BpdPeriodDetail: React.FunctionComponent = props => (
-
- {props.selectedPeriod && selectPeriodScreen(props.selectedPeriod)}
-
-);
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (state: GlobalState) => ({
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(BpdPeriodDetail);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/BpdAvailableTransactionsScreen.tsx b/ts/features/bonus/bpd/screens/details/transaction/BpdAvailableTransactionsScreen.tsx
deleted file mode 100644
index e7fb721c6f1..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/BpdAvailableTransactionsScreen.tsx
+++ /dev/null
@@ -1,339 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { compareDesc } from "date-fns";
-import * as AR from "fp-ts/lib/Array";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import {
- View,
- SafeAreaView,
- ScrollView,
- SectionList,
- SectionListData,
- SectionListRenderItem
-} from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../components/box/InfoBox";
-import { H1 } from "../../../../../../components/core/typography/H1";
-import { H4 } from "../../../../../../components/core/typography/H4";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent";
-import I18n from "../../../../../../i18n";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import { emptyContextualHelp } from "../../../../../../utils/emptyContextualHelp";
-import { localeDateFormat } from "../../../../../../utils/locale";
-import BaseDailyTransactionHeader from "../../../components/BaseDailyTransactionHeader";
-import BpdTransactionSummaryComponent from "../../../components/BpdTransactionSummaryComponent";
-import {
- BpdTransactionItem,
- EnhancedBpdTransaction
-} from "../../../components/transactionItem/BpdTransactionItem";
-import {
- atLeastOnePaymentMethodHasBpdEnabledSelector,
- bpdDisplayTransactionsSelector,
- paymentMethodsWithActivationStatusSelector
-} from "../../../store/reducers/details/combiner";
-import { bpdSelectedPeriodSelector } from "../../../store/reducers/details/selectedPeriod";
-import BpdCashbackMilestoneComponent from "./BpdCashbackMilestoneComponent";
-import BpdEmptyTransactionsList from "./BpdEmptyTransactionsList";
-import { BpdTransactionDetailRepresentation } from "./detail/BpdTransactionDetailComponent";
-
-export type Props = ReturnType &
- ReturnType;
-
-type TotalCashbackPerDate = {
- trxDate: Date;
- totalCashBack: number;
-};
-
-const dataForFlatList = (
- transactions: pot.Pot, Error>
-) => pot.getOrElse(transactions, []);
-
-export const isTotalCashback = (item: any): item is TotalCashbackPerDate =>
- item.totalCashBack !== undefined;
-
-/**
- * Builds the array of objects needed to show the sectionsList grouped by transaction day.
- *
- * We check the subtotal of TotalCashback earned on each transaction to check when the user reaches the cashback.
- *
- * When creating the final array if we reached the cashback amount we set all the following transaction cashback value to 0
- *
- * If the sum of cashback comes over the award we remove the exceeding part on the transaction.
- * @param transactions
- * @param cashbackAward
- */
-const getTransactionsByDaySections = (
- transactions: ReadonlyArray,
- cashbackAward: number
-): ReadonlyArray<
- SectionListData
-> => {
- const dates = [
- ...new Set(
- transactions.map(trx =>
- localeDateFormat(trx.trxDate, I18n.t("global.dateFormats.dayFullMonth"))
- )
- )
- ];
-
- const transactionsAsc = AR.reverse([...transactions]);
-
- // accumulator to define when the user reached the cashback award amount
- // and tracing the sum of all the cashback value to check if any negative trx may cause a revoke of cashback award
- const amountWinnerAccumulator = transactionsAsc.reduce(
- (
- acc: {
- winner?: {
- amount: number;
- index: number;
- date: Date;
- };
- sumAmount: number;
- },
- t: EnhancedBpdTransaction,
- currIndex: number
- ) => {
- const sum = acc.sumAmount + t.cashback;
- if (sum >= cashbackAward && !acc.winner) {
- return {
- winner: {
- amount: sum,
- index: currIndex,
- date: new Date(t.trxDate)
- },
- sumAmount: sum
- };
- } else if (sum < cashbackAward) {
- return {
- sumAmount: sum
- };
- }
- return {
- ...acc,
- sumAmount: sum
- };
- },
- {
- sumAmount: 0
- }
- );
-
- const maybeWinner = O.fromNullable(amountWinnerAccumulator.winner);
-
- // If the user reached the cashback amount within transactions we actualize all the cashback value starting from the index of winning transaction
- // if the winning transaction makes cashback value exceed the limit we set the amount to the difference of transaction cashback value, total amout at winnign transaction and cashback award limit.
- // all the following transactions will be set to 0 cashback value, since the limit has been reached (a dedicated item will be displayed)
- const updatedTransactions = [...transactionsAsc].map(
- (t, i): BpdTransactionDetailRepresentation => {
- if (O.isSome(maybeWinner)) {
- if (
- i === maybeWinner.value.index &&
- maybeWinner.value.amount > cashbackAward
- ) {
- return {
- ...t,
- cashback: t.cashback - (maybeWinner.value.amount - cashbackAward),
- validForCashback: true
- };
- } else if (i > maybeWinner.value.index) {
- return {
- ...t,
- cashback: 0,
- validForCashback: false
- };
- }
- }
- return { ...t, validForCashback: true };
- }
- );
-
- return dates.map(d => ({
- title: d,
- data: [
- ...updatedTransactions.filter(
- t =>
- localeDateFormat(
- t.trxDate,
- I18n.t("global.dateFormats.dayFullMonth")
- ) === d
- ),
- // we add the the data array an item to display the milestone reached
- // in order to display the milestone after the latest transaction summed in the total we add 1 ms so that the ordering will set it correctly
- ...pipe(
- maybeWinner,
- O.fold(
- () => [],
- w => {
- if (
- localeDateFormat(
- w.date,
- I18n.t("global.dateFormats.dayFullMonth")
- ) === d
- ) {
- return [
- {
- totalCashBack: w.amount,
- trxDate: new Date(
- w.date.setMilliseconds(w.date.getMilliseconds() + 1)
- )
- }
- ];
- }
- return [];
- }
- )
- )
- ].sort((trx1, trx2) => compareDesc(trx1.trxDate, trx2.trxDate))
- }));
-};
-
-const renderSectionHeader = (info: {
- section: SectionListData<
- BpdTransactionDetailRepresentation | TotalCashbackPerDate
- >;
-}): React.ReactNode => (
- !isTotalCashback(i)).length
- }
- />
-);
-
-export const NoPaymentMethodAreActiveWarning = () => (
-
-
-
- {I18n.t("bonus.bpd.details.transaction.noPaymentMethod.text1")}
-
- {I18n.t("bonus.bpd.details.transaction.noPaymentMethod.text2")}
-
- {I18n.t("bonus.bpd.details.transaction.noPaymentMethod.text3")}
-
-
-
-
-);
-
-/**
- * Display all the transactions for a specific period
- * TODO: scroll to refresh, display error, display loading
- * @constructor
- */
-const BpdAvailableTransactionsScreen: React.FunctionComponent<
- Props
-> = props => {
- const transactions = dataForFlatList(props.transactionForSelectedPeriod);
-
- const trxSortByDate = [...transactions].sort((trx1, trx2) =>
- compareDesc(trx1.trxDate, trx2.trxDate)
- );
-
- const maybeLastUpdateDate = pipe(
- [...trxSortByDate].map(t => t.trxDate),
- AR.lookup(0)
- );
-
- const renderTransactionItem: SectionListRenderItem<
- BpdTransactionDetailRepresentation | TotalCashbackPerDate
- > = info => {
- if (isTotalCashback(info.item)) {
- return (
- 0,
- p => p.maxPeriodCashback
- )
- )}
- />
- );
- }
- return ;
- };
-
- return (
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.title")}
-
-
-
-
- {props.selectedPeriod && O.isSome(maybeLastUpdateDate) && (
- <>
-
-
- >
- )}
-
- {props.selectedPeriod &&
- (transactions.length > 0 ? (
-
- isTotalCashback(t)
- ? `awarded_cashback_item${t.totalCashBack}`
- : t.keyId
- }
- />
- ) : !props.atLeastOnePaymentMethodActive &&
- pot.isSome(props.potWallets) &&
- props.potWallets.value.length > 0 ? (
-
-
-
- ) : (
-
-
-
- ))}
-
-
-
- );
-};
-
-const mapDispatchToProps = (_: Dispatch) => ({});
-
-const mapStateToProps = (state: GlobalState) => ({
- transactionForSelectedPeriod: bpdDisplayTransactionsSelector(state),
- selectedPeriod: bpdSelectedPeriodSelector(state),
- potWallets: paymentMethodsWithActivationStatusSelector(state),
- atLeastOnePaymentMethodActive:
- atLeastOnePaymentMethodHasBpdEnabledSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdAvailableTransactionsScreen);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/BpdCashbackMilestoneComponent.tsx b/ts/features/bonus/bpd/screens/details/transaction/BpdCashbackMilestoneComponent.tsx
deleted file mode 100644
index 0c1986c28ed..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/BpdCashbackMilestoneComponent.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as React from "react";
-import { View, Image, StyleSheet } from "react-native";
-import { IOColors } from "@pagopa/io-app-design-system";
-import fireworksIcon from "../../../../../../../img/bonus/bpd/fireworks.png";
-import { formatNumberAmount } from "../../../../../../utils/stringBuilder";
-import { H4 } from "../../../../../../components/core/typography/H4";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../i18n";
-
-type Props = {
- cashbackValue: number;
-};
-
-const styles = StyleSheet.create({
- container: {
- flexDirection: "row",
- alignItems: "center",
- justifyContent: "space-between",
- backgroundColor: IOColors.blue,
- paddingVertical: 16
- },
- image: { width: 32, height: 32, resizeMode: "cover" },
- textPadding: {
- paddingHorizontal: 16
- }
-});
-const BpdCashbackMilestoneComponent: React.FunctionComponent = (
- props: Props
-) => (
-
-
-
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.milestone.title",
- { cashbackValue: formatNumberAmount(props.cashbackValue, true) }
- )}
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.summary.milestone.body")}
-
-
-
-);
-
-export default BpdCashbackMilestoneComponent;
diff --git a/ts/features/bonus/bpd/screens/details/transaction/BpdEmptyTransactionsList.tsx b/ts/features/bonus/bpd/screens/details/transaction/BpdEmptyTransactionsList.tsx
deleted file mode 100644
index b0d44b9bcc8..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/BpdEmptyTransactionsList.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { View } from "react-native";
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../components/core/typography/H4";
-import I18n from "../../../../../../i18n";
-import { BottomSheetBpdTransactionsBody } from "../../../components/BpdTransactionSummaryComponent";
-
-const BpdEmptyTransactionsList: React.FunctionComponent = () => (
- <>
-
- {I18n.t("bonus.bpd.details.transaction.detail.empty.text1")}
- {I18n.t("bonus.bpd.details.transaction.detail.empty.text2")}
-
-
-
-
-
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text1"
- )}
-
- {" "}
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text2"
- )}
-
- {I18n.t(
- "bonus.bpd.details.transaction.detail.summary.calendarBlock.text3"
- )}
-
-
-
-
- >
-);
-
-export default BpdEmptyTransactionsList;
diff --git a/ts/features/bonus/bpd/screens/details/transaction/BpdTransactionsScreen.tsx b/ts/features/bonus/bpd/screens/details/transaction/BpdTransactionsScreen.tsx
deleted file mode 100644
index c037245eac2..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/BpdTransactionsScreen.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import * as React from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { GlobalState } from "../../../../../../store/reducers/types";
-import { EnhancedBpdTransaction } from "../../../components/transactionItem/BpdTransactionItem";
-import { bpdAllData } from "../../../store/actions/details";
-import { bpdDisplayTransactionsSelector } from "../../../store/reducers/details/combiner";
-import { bpdLastUpdateSelector } from "../../../store/reducers/details/lastUpdate";
-import BpdAvailableTransactionsScreen from "./BpdAvailableTransactionsScreen";
-import LoadTransactions from "./LoadTransactions";
-import TransactionsUnavailable from "./TransactionsUnavailable";
-
-export type Props = ReturnType &
- ReturnType;
-
-/**
- * Associate at every state of the pot transactions status the right screen to show
- * @param transactions
- */
-const handleTransactionsStatus = (
- transactions: pot.Pot, Error>
-) =>
- pot.fold(
- transactions,
- () => ,
- () => ,
- _ => ,
- _ => ,
- _ => ,
- _ => ,
- _ => ,
- _ =>
- );
-
-/**
- * Display all the transactions for a specific period if available, in other case show a loading or an error screen.
- * First check the whole bpd status than if is some check the transactions status.
- * TODO: Delete, replaced by BpdTransactionsRouterScreen
- * @deprecated
- * @constructor
- */
-const BpdTransactionsScreen: React.FC = (props: Props) => {
- const { bpdLastUpdate, transactionForSelectedPeriod, loadTransactions } =
- props;
- React.useEffect(() => {
- if (
- pot.isError(bpdLastUpdate) ||
- pot.isError(transactionForSelectedPeriod)
- ) {
- loadTransactions();
- }
- }, [bpdLastUpdate, transactionForSelectedPeriod, loadTransactions]);
- return pot.fold(
- props.bpdLastUpdate,
- () => ,
- () => ,
- _ => ,
- _ => ,
- _ => handleTransactionsStatus(props.transactionForSelectedPeriod),
- _ => ,
- _ => ,
- _ =>
- );
-};
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- loadTransactions: () => dispatch(bpdAllData.request())
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- transactionForSelectedPeriod: bpdDisplayTransactionsSelector(state),
- bpdLastUpdate: bpdLastUpdateSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdTransactionsScreen);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/GoToTransactions.tsx b/ts/features/bonus/bpd/screens/details/transaction/GoToTransactions.tsx
deleted file mode 100644
index 3eb39bf2c62..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/GoToTransactions.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import * as React from "react";
-import { getBottomSpace, isIphoneX } from "react-native-iphone-x-helper";
-import DeviceInfo from "react-native-device-info";
-import { Icon, HSpacer } from "@pagopa/io-app-design-system";
-import ButtonDefaultOpacity from "../../../../../../components/ButtonDefaultOpacity";
-import { Label } from "../../../../../../components/core/typography/Label";
-import I18n from "../../../../../../i18n";
-
-type Props = { goToTransactions: () => void };
-
-/**
- * Display the transactions button when:
- * - Period is closed and transactions number is > 0
- * - Period is active
- * never displays for inactive/incoming period
- * @param props
- * @constructor
- */
-const GoToTransactions: React.FunctionComponent = props => (
-
-
-
-
-
-);
-
-export default GoToTransactions;
diff --git a/ts/features/bonus/bpd/screens/details/transaction/LoadTransactions.tsx b/ts/features/bonus/bpd/screens/details/transaction/LoadTransactions.tsx
deleted file mode 100644
index 1fbadfad0a6..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/LoadTransactions.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import * as React from "react";
-import { View, ActivityIndicator } from "react-native";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { InfoScreenComponent } from "../../../../../../components/infoScreen/InfoScreenComponent";
-import I18n from "../../../../../../i18n";
-
-/**
- * This screen is displayed when loading the list of transactions
- * @constructor
- */
-const LoadTransactions: React.FunctionComponent = () => (
-
-
- }
- title={I18n.t("bonus.bpd.details.transaction.loading")}
- />
-
-);
-
-export default LoadTransactions;
diff --git a/ts/features/bonus/bpd/screens/details/transaction/TransactionsUnavailable.tsx b/ts/features/bonus/bpd/screens/details/transaction/TransactionsUnavailable.tsx
deleted file mode 100644
index 6b4a36ee800..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/TransactionsUnavailable.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as React from "react";
-import { SafeAreaView } from "react-native";
-import image from "../../../../../../../img/wallet/errors/payment-unavailable-icon.png";
-import { IOStyles } from "../../../../../../components/core/variables/IOStyles";
-import { renderInfoRasterImage } from "../../../../../../components/infoScreen/imageRendering";
-import { InfoScreenComponent } from "../../../../../../components/infoScreen/InfoScreenComponent";
-import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent";
-import I18n from "../../../../../../i18n";
-
-export type Props = Pick<
- React.ComponentProps,
- "contextualHelp"
->;
-
-const loadLocales = () => ({
- headerTitle: I18n.t("bonus.bpd.details.transaction.goToButton"),
- title: I18n.t("bonus.bpd.details.transaction.error.title"),
- body: I18n.t("bonus.bpd.details.transaction.error.body")
-});
-
-/**
- * This screen informs the user that there are problems retrieving the transactions list.
- * @deprecated
- * @constructor
- */
-const TransactionsUnavailable: React.FunctionComponent = props => {
- const { headerTitle, title, body } = loadLocales();
-
- return (
-
-
-
-
-
- );
-};
-
-export default TransactionsUnavailable;
diff --git a/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionDetailComponent.tsx b/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionDetailComponent.tsx
deleted file mode 100644
index 36da07696bc..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionDetailComponent.tsx
+++ /dev/null
@@ -1,183 +0,0 @@
-import * as React from "react";
-import { View, Image, StyleSheet } from "react-native";
-import { HSpacer, VSpacer } from "@pagopa/io-app-design-system";
-import CopyButtonComponent from "../../../../../../../components/CopyButtonComponent";
-import { IOBadge } from "../../../../../../../components/core/IOBadge";
-import { Body } from "../../../../../../../components/core/typography/Body";
-import { H4 } from "../../../../../../../components/core/typography/H4";
-import { H5 } from "../../../../../../../components/core/typography/H5";
-import { Monospace } from "../../../../../../../components/core/typography/Monospace";
-import { IOStyles } from "../../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../../i18n";
-import { localeDateFormat } from "../../../../../../../utils/locale";
-import { formatNumberAmount } from "../../../../../../../utils/stringBuilder";
-import { EnhancedBpdTransaction } from "../../../../components/transactionItem/BpdTransactionItem";
-import { BpdTransactionWarning } from "./BpdTransactionWarning";
-
-/**
- * @deprecated
- */
-export type BpdTransactionDetailRepresentation = EnhancedBpdTransaction & {
- // false if the transaction is not valid for the cashback (eg: the user has
- // already reached the maximum cashback value for the period )
- validForCashback: boolean;
-};
-
-export type BpdTransactionDetailRepresentationV2 =
- BpdTransactionDetailRepresentation & {
- isPivot: boolean;
- };
-
-type Props = { transaction: BpdTransactionDetailRepresentation };
-
-const styles = StyleSheet.create({
- image: { width: 48, height: 30 },
- rowId: {
- flexDirection: "row",
- justifyContent: "space-between"
- },
- copyText: {
- flex: 1,
- paddingRight: 16
- }
-});
-
-const loadLocales = () => ({
- paymentMethod: I18n.t("wallet.paymentMethod"),
- acquirerId: I18n.t("bonus.bpd.details.transaction.detail.acquirerId"),
- issuerId: I18n.t("bonus.bpd.details.transaction.detail.issuerId")
-});
-
-type IdBlockProps = {
- title: string;
- value: string;
-};
-
-const CancelBadge = () => (
-
-);
-
-const Table = (props: Props) => {
- const isMidNight =
- props.transaction.trxDate.getHours() +
- props.transaction.trxDate.getMinutes() +
- props.transaction.trxDate.getSeconds() ===
- 0;
- return (
-
-
-
- {isMidNight
- ? I18n.t("payment.details.info.onlyDate")
- : I18n.t("payment.details.info.dateAndTime")}
-
-
- {isMidNight
- ? localeDateFormat(
- props.transaction.trxDate,
- I18n.t(
- "global.dateFormats.fullFormatShortMonthLiteralWithoutTime"
- )
- )
- : localeDateFormat(
- props.transaction.trxDate,
- I18n.t("global.dateFormats.fullFormatShortMonthLiteralWithTime")
- )}
-
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.paymentCircuit")}
-
-
- {props.transaction.circuitType === "Unknown"
- ? I18n.t("global.unknown")
- : props.transaction.circuitType}
-
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.transactionAmount")}
-
-
- {props.transaction.amount < 0 && (
- <>
-
-
- >
- )}
-
- {formatNumberAmount(props.transaction.amount, true)}
-
-
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.detail.cashbackAmount")}
-
-
- {formatNumberAmount(props.transaction.cashback, true)}
-
-
-
- );
-};
-
-const IdBlock = (props: IdBlockProps) => (
-
- {props.title}
-
-
- {props.value}
-
-
-
-
-);
-
-/**
- * This screen shows the details about a single transaction.
- * https://pagopa.invisionapp.com/console/IO---Cashback---Dettaglio-e-transazioni-ckg6bcpcr0ryb016nas1h4nbf/ckg6cwqfc03uf012khxbr6mun/play
- * @param props
- * @constructor
- */
-export const BpdTransactionDetailComponent: React.FunctionComponent<
- Props
-> = props => {
- const { paymentMethod, acquirerId, issuerId } = loadLocales();
-
- return (
-
-
- {paymentMethod}
-
-
-
-
- {props.transaction.title}
-
-
- {/* using the keyvaluetable with custom style in order to be quick */}
-
-
-
-
-
-
-
- );
-};
diff --git a/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionWarning.tsx b/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionWarning.tsx
deleted file mode 100644
index f966dafe117..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/detail/BpdTransactionWarning.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { InfoBox } from "../../../../../../../components/box/InfoBox";
-import { Body } from "../../../../../../../components/core/typography/Body";
-import I18n from "../../../../../../../i18n";
-import { BpdTransactionDetailRepresentation } from "./BpdTransactionDetailComponent";
-
-type Props = { transaction: BpdTransactionDetailRepresentation };
-
-const TransactionWarning = (props: { text: string }) => (
- <>
-
-
- {props.text}
-
- >
-);
-
-/**
- * Displays a warning when certain conditions occur
- * @param props
- * @constructor
- */
-export const BpdTransactionWarning: React.FunctionComponent = props => {
- // transaction not valid for cashback (eg: the user has already reached
- // the maximum cashback value for the period
- if (!props.transaction.validForCashback) {
- return (
-
- );
- }
- // max cashback for a single transaction reached
- if (
- props.transaction.maxCashbackForTransactionAmount ===
- props.transaction.cashback
- ) {
- return (
-
- );
- }
- // transaction canceled (negative amount)
- if (props.transaction.cashback < 0) {
- return (
-
- );
- }
- return null;
-};
diff --git a/ts/features/bonus/bpd/screens/details/transaction/detail/__test__/BdpTransactionDetailComponent.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/detail/__test__/BdpTransactionDetailComponent.test.tsx
deleted file mode 100644
index 2b26abeebc5..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/detail/__test__/BdpTransactionDetailComponent.test.tsx
+++ /dev/null
@@ -1,263 +0,0 @@
-// import { debug } from "console";
-import { render } from "@testing-library/react-native";
-import * as React from "react";
-import I18n from "../../../../../../../../i18n";
-import { HPan } from "../../../../../store/actions/paymentMethods";
-import { AwardPeriodId } from "../../../../../store/actions/periods";
-import {
- BpdTransactionDetailComponent,
- BpdTransactionDetailRepresentation
-} from "../BpdTransactionDetailComponent";
-
-const baseTransaction: BpdTransactionDetailRepresentation = {
- hashPan:
- "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan,
- idTrxAcquirer: "10126487773E",
- idTrxIssuer: "R64692",
- amount: 87.79,
- awardPeriodId: 2 as AwardPeriodId,
- image: 29,
- maxCashbackForTransactionAmount: 15,
- title: "xxxxxxx",
- trxDate: new Date("2100-12-17T00:00"),
- keyId: "xxxxxxxxx",
- cashback: 8.779,
- circuitType: "Mastercard / Maestro",
- validForCashback: true
-};
-
-describe("Test Transaction Timestamp", () => {
- it("It should render label 'Date' and a value without hours and minutes when the transaction has a timestamp 00:00", () => {
- const myTransaction: BpdTransactionDetailRepresentation = {
- hashPan:
- "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan,
- idTrxAcquirer: "10126487773E",
- idTrxIssuer: "R64692",
- amount: 87.79,
- awardPeriodId: 2 as AwardPeriodId,
- image: 29,
- maxCashbackForTransactionAmount: 15,
- title: "xxxxxxx",
- trxDate: new Date("2100-12-17T00:00"),
- keyId: "xxxxxxxxx",
- cashback: 8.779,
- circuitType: "Mastercard / Maestro",
- validForCashback: true
- };
-
- // cut : Component Under Test
- const cut = render(
-
- );
-
- const dateLabel = cut.getByTestId("dateLabel");
- const dateValue = cut.getByTestId("dateValue");
-
- expect(dateLabel.children[0]).toMatch(/Date/);
- expect(dateValue.children[0]).toMatch(/17 Dec 2100/);
- });
-
- it("It should render label 'Date and time' and a value with hours and minutes when the transaction has a timestamp different from 00:00 ", () => {
- const myTransaction: BpdTransactionDetailRepresentation = {
- hashPan:
- "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan,
- idTrxAcquirer: "10126487773E",
- idTrxIssuer: "R64692",
- amount: 87.79,
- awardPeriodId: 2 as AwardPeriodId,
- image: 29,
- maxCashbackForTransactionAmount: 0,
- title: "xxxxxxx",
- trxDate: new Date("2100-12-17T01:00"),
- keyId: "xxxxxxxxx",
- cashback: 8.779,
- circuitType: "Mastercard / Maestro",
- validForCashback: true
- };
-
- // cut : Component Under Test
- const cut = render(
-
- );
- const dateLabel = cut.getByTestId("dateLabel");
- const dateValue = cut.getByTestId("dateValue");
-
- expect(dateLabel.children[0]).toMatch(/Date and time/);
- expect(dateValue.children[0]).toMatch(/17 Dec 2100, 01:00/);
- });
-});
-
-describe("Test BpdTransactionDetailComponent warnings", () => {
- describe("It should render warning 'max cashback for transaction' when maxCashbackForTransactionAmount === cashback", () => {
- const maxAmount = 15.01;
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: maxAmount,
- maxCashbackForTransactionAmount: maxAmount,
- validForCashback: true
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t("bonus.bpd.details.transaction.detail.maxCashbackWarning", {
- amount: maxAmount
- })
- );
- expect(warningTest).not.toBeNull();
- });
- });
-
- describe("It shouldn't render warning 'max cashback for transaction' when maxCashbackForTransactionAmount !== cashback", () => {
- const maxAmount = 15.01;
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: maxAmount,
- maxCashbackForTransactionAmount: maxAmount - 0.01,
- validForCashback: true
- },
- {
- ...baseTransaction,
- cashback: maxAmount,
- maxCashbackForTransactionAmount: 0,
- validForCashback: false
- },
- {
- ...baseTransaction,
- cashback: maxAmount,
- maxCashbackForTransactionAmount: maxAmount,
- validForCashback: false
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t("bonus.bpd.details.transaction.detail.maxCashbackWarning", {
- amount: maxAmount
- })
- );
- expect(warningTest).toBeNull();
- });
- });
-
- describe("It should render warning 'canceledOperationWarning' when cashback value < 0", () => {
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: -0.01,
- validForCashback: true
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t("bonus.bpd.details.transaction.detail.canceledOperationWarning")
- );
- expect(warningTest).not.toBeNull();
- });
- });
- describe("It shouldn't render warning 'canceledOperationWarning' when cashback value >= 0", () => {
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: 0,
- validForCashback: true
- },
- {
- ...baseTransaction,
- cashback: 5,
- validForCashback: false
- },
- {
- ...baseTransaction,
- cashback: -5,
- validForCashback: false
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t("bonus.bpd.details.transaction.detail.canceledOperationWarning")
- );
- expect(warningTest).toBeNull();
- });
- });
- describe("It should render warning 'maxCashbackForPeriodWarning' when validForCashback === false", () => {
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: 0,
- validForCashback: false
- },
- {
- ...baseTransaction,
- cashback: 10.5,
- validForCashback: false
- },
- {
- ...baseTransaction,
- cashback: -10.5,
- validForCashback: false
- },
- {
- ...baseTransaction,
- cashback: 15,
- maxCashbackForTransactionAmount: 15,
- validForCashback: false
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t(
- "bonus.bpd.details.transaction.detail.maxCashbackForPeriodWarning"
- )
- );
- expect(warningTest).not.toBeNull();
- });
- });
- describe("It shouldn't render warning 'maxCashbackForPeriodWarning'", () => {
- const testCases: ReadonlyArray = [
- {
- ...baseTransaction,
- cashback: 0,
- validForCashback: true
- }
- ];
-
- test.each(testCases)("Test case: %p", transaction => {
- const component = render(
-
- );
-
- const warningTest = component.queryByText(
- I18n.t(
- "bonus.bpd.details.transaction.detail.maxCashbackForPeriodWarning"
- )
- );
- expect(warningTest).toBeNull();
- });
- });
-});
diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/BpdAvailableTransactionsScreenV2.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/BpdAvailableTransactionsScreenV2.tsx
deleted file mode 100644
index e0f64466103..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/v2/BpdAvailableTransactionsScreenV2.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { View, SafeAreaView } from "react-native";
-import * as React from "react";
-import { VSpacer } from "@pagopa/io-app-design-system";
-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 { emptyContextualHelp } from "../../../../../../../utils/emptyContextualHelp";
-import TransactionsSectionList from "./TransactionsSectionList";
-
-export const BpdAvailableTransactionsScreenV2 = (): React.ReactElement => (
-
-
-
-
- {I18n.t("bonus.bpd.details.transaction.title")}
-
-
-
-
-);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/BpdTransactionsRouterScreen.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/BpdTransactionsRouterScreen.tsx
deleted file mode 100644
index 3ca6f6db0c3..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/v2/BpdTransactionsRouterScreen.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import * as React from "react";
-import { useEffect, useState } from "react";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import WorkunitGenericFailure from "../../../../../../../components/error/WorkunitGenericFailure";
-import { mixpanelTrack } from "../../../../../../../mixpanel";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { AwardPeriodId } from "../../../../store/actions/periods";
-import { bpdTransactionsLoadRequiredData } from "../../../../store/actions/transactions";
-import { bpdSelectedPeriodSelector } from "../../../../store/reducers/details/selectedPeriod";
-import { bpdTransactionsRequiredDataLoadStateSelector } from "../../../../store/reducers/details/transactionsv2/ui";
-import LoadTransactions from "../LoadTransactions";
-import { BpdAvailableTransactionsScreenV2 } from "./BpdAvailableTransactionsScreenV2";
-import TransactionsUnavailableV2 from "./TransactionsUnavailableV2";
-
-type Props = ReturnType &
- ReturnType;
-
-/**
- * V2 version of the screen, makes sure that all essential data for viewing transactions is loaded
- * @param props
- * @constructor
- */
-const BpdTransactionsRouterScreen = (
- props: Props
-): React.ReactElement | null => {
- const [firstLoadingRequest, setFirstLoadingRequest] = useState(false);
- const [unexpectedError, setUnexpectedError] = useState(false);
-
- const { selectedPeriod, loadRequiredData } = props;
-
- // Refresh the transactions required data when the screen is open
- useEffect(() => {
- if (selectedPeriod) {
- setFirstLoadingRequest(true);
- loadRequiredData(selectedPeriod.awardPeriodId);
- } else {
- // This should never happens
- setUnexpectedError(true);
- }
- }, [selectedPeriod, loadRequiredData]);
-
- // Handling unexpected error
- if (unexpectedError) {
- void mixpanelTrack("BPD_TRANSACTIONS_SCREEN_UNEXPECTED_ERROR");
- return ;
- }
-
- // We want to be sure that before rendering the pot state, a first load request has been sent
- if (!firstLoadingRequest) {
- return ;
- }
-
- return pot.fold(
- props.transactionsRequiredData,
- () => ,
- () => ,
- _ => ,
- _ => ,
- _ => ,
- _ => ,
- (_, __) => ,
- _ =>
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- loadRequiredData: (periodId: AwardPeriodId) =>
- dispatch(bpdTransactionsLoadRequiredData.request(periodId))
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- transactionsRequiredData: bpdTransactionsRequiredDataLoadStateSelector(state),
- selectedPeriod: bpdSelectedPeriodSelector(state)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(BpdTransactionsRouterScreen);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsSectionList.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsSectionList.tsx
deleted file mode 100644
index 24e49a64579..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsSectionList.tsx
+++ /dev/null
@@ -1,251 +0,0 @@
-import * as pot from "@pagopa/ts-commons/lib/pot";
-import { pipe } from "fp-ts/lib/function";
-import * as O from "fp-ts/lib/Option";
-import * as React from "react";
-import { useEffect } from "react";
-import {
- View,
- ActivityIndicator,
- SectionList,
- SectionListData,
- SectionListRenderItemInfo
-} from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import { IOStyles } from "../../../../../../../components/core/variables/IOStyles";
-import I18n from "../../../../../../../i18n";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import { localeDateFormat } from "../../../../../../../utils/locale";
-import { showToast } from "../../../../../../../utils/showToast";
-import BaseDailyTransactionHeader from "../../../../components/BaseDailyTransactionHeader";
-import BpdTransactionSummaryComponent from "../../../../components/BpdTransactionSummaryComponent";
-import { BpdTransactionItem } from "../../../../components/transactionItem/BpdTransactionItem";
-import { AwardPeriodId } from "../../../../store/actions/periods";
-import {
- BpdTransactionId,
- bpdTransactionsLoadPage
-} from "../../../../store/actions/transactions";
-import {
- atLeastOnePaymentMethodHasBpdEnabledSelector,
- paymentMethodsWithActivationStatusSelector
-} from "../../../../store/reducers/details/combiner";
-import { bpdLastUpdateSelector } from "../../../../store/reducers/details/lastUpdate";
-import { bpdSelectedPeriodSelector } from "../../../../store/reducers/details/selectedPeriod";
-import { bpdDaysInfoByIdSelector } from "../../../../store/reducers/details/transactionsv2/daysInfo";
-import {
- bpdTransactionByIdSelector,
- bpdTransactionsGetNextCursor,
- BpdTransactionsSectionItem,
- bpdTransactionsSelector
-} from "../../../../store/reducers/details/transactionsv2/ui";
-import { NoPaymentMethodAreActiveWarning } from "../BpdAvailableTransactionsScreen";
-import BpdCashbackMilestoneComponent from "../BpdCashbackMilestoneComponent";
-import BpdEmptyTransactionsList from "../BpdEmptyTransactionsList";
-
-type Props = ReturnType &
- ReturnType;
-
-type HeaderProps = Props & {
- info: {
- section: SectionListData;
- };
-};
-
-const RenderSectionHeaderBase = (
- // we need to pass props as argument because with the current react-redux version useSelect cannot be used
- props: HeaderProps
-) =>
- pipe(
- props.bpdDaysInfoByIdSelector(props.info.section.dayInfoId),
- O.fold(
- () => null,
- daysInfo => (
-
- )
- )
- );
-
-/**
- * In order to optimize the rendering of the item, we use the dayInfo as unique identifier to avoid to redraw the component.
- * The dayInfo data cannot change while consulting the list and we use this information to avoid a deep comparison
- */
-export const RenderSectionHeader = React.memo(
- RenderSectionHeaderBase,
- (prev: HeaderProps, curr: HeaderProps) =>
- prev.info.section.dayInfoId === curr.info.section.dayInfoId
-);
-
-type ItemProps = Props & {
- trxId: SectionListRenderItemInfo;
-};
-
-const RenderItemBase = (
- // we need to pass props as argument because with the current react-redux version useSelect cannot be used
- props: ItemProps
-): React.ReactElement | null =>
- pipe(
- props.bpdTransactionByIdSelector(props.trxId.item),
- O.fold(
- () => null,
- trx => (
- <>
- {trx.isPivot && (
- 0,
- p => p.maxPeriodCashback
- )
- )}
- />
- )}
-
- >
- )
- )
- );
-
-/**
- * In order to optimize the rendering of the item, we use the keyId as unique identifier to avoid to redraw the component.
- * The trx data cannot change while consulting the list and we use this information to avoid a deep comparison
- */
-export const RenderItem = React.memo(
- RenderItemBase,
- (prev: ItemProps, curr: ItemProps) => prev.trxId.item === curr.trxId.item
-);
-
-/**
- * The header of the transactions list
- * @param props
- * @constructor
- */
-const TransactionsHeader = (
- props: Pick
-) => (
-
-
- {props.selectedPeriod &&
- pot.isSome(props.maybeLastUpdateDate) &&
- props.selectedPeriod.amount.transactionNumber > 0 && (
- <>
-
-
- >
- )}
-
-);
-
-/**
- * This component is rendered when no transactions are available
- * @param props
- * @constructor
- */
-const TransactionsEmpty = (
- props: Pick
-) => (
-
- {!props.atLeastOnePaymentMethodActive &&
- pot.isSome(props.potWallets) &&
- props.potWallets.value.length > 0 ? (
-
- ) : (
-
- )}
-
-);
-
-/**
- * Loading item, placed in the footer during the loading of the next page
- * @constructor
- */
-const FooterLoading = () => (
- <>
-
-
- >
-);
-
-const TransactionsSectionList = (props: Props): React.ReactElement => {
- const isError = pot.isError(props.potTransactions);
- const isLoading = pot.isLoading(props.potTransactions);
- const transactions = pot.getOrElse(props.potTransactions, []);
-
- useEffect(() => {
- if (isError) {
- showToast(
- I18n.t("bonus.bpd.details.transaction.error.pageLoading"),
- "danger"
- );
- }
- }, [isError]);
-
- return (
- (
-
- )}
- ListHeaderComponent={}
- ListEmptyComponent={}
- ListFooterComponent={isLoading && }
- onEndReached={() => {
- if (props.selectedPeriod && props.nextCursor && !isLoading) {
- props.loadNextPage(
- props.selectedPeriod.awardPeriodId,
- props.nextCursor
- );
- }
- }}
- scrollEnabled={true}
- stickySectionHeadersEnabled={true}
- sections={transactions}
- renderItem={ri => }
- keyExtractor={t => t}
- />
- );
-};
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
- loadNextPage: (awardPeriodId: AwardPeriodId, nextCursor: number) =>
- dispatch(bpdTransactionsLoadPage.request({ awardPeriodId, nextCursor }))
-});
-
-const mapStateToProps = (state: GlobalState) => ({
- selectedPeriod: bpdSelectedPeriodSelector(state),
- maybeLastUpdateDate: bpdLastUpdateSelector(state),
- potWallets: paymentMethodsWithActivationStatusSelector(state),
- atLeastOnePaymentMethodActive:
- atLeastOnePaymentMethodHasBpdEnabledSelector(state),
- potTransactions: bpdTransactionsSelector(state),
- nextCursor: bpdTransactionsGetNextCursor(state),
- bpdTransactionByIdSelector: (trxId: BpdTransactionId) =>
- bpdTransactionByIdSelector(state, trxId),
- bpdDaysInfoByIdSelector: (id: string) => bpdDaysInfoByIdSelector(state, id)
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(TransactionsSectionList);
diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsUnavailableV2.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsUnavailableV2.tsx
deleted file mode 100644
index 3bb18877df4..00000000000
--- a/ts/features/bonus/bpd/screens/details/transaction/v2/TransactionsUnavailableV2.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import * as React from "react";
-import { SafeAreaView } from "react-native";
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import image from "../../../../../../../../img/wallet/errors/payment-unavailable-icon.png";
-import { IOStyles } from "../../../../../../../components/core/variables/IOStyles";
-import { renderInfoRasterImage } from "../../../../../../../components/infoScreen/imageRendering";
-import { InfoScreenComponent } from "../../../../../../../components/infoScreen/InfoScreenComponent";
-import BaseScreenComponent from "../../../../../../../components/screens/BaseScreenComponent";
-import FooterWithButtons from "../../../../../../../components/ui/FooterWithButtons";
-import I18n from "../../../../../../../i18n";
-import { navigateBack } from "../../../../../../../store/actions/navigation";
-import { GlobalState } from "../../../../../../../store/reducers/types";
-import {
- cancelButtonProps,
- confirmButtonProps
-} from "../../../../../../../components/buttons/ButtonConfigurations";
-import { AwardPeriodId } from "../../../../store/actions/periods";
-import { bpdTransactionsLoadRequiredData } from "../../../../store/actions/transactions";
-import { bpdSelectedPeriodSelector } from "../../../../store/reducers/details/selectedPeriod";
-
-export type Props = Pick<
- React.ComponentProps,
- "contextualHelp"
-> &
- ReturnType &
- ReturnType