From e6df0f84edca196c5b4e3306122e4f669781244f Mon Sep 17 00:00:00 2001 From: Alessandro Mazzon Date: Thu, 21 Nov 2024 16:45:09 +0100 Subject: [PATCH] fix(IT Wallet): [SIW-1867] Unsupported device cta onpress action (#6437) ## Short description This pull request focuses on enhancing the error handling and user experience in the `ItwIssuanceEidFailureScreen` component by making use of the `IOToast` component and a utility function for opening URLs. ## List of changes proposed in this pull request * Replaced the `Linking.openURL` function with the `openWebUrl` utility function, which includes a callback to display an error toast using `IOToast` if the URL fails to open. ## How to test Navigate inside the `ItwIssuanceEidFailureScreen` simulating an error and test the CTA. --- .../issuance/screens/ItwIssuanceEidFailureScreen.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/features/itwallet/issuance/screens/ItwIssuanceEidFailureScreen.tsx b/ts/features/itwallet/issuance/screens/ItwIssuanceEidFailureScreen.tsx index 36f77b804db..aa9ca1a57d2 100644 --- a/ts/features/itwallet/issuance/screens/ItwIssuanceEidFailureScreen.tsx +++ b/ts/features/itwallet/issuance/screens/ItwIssuanceEidFailureScreen.tsx @@ -1,7 +1,7 @@ import * as O from "fp-ts/lib/Option"; import { constNull, pipe } from "fp-ts/lib/function"; import React, { useEffect } from "react"; -import { Linking } from "react-native"; +import { useIOToast } from "@pagopa/io-app-design-system"; import { OperationResultScreenContent, OperationResultScreenContentProps @@ -27,6 +27,7 @@ import { trackItwUnsupportedDevice, trackWalletCreationFailed } from "../../analytics"; +import { openWebUrl } from "../../../../utils/url"; export const ItwIssuanceEidFailureScreen = () => { const failureOption = @@ -47,6 +48,7 @@ const ContentView = ({ failure }: ContentViewProps) => { const machineRef = ItwEidIssuanceMachineContext.useActorRef(); const identification = ItwEidIssuanceMachineContext.useSelector(selectIdentification); + const toast = useIOToast(); useDebugInfo({ failure @@ -118,7 +120,9 @@ const ContentView = ({ failure }: ContentViewProps) => { "features.itWallet.unsupportedDevice.error.secondaryAction" ), onPress: () => - Linking.openURL("https://io.italia.it/documenti-su-io/faq/#n1_12") + openWebUrl("https://io.italia.it/documenti-su-io/faq/#n1_12", () => + toast.error(I18n.t("global.jserror.title")) + ) } }, [IssuanceFailureType.NOT_MATCHING_IDENTITY]: {