diff --git a/ts/features/walletV3/analytics/store/actions/index.ts b/ts/features/walletV3/analytics/store/actions/index.ts index cd521bd2035..dcf32b447a9 100644 --- a/ts/features/walletV3/analytics/store/actions/index.ts +++ b/ts/features/walletV3/analytics/store/actions/index.ts @@ -1,14 +1,14 @@ import { ActionType, createStandardAction } from "typesafe-actions"; import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId"; -export const walletAnalyticsStorePaymentTentative = createStandardAction( - "WALLET_ANALYTICS_STORE_PAYMENT_TENTATIVE" +export const walletAnalyticsStorePaymentAttempt = createStandardAction( + "WALLET_ANALYTICS_STORE_PAYMENT_ATTEMPT" )(); -export const walletAnalyticsResetPaymentTentative = createStandardAction( - "WALLET_ANALYTICS_RESET_PAYMENT_TENTATIVE" +export const walletAnalyticsResetPaymentAttempt = createStandardAction( + "WALLET_ANALYTICS_RESET_PAYMENT_ATTEMPT" )(); export type WalletAnalyticsActions = - | ActionType - | ActionType; + | ActionType + | ActionType; diff --git a/ts/features/walletV3/analytics/store/reducers/index.ts b/ts/features/walletV3/analytics/store/reducers/index.ts index 26a22e825c4..de079f3843d 100644 --- a/ts/features/walletV3/analytics/store/reducers/index.ts +++ b/ts/features/walletV3/analytics/store/reducers/index.ts @@ -4,16 +4,16 @@ import { getType } from "typesafe-actions"; import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId"; import { Action } from "../../../../../store/actions/types"; import { - walletAnalyticsStorePaymentTentative, - walletAnalyticsResetPaymentTentative + walletAnalyticsStorePaymentAttempt, + walletAnalyticsResetPaymentAttempt } from "../actions"; export type WalletAnalyticsState = { - paymentTentativeByRptId: Record; + paymentAttemptsByRptId: Record; }; const INITIAL_STATE: WalletAnalyticsState = { - paymentTentativeByRptId: {} + paymentAttemptsByRptId: {} }; // eslint-disable-next-line complexity @@ -24,24 +24,22 @@ const reducer = ( ): WalletAnalyticsState => { switch (action.type) { // Payment tentative - case getType(walletAnalyticsStorePaymentTentative): - const currentTentative = - state.paymentTentativeByRptId[action.payload] || 0; + case getType(walletAnalyticsStorePaymentAttempt): + const currentAttempts = state.paymentAttemptsByRptId[action.payload] || 0; return { ...state, - paymentTentativeByRptId: { - ...state.paymentTentativeByRptId, - [action.payload]: currentTentative + 1 + paymentAttemptsByRptId: { + ...state.paymentAttemptsByRptId, + [action.payload]: currentAttempts + 1 } }; - case getType(walletAnalyticsResetPaymentTentative): - const { [action.payload]: _, ...tentatives } = - state.paymentTentativeByRptId; + case getType(walletAnalyticsResetPaymentAttempt): + const { [action.payload]: _, ...attempts } = state.paymentAttemptsByRptId; return { ...state, - paymentTentativeByRptId: tentatives + paymentAttemptsByRptId: attempts }; } return state; @@ -53,7 +51,7 @@ const persistConfig: PersistConfig = { key: "wallet_analytics", storage: AsyncStorage, version: CURRENT_REDUX_PAYMENT_ANALYTICS_STORE_VERSION, - whitelist: ["paymentTentativeByRptId"] + whitelist: ["paymentAttemptsByRptId"] }; const persistedReducer = persistReducer( diff --git a/ts/features/walletV3/analytics/store/selectors/index.ts b/ts/features/walletV3/analytics/store/selectors/index.ts index 2228aabbd3a..8323d125e1d 100644 --- a/ts/features/walletV3/analytics/store/selectors/index.ts +++ b/ts/features/walletV3/analytics/store/selectors/index.ts @@ -8,18 +8,18 @@ import { walletPaymentDetailsSelector } from "../../../payment/store/selectors"; const selectWalletAnalytics = (state: GlobalState) => state.features.wallet.analytics; -export const walletPaymentTentativeByRptIdSelector = createSelector( +export const walletPaymentAttemptsByRptIdSelector = createSelector( selectWalletAnalytics, - state => state.paymentTentativeByRptId + state => state.paymentAttemptsByRptId ); export const walletPaymentTentativeSelector = createSelector( - [walletPaymentTentativeByRptIdSelector, walletPaymentDetailsSelector], - (tentativeByRptId, paymentDetailsPot) => + [walletPaymentAttemptsByRptIdSelector, walletPaymentDetailsSelector], + (attemptsByRptId, paymentDetailsPot) => pipe( paymentDetailsPot, pot.toOption, - O.map(({ rptId }) => tentativeByRptId[rptId]), + O.map(({ rptId }) => attemptsByRptId[rptId]), O.toUndefined ) ); diff --git a/ts/features/walletV3/payment/hooks/useWalletPaymentAuthorizationModal.tsx b/ts/features/walletV3/payment/hooks/useWalletPaymentAuthorizationModal.tsx index f4218b85eb8..5af0b9d944d 100644 --- a/ts/features/walletV3/payment/hooks/useWalletPaymentAuthorizationModal.tsx +++ b/ts/features/walletV3/payment/hooks/useWalletPaymentAuthorizationModal.tsx @@ -7,7 +7,7 @@ import { pipe } from "fp-ts/lib/function"; import * as React from "react"; import URLParse from "url-parse"; import { useIODispatch, useIOSelector } from "../../../../store/hooks"; -import { walletAnalyticsResetPaymentTentative } from "../../analytics/store/actions"; +import { walletAnalyticsStorePaymentAttempt } from "../../analytics/store/actions"; import { WALLET_WEBVIEW_OUTCOME_SCHEMA } from "../../common/utils/const"; import { WalletPaymentAuthorizePayload, @@ -56,7 +56,7 @@ export const useWalletPaymentAuthorizationModal = ({ paymentDetailsPot, pot.toOption, O.map(({ rptId }) => rptId), - O.map(walletAnalyticsResetPaymentTentative), + O.map(walletAnalyticsStorePaymentAttempt), O.map(dispatch) ); } diff --git a/ts/features/walletV3/payment/screens/WalletPaymentDetailScreen.tsx b/ts/features/walletV3/payment/screens/WalletPaymentDetailScreen.tsx index e01bb9d787a..7a345a57de5 100644 --- a/ts/features/walletV3/payment/screens/WalletPaymentDetailScreen.tsx +++ b/ts/features/walletV3/payment/screens/WalletPaymentDetailScreen.tsx @@ -51,7 +51,7 @@ import { WalletPaymentRoutes } from "../navigation/routes"; import { walletPaymentGetDetails } from "../store/actions/networking"; import { walletPaymentDetailsSelector } from "../store/selectors"; import { WalletPaymentFailure } from "../types/failure"; -import { walletAnalyticsStorePaymentTentative } from "../../analytics/store/actions"; +import { walletAnalyticsStorePaymentAttempt } from "../../analytics/store/actions"; type WalletPaymentDetailScreenNavigationParams = { rptId: RptId; @@ -134,7 +134,7 @@ const WalletPaymentDetailContent = ({ }); const handleGoToPayment = () => { - dispatch(walletAnalyticsStorePaymentTentative(rptId)); + dispatch(walletAnalyticsStorePaymentAttempt(rptId)); navigation.push(WalletPaymentRoutes.WALLET_PAYMENT_MAIN, { screen: WalletPaymentRoutes.WALLET_PAYMENT_PICK_METHOD });