Skip to content

Commit

Permalink
fix(IT Wallet): [SIW-570] Blocking error screen in wallet home screen (
Browse files Browse the repository at this point in the history
…#5259)

## Short description
This PR fixes a blocking error screen in the wallet home screen.
It's shown when the decode of the PID fails. That's not supposed to
happen but sometimes it does due to dirty state which we are currently
not migrating.

## List of changes proposed in this pull request
- Replaces the old error view with a new one which has a reset button
and doesn't block the wallet usage.

## How to test
Static checks should be enough.

Co-authored-by: Mario Perrotta <mario.perrotta@pagopa.it>
  • Loading branch information
LazyAfternoons and hevelius committed Nov 29, 2023
1 parent b732ece commit 77584d8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions ts/features/it-wallet/screens/ItwHomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import { useItwResetFlow } from "../hooks/useItwResetFlow";
import ItwCredentialCard from "../components/ItwCredentialCard";
import { CredentialType, getPidDisplayData } from "../utils/mocks";
import ItwKoView from "../components/ItwKoView";
import { getItwGenericMappedError } from "../utils/errors/itwErrorsMapping";
import { ItWalletError } from "../utils/errors/itwErrors";

const contextualHelpMarkdown: ContextualHelpPropsMarkdown = {
title: "wallet.contextualHelpTitle",
Expand Down Expand Up @@ -168,20 +166,23 @@ const ItwHomeScreen = () => {
</View>
);

/**
* Error view component which currently displays a generic error.
* @param error - optional ItWalletError to be displayed.
*/
const ErrorView = ({ error: _ }: { error?: ItWalletError }) => {
const mappedError = getItwGenericMappedError(() => navigation.goBack());
return <ItwKoView {...mappedError} />;
};

const RenderMask = () =>
pipe(
decodedPid,
O.fold(
() => <ErrorView />,
() => (
<ItwKoView
title={I18n.t("global.jserror.title")}
pictogram="fatalError"
action={{
accessibilityLabel: I18n.t(
"features.itWallet.homeScreen.reset.label"
),
label: I18n.t("features.itWallet.homeScreen.reset.label"),
onPress: () => present()
}}
/>
),
some => <ContentView decodedPid={some} />
)
);
Expand Down

0 comments on commit 77584d8

Please sign in to comment.