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

fix: [IOBP-512] Wallet details with new generic error screen #5427

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,11 @@ wallet:
title: Vuoi pagare in app?
content: Scopri quali sono i metodi che puoi aggiungere al tuo portafoglio.
cta: Scopri di più
error:
title: Si è verificato un errore
subtitle: Riprova o contatta l'assistenza
primaryButton: Chiudi
secondaryButton: Riprova
wallet: Wallet
refreshWallet: Refresh the Wallet
favourite:
Expand Down
5 changes: 5 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,11 @@ wallet:
title: Vuoi pagare in app?
content: Scopri quali sono i metodi che puoi aggiungere al tuo portafoglio.
cta: Scopri di più
error:
title: Si è verificato un errore
subtitle: Riprova o contatta l'assistenza
primaryButton: Chiudi
secondaryButton: Riprova
wallet: Portafoglio
refreshWallet: Aggiorna il Portafoglio
favourite:
Expand Down
36 changes: 33 additions & 3 deletions ts/features/walletV3/details/screens/WalletDetailsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from "react";
import { RouteProp, useRoute } from "@react-navigation/native";
import { RouteProp, useNavigation, useRoute } from "@react-navigation/native";
import { useDispatch } from "react-redux";
import { IOLogoPaymentExtType } from "@pagopa/io-app-design-system";

import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import LoadingSpinnerOverlay from "../../../../components/LoadingSpinnerOverlay";
import WorkunitGenericFailure from "../../../../components/error/WorkunitGenericFailure";
import { PaymentCardBig } from "../../../../components/ui/cards/payment/PaymentCardBig";
import { useIOSelector } from "../../../../store/hooks";
import { idPayAreInitiativesFromInstrumentLoadingSelector } from "../../../idpay/wallet/store/reducers";
Expand All @@ -22,6 +21,12 @@ import {
import { walletDetailsGetInstrument } from "../store/actions";
import { UIWalletInfoDetails } from "../types/UIWalletInfoDetails";
import { getDateFromExpiryDate } from "../../../../utils/dates";
import { OperationResultScreenContent } from "../../../../components/screens/OperationResultScreenContent";
import I18n from "../../../../i18n";
import {
AppParamsList,
IOStackNavigationProp
} from "../../../../navigation/params/AppParamsList";

export type WalletDetailsScreenNavigationParams = Readonly<{
walletId: string;
Expand Down Expand Up @@ -71,6 +76,7 @@ const generateCardHeaderTitle = (details?: UIWalletInfoDetails) => {
*/
const WalletDetailsScreen = () => {
const route = useRoute<WalletDetailsScreenRouteProps>();
const navigation = useNavigation<IOStackNavigationProp<AppParamsList>>();
const dispatch = useDispatch();
const { walletId } = route.params;
const walletDetails = useIOSelector(walletDetailsInstrumentSelector);
Expand All @@ -82,6 +88,30 @@ const WalletDetailsScreen = () => {
idPayAreInitiativesFromInstrumentLoadingSelector
);

const WalletDetailsGenericFailure = () => (
<OperationResultScreenContent
title={I18n.t("wallet.methodDetails.error.title")}
subtitle={I18n.t("wallet.methodDetails.error.subtitle")}
pictogram="umbrellaNew"
action={{
label: I18n.t("wallet.methodDetails.error.primaryButton"),
accessibilityLabel: I18n.t("wallet.methodDetails.error.primaryButton"),
onPress: () => navigation.pop()
}}
secondaryAction={{
label: I18n.t("wallet.methodDetails.error.secondaryButton"),
accessibilityLabel: I18n.t(
"wallet.methodDetails.error.secondaryButton"
),
onPress: handleOnRetry
}}
/>
);

const handleOnRetry = () => {
dispatch(walletDetailsGetInstrument.request({ walletId }));
};

React.useEffect(() => {
dispatch(walletDetailsGetInstrument.request({ walletId }));
}, [walletId, dispatch]);
Expand Down Expand Up @@ -122,7 +152,7 @@ const WalletDetailsScreen = () => {
</LoadingSpinnerOverlay>
);
} else if (isErrorWalletDetails) {
return <WorkunitGenericFailure />;
return <WalletDetailsGenericFailure />;
}
return null;
};
Expand Down
Loading