Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [IOBP-930] Remove payments redirect banner from wallet #6316

Merged
merged 8 commits into from
Oct 22, 2024
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

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
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
Loading