Skip to content

Commit

Permalink
feat: [IOBP-930] Remove payments redirect banner from wallet (#6316)
Browse files Browse the repository at this point in the history
## Short description
This pull request removes the banner that prompts users to go to the
payments section when they want to pay a notice from the wallet screen.

## List of changes proposed in this pull request
- Delete `WalletPaymentsRedirectBanner` component and its redux variable

## How to test
- Navigate to the Portafoglio (Wallet) section.
- Verify that the banner prompting for payment redirection no longer
appears.

---------

Co-authored-by: Alessandro <alessandro.izzo998@gmail.com>
  • Loading branch information
2 people authored and LazyAfternoons committed Oct 23, 2024
1 parent 5af3ad0 commit 5c6bf7c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 128 deletions.
4 changes: 1 addition & 3 deletions ts/boot/configureStoreAndPersistor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,7 @@ const migrations: MigrationManifest = {
merge(state, {
features: {
wallet: {
preferences: {
shouldShowPaymentsRedirectBanner: true
}
preferences: {}
}
}
}),
Expand Down
55 changes: 0 additions & 55 deletions ts/features/newWallet/components/WalletPaymentsRedirectBanner.tsx

This file was deleted.

16 changes: 7 additions & 9 deletions ts/features/newWallet/screens/WalletHomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ 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,
useIONavigation
} 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<MainTabParamsList, "WALLET_HOME">;

Expand Down Expand Up @@ -63,7 +62,6 @@ const WalletHomeScreen = ({ route }: Props) => {
return (
<WalletScrollView>
<WalletCategoryFilterTabs />
<WalletPaymentsRedirectBanner />
<WalletCardsContainer />
</WalletScrollView>
);
Expand Down
37 changes: 2 additions & 35 deletions ts/features/newWallet/screens/__tests__/WalletHomeScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")).not.toBeNull();
expect(queryByTestId("walletEmptyScreenContentTestID")).not.toBeNull();
expect(queryByTestId("walletCardsContainerTestID")).toBeNull();
expect(queryByTestId("walletAddCardButtonTestID")).toBeNull();
});

it("should correctly render card list screen", () => {
const {
component: { queryByTestId }
Expand All @@ -87,39 +69,24 @@ 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")).not.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<GlobalState>();
const store: ReturnType<typeof mockStore> = mockStore(
_.merge(globalState, {
features: {
wallet: {
cards,
preferences: {
shouldShowPaymentsRedirectBanner
},
preferences: {},
placeholders: {
isLoading
}
Expand Down
10 changes: 3 additions & 7 deletions ts/features/newWallet/store/actions/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { ActionType, createStandardAction } from "typesafe-actions";
import { WalletCardCategoryFilter } from "../../types";

export const walletSetPaymentsRedirectBannerVisible = createStandardAction(
"WALLET_SET_PAYMENTS_REDIRECT_BANNER_VISIBLE"
)<boolean>();

export const walletSetCategoryFilter = createStandardAction(
"WALLET_SET_CATEGORY_FILTER"
)<WalletCardCategoryFilter | undefined>();

export type WalletPreferencesActions =
| ActionType<typeof walletSetPaymentsRedirectBannerVisible>
| ActionType<typeof walletSetCategoryFilter>;
export type WalletPreferencesActions = ActionType<
typeof walletSetCategoryFilter
>;
18 changes: 3 additions & 15 deletions ts/features/newWallet/store/reducers/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<
Expand Down
4 changes: 0 additions & 4 deletions ts/features/newWallet/store/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5c6bf7c

Please sign in to comment.