From aea5e74a5f1d8fbb6cf6007c7634ae998a565c7b Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:27:31 +0200 Subject: [PATCH 1/5] refactor(Wallet): remove payments redirect banner --- .../newWallet/screens/WalletHomeScreen.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ts/features/newWallet/screens/WalletHomeScreen.tsx b/ts/features/newWallet/screens/WalletHomeScreen.tsx index 4ef5e75d774..ce393e15546 100644 --- a/ts/features/newWallet/screens/WalletHomeScreen.tsx +++ b/ts/features/newWallet/screens/WalletHomeScreen.tsx @@ -2,6 +2,7 @@ import { IOStyles, IOToast } from "@pagopa/io-app-design-system"; import { useFocusEffect } from "@react-navigation/native"; import React from "react"; import { ScrollView } from "react-native"; +import { IOScrollView } from "../../../components/ui/IOScrollView"; import I18n from "../../../i18n"; import { IOStackNavigationRouteProps, @@ -9,22 +10,20 @@ import { } from "../../../navigation/params/AppParamsList"; import { MainTabParamsList } from "../../../navigation/params/MainTabParamsList"; import { useIODispatch, useIOSelector, useIOStore } from "../../../store/hooks"; +import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender"; import { cgnDetails } from "../../bonus/cgn/store/actions/details"; import { idPayWalletGet } from "../../idpay/wallet/store/actions"; +import { + trackAllCredentialProfileAndSuperProperties, + trackOpenWalletScreen, + trackWalletAdd +} from "../../itwallet/analytics"; import { ITW_ROUTES } from "../../itwallet/navigation/routes"; import { getPaymentsWalletUserMethods } from "../../payments/wallet/store/actions"; import { WalletCardsContainer } from "../components/WalletCardsContainer"; import { WalletCategoryFilterTabs } from "../components/WalletCategoryFilterTabs"; -import { WalletPaymentsRedirectBanner } from "../components/WalletPaymentsRedirectBanner"; import { walletToggleLoadingState } from "../store/actions/placeholders"; import { selectWalletCards } from "../store/selectors"; -import { - trackAllCredentialProfileAndSuperProperties, - trackOpenWalletScreen, - trackWalletAdd -} from "../../itwallet/analytics"; -import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender"; -import { IOScrollView } from "../../../components/ui/IOScrollView"; type Props = IOStackNavigationRouteProps; @@ -63,7 +62,6 @@ const WalletHomeScreen = ({ route }: Props) => { return ( - ); From e781e6d0fdb15a25693335850b537535ed92850e Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:44:24 +0200 Subject: [PATCH 2/5] test: update WalletHomeScreen test suite --- .../newWallet/screens/__tests__/WalletHomeScreen.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx b/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx index 086f5b1b69e..047e80dce4b 100644 --- a/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx +++ b/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx @@ -71,7 +71,7 @@ describe("WalletHomeScreen", () => { jest.runOnlyPendingTimers(); - expect(queryByTestId("walletPaymentsRedirectBannerTestID")).not.toBeNull(); + expect(queryByTestId("walletPaymentsRedirectBannerTestID")).toBeNull(); expect(queryByTestId("walletEmptyScreenContentTestID")).not.toBeNull(); expect(queryByTestId("walletCardsContainerTestID")).toBeNull(); expect(queryByTestId("walletAddCardButtonTestID")).toBeNull(); @@ -93,7 +93,7 @@ describe("WalletHomeScreen", () => { component: { queryByTestId } } = renderComponent(T_CARDS, { shouldShowPaymentsRedirectBanner: true }); - expect(queryByTestId("walletPaymentsRedirectBannerTestID")).not.toBeNull(); + expect(queryByTestId("walletPaymentsRedirectBannerTestID")).toBeNull(); expect(queryByTestId("walletEmptyScreenContentTestID")).toBeNull(); expect(queryByTestId("walletCardsContainerTestID")).not.toBeNull(); expect(queryByTestId("walletAddCardButtonTestID")).not.toBeNull(); From 419778f648a691e8ac0f10a42a70e6534521057d Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:53:30 +0200 Subject: [PATCH 3/5] refactor: remove WalletPaymentsRedirectBanner --- .../WalletPaymentsRedirectBanner.tsx | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 ts/features/newWallet/components/WalletPaymentsRedirectBanner.tsx diff --git a/ts/features/newWallet/components/WalletPaymentsRedirectBanner.tsx b/ts/features/newWallet/components/WalletPaymentsRedirectBanner.tsx deleted file mode 100644 index 97d434d0b8f..00000000000 --- a/ts/features/newWallet/components/WalletPaymentsRedirectBanner.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { Banner, VSpacer } from "@pagopa/io-app-design-system"; -import React from "react"; -import { View } from "react-native"; -import Animated, { Layout } from "react-native-reanimated"; -import I18n from "../../../i18n"; -import { useIONavigation } from "../../../navigation/params/AppParamsList"; -import ROUTES from "../../../navigation/routes"; -import { useIODispatch, useIOSelector } from "../../../store/hooks"; -import { walletSetPaymentsRedirectBannerVisible } from "../store/actions/preferences"; -import { isWalletPaymentsRedirectBannerVisibleSelector } from "../store/selectors"; - -const WalletPaymentsRedirectBanner = () => { - const dispatch = useIODispatch(); - const navigation = useIONavigation(); - const bannerRef = React.createRef(); - - const isVisible = useIOSelector( - isWalletPaymentsRedirectBannerVisibleSelector - ); - - const handleOnBannerPress = () => { - navigation.navigate(ROUTES.MAIN, { - screen: ROUTES.PAYMENTS_HOME - }); - }; - - const handleOnBannerClose = () => { - dispatch(walletSetPaymentsRedirectBannerVisible(false)); - }; - - if (!isVisible) { - return null; - } - - return ( - - - - - - ); -}; - -export { WalletPaymentsRedirectBanner }; From fb26d1a4c06e7746ce2fcfe191f291a9c3b0d869 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:56:52 +0200 Subject: [PATCH 4/5] refactor: remove unused const from store Removed reducers, actions and selectors used to display WalletPaymentsRedirectBanner --- ts/boot/configureStoreAndPersistor.ts | 4 +--- .../newWallet/store/actions/preferences.ts | 10 +++------- .../newWallet/store/reducers/preferences.ts | 18 +++--------------- ts/features/newWallet/store/selectors/index.ts | 4 ---- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/ts/boot/configureStoreAndPersistor.ts b/ts/boot/configureStoreAndPersistor.ts index e8df018d3e1..6f36402e35f 100644 --- a/ts/boot/configureStoreAndPersistor.ts +++ b/ts/boot/configureStoreAndPersistor.ts @@ -377,9 +377,7 @@ const migrations: MigrationManifest = { merge(state, { features: { wallet: { - preferences: { - shouldShowPaymentsRedirectBanner: true - } + preferences: {} } } }), diff --git a/ts/features/newWallet/store/actions/preferences.ts b/ts/features/newWallet/store/actions/preferences.ts index 4270be33359..fbfe75a1e6e 100644 --- a/ts/features/newWallet/store/actions/preferences.ts +++ b/ts/features/newWallet/store/actions/preferences.ts @@ -1,14 +1,10 @@ import { ActionType, createStandardAction } from "typesafe-actions"; import { WalletCardCategoryFilter } from "../../types"; -export const walletSetPaymentsRedirectBannerVisible = createStandardAction( - "WALLET_SET_PAYMENTS_REDIRECT_BANNER_VISIBLE" -)(); - export const walletSetCategoryFilter = createStandardAction( "WALLET_SET_CATEGORY_FILTER" )(); -export type WalletPreferencesActions = - | ActionType - | ActionType; +export type WalletPreferencesActions = ActionType< + typeof walletSetCategoryFilter +>; diff --git a/ts/features/newWallet/store/reducers/preferences.ts b/ts/features/newWallet/store/reducers/preferences.ts index 7aa34eedbc6..49cf5f2c708 100644 --- a/ts/features/newWallet/store/reducers/preferences.ts +++ b/ts/features/newWallet/store/reducers/preferences.ts @@ -2,31 +2,20 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; import { PersistConfig, persistReducer } from "redux-persist"; import { getType } from "typesafe-actions"; import { Action } from "../../../../store/actions/types"; -import { - walletSetCategoryFilter, - walletSetPaymentsRedirectBannerVisible -} from "../actions/preferences"; +import { walletSetCategoryFilter } from "../actions/preferences"; import { WalletCardCategoryFilter } from "../../types"; export type WalletPreferencesState = { - shouldShowPaymentsRedirectBanner: boolean; categoryFilter?: WalletCardCategoryFilter; }; -const INITIAL_STATE: WalletPreferencesState = { - shouldShowPaymentsRedirectBanner: true -}; +const INITIAL_STATE: WalletPreferencesState = {}; const reducer = ( state: WalletPreferencesState = INITIAL_STATE, action: Action ): WalletPreferencesState => { switch (action.type) { - case getType(walletSetPaymentsRedirectBannerVisible): - return { - ...state, - shouldShowPaymentsRedirectBanner: action.payload - }; case getType(walletSetCategoryFilter): return { ...state, @@ -41,8 +30,7 @@ const CURRENT_REDUX_WALLET_PREFERENCES_STORE_VERSION = -1; const persistConfig: PersistConfig = { key: "walletPreferences", storage: AsyncStorage, - version: CURRENT_REDUX_WALLET_PREFERENCES_STORE_VERSION, - whitelist: ["shouldShowPaymentsRedirectBanner"] + version: CURRENT_REDUX_WALLET_PREFERENCES_STORE_VERSION }; export const walletReducerPersistor = persistReducer< diff --git a/ts/features/newWallet/store/selectors/index.ts b/ts/features/newWallet/store/selectors/index.ts index f9ad8312e49..017cc2cebbd 100644 --- a/ts/features/newWallet/store/selectors/index.ts +++ b/ts/features/newWallet/store/selectors/index.ts @@ -2,10 +2,6 @@ import { createSelector } from "reselect"; import { GlobalState } from "../../../../store/reducers/types"; import { WalletCard, walletCardCategories } from "../../types"; -export const isWalletPaymentsRedirectBannerVisibleSelector = ( - state: GlobalState -) => state.features.wallet.preferences.shouldShowPaymentsRedirectBanner; - const selectWalletFeature = (state: GlobalState) => state.features.wallet; export const selectWalletPlaceholders = createSelector( From ee7d8588630f8e12f6f509b84ddf03556f0185e6 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:01:37 +0200 Subject: [PATCH 5/5] test: update WalletHomeScreen test suite Remove unnecessary assertion since shouldShowPaymentsRedirectBanner has been removed --- .../__tests__/WalletHomeScreen.test.tsx | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx b/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx index 047e80dce4b..9ff320e7054 100644 --- a/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx +++ b/ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx @@ -59,24 +59,6 @@ describe("WalletHomeScreen", () => { expect(queryByTestId("walletAddCardButtonTestID")).toBeNull(); }); - it("should correctly render empty screen with redirect banner", () => { - const { - component: { queryByTestId } - } = renderComponent( - {}, - { - shouldShowPaymentsRedirectBanner: true - } - ); - - jest.runOnlyPendingTimers(); - - expect(queryByTestId("walletPaymentsRedirectBannerTestID")).toBeNull(); - expect(queryByTestId("walletEmptyScreenContentTestID")).not.toBeNull(); - expect(queryByTestId("walletCardsContainerTestID")).toBeNull(); - expect(queryByTestId("walletAddCardButtonTestID")).toBeNull(); - }); - it("should correctly render card list screen", () => { const { component: { queryByTestId } @@ -87,29 +69,16 @@ describe("WalletHomeScreen", () => { expect(queryByTestId("walletCardsContainerTestID")).not.toBeNull(); expect(queryByTestId("walletAddCardButtonTestID")).not.toBeNull(); }); - - it("should correctly render card list screen with redirect banner", () => { - const { - component: { queryByTestId } - } = renderComponent(T_CARDS, { shouldShowPaymentsRedirectBanner: true }); - - expect(queryByTestId("walletPaymentsRedirectBannerTestID")).toBeNull(); - expect(queryByTestId("walletEmptyScreenContentTestID")).toBeNull(); - expect(queryByTestId("walletCardsContainerTestID")).not.toBeNull(); - expect(queryByTestId("walletAddCardButtonTestID")).not.toBeNull(); - }); }); const renderComponent = ( cards: WalletCardsState, options: { - shouldShowPaymentsRedirectBanner?: boolean; isLoading?: boolean; } = {} ) => { const globalState = appReducer(undefined, applicationChangeState("active")); - const { shouldShowPaymentsRedirectBanner = false, isLoading = false } = - options; + const { isLoading = false } = options; const mockStore = configureMockStore(); const store: ReturnType = mockStore( @@ -117,9 +86,7 @@ const renderComponent = ( features: { wallet: { cards, - preferences: { - shouldShowPaymentsRedirectBanner - }, + preferences: {}, placeholders: { isLoading }