From ffabede0507a3fe5fe479efdeeef59374fd45f8d Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:26:14 +0100 Subject: [PATCH] feat: [PE-805] CGN update cta on card remove action (#6423) ## Short description The changes focus on updating the text for deactivating the `Carta Giovani Nazionale` ## List of changes proposed in this pull request - Update localizations - Update alert render view ## How to test - Add CGN to the wallet - Check the remove button text - Try to remove the CGN card - Check the alert text and then continue - Check the toast message in both positive and negative case --- locales/de/index.yml | 6 +++--- locales/en/index.yml | 8 +++---- locales/it/index.yml | 8 +++---- .../bonus/cgn/components/CgnServiceCTA.tsx | 21 ++++++++++++------- .../bonus/cgn/hooks/useCgnUnsubscribe.tsx | 19 ++++++++++------- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/locales/de/index.yml b/locales/de/index.yml index e662cac176a..ee4c153456c 100644 --- a/locales/de/index.yml +++ b/locales/de/index.yml @@ -2307,7 +2307,7 @@ bonus: cta: activeBonus: Attiva Carta Giovani Nazionale back: Non ora - deactivateBonus: "Die Karte deaktivieren" + deactivateBonus: "Aus Wallet entfernen" goToDetail: Usa la Carta detail: cta: @@ -2374,10 +2374,10 @@ bonus: title: "Geschafft!" body: "Deine Nationale Jugendkarte ist aktiv." deactivate: - toast: "Die Anfrage zur Deaktivierung war erfolgreich" + toast: "Zahlungsmethode von deinem Konto entfernt!" alert: title: "Karte deaktivieren" - message: "Vuoi davvero disattivare la tua Carta Giovani Nazionale? Se confermi, non potrai più accedere alle opportunità e la carta scomparirà dal Portafoglio." + message: "La Carta verrà disattivata e non potrai più accedere alle opportunità disponibili." expired: Elimina Carta Giovani Nazionale otp: error: "Aufgrund eines technischen Problems war es uns nicht möglich, einen Rabattcode zu generieren. Bitte versuche es erneut." diff --git a/locales/en/index.yml b/locales/en/index.yml index 08dda6ef47f..de969f57807 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -2790,7 +2790,7 @@ bonus: cta: activeBonus: Activate Carta Giovani Nazionale back: Not now - deactivateBonus: Deactivate Carta Giovani Nazionale + deactivateBonus: Remove from Wallet goToDetail: Use the card detail: cta: @@ -2859,10 +2859,10 @@ bonus: title: "Congratulation!" body: "Your Carta Giovani Nazionale is active" deactivate: - toast: "The request to deactivate the card has been successfully executed" + toast: "Method removed!" alert: - title: "Deactivate card" - message: "Do you really want to deactivate your Carta Giovani Nazionale? If you confirm, you will no longer be able to access the opportunities and the card will disappear from your Wallet." + title: "Do you want to remove Carta Giovani from the Wallet?" + message: "The card will be deactivated and you will no longer be able to access the available opportunities." expired: Delete Carta Giovani Nazionale otp: error: "Due to a technical problem we were unable to generate a discount code. Please try again." diff --git a/locales/it/index.yml b/locales/it/index.yml index 2d00e7770aa..cca9b5363d6 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -2791,7 +2791,7 @@ bonus: cta: activeBonus: Attiva Carta Giovani Nazionale back: Non ora - deactivateBonus: Disattiva Carta Giovani Nazionale + deactivateBonus: Rimuovi dal Portafoglio goToDetail: Usa la Carta detail: cta: @@ -2860,10 +2860,10 @@ bonus: title: "Fatto!" body: "La tua Carta Giovani Nazionale è attiva." deactivate: - toast: "La richiesta di disattivazione è avvenuta correttamente" + toast: "Metodo rimosso!" alert: - title: "Disattiva carta" - message: "Vuoi davvero disattivare la tua Carta Giovani Nazionale? Se confermi, non potrai più accedere alle opportunità e la carta scomparirà dal Portafoglio." + title: "Vuoi rimuovere Carta Giovani dal Portafoglio?" + message: "La Carta verrà disattivata e non potrai più accedere alle opportunità disponibili." expired: Elimina Carta Giovani Nazionale otp: error: "Per un problema tecnico non siamo riusciti a generare un codice sconto. Ti chiediamo di riprovare." diff --git a/ts/features/bonus/cgn/components/CgnServiceCTA.tsx b/ts/features/bonus/cgn/components/CgnServiceCTA.tsx index 131839402a4..db7f88f51c3 100644 --- a/ts/features/bonus/cgn/components/CgnServiceCTA.tsx +++ b/ts/features/bonus/cgn/components/CgnServiceCTA.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useRef } from "react"; -import { Alert } from "react-native"; +import { Alert, Platform } from "react-native"; import { ButtonSolid, IOToast } from "@pagopa/io-app-design-system"; import { constNull } from "fp-ts/lib/function"; import * as pot from "@pagopa/ts-commons/lib/pot"; @@ -51,7 +51,7 @@ export const CgnServiceCta = ({ serviceId }: CgnServiceCtaProps) => { IOToast.success(I18n.t("bonus.cgn.activation.deactivate.toast")); dispatch(loadServicePreference.request(serviceId)); }, - () => IOToast.error(I18n.t("global.genericError")) + () => IOToast.error(I18n.t("wallet.delete.failed")) ); } // eslint-disable-next-line functional/immutable-data @@ -65,11 +65,11 @@ export const CgnServiceCta = ({ serviceId }: CgnServiceCtaProps) => { I18n.t("bonus.cgn.activation.deactivate.alert.message"), [ { - text: I18n.t("global.buttons.cancel"), - style: "cancel" - }, - { - text: I18n.t("global.buttons.deactivate"), + text: + Platform.OS === "ios" + ? I18n.t(`wallet.delete.ios.confirm`) + : I18n.t(`wallet.delete.android.confirm`), + style: "destructive", onPress: () => { analytics.trackSpecialServiceStatusChanged({ is_active: false, @@ -77,8 +77,13 @@ export const CgnServiceCta = ({ serviceId }: CgnServiceCtaProps) => { }); dispatch(cgnUnsubscribe.request()); } + }, + { + text: I18n.t("global.buttons.cancel"), + style: "default" } - ] + ], + { cancelable: false } ), [dispatch, serviceId] ); diff --git a/ts/features/bonus/cgn/hooks/useCgnUnsubscribe.tsx b/ts/features/bonus/cgn/hooks/useCgnUnsubscribe.tsx index f5ea9024ff4..73233f5e1b7 100644 --- a/ts/features/bonus/cgn/hooks/useCgnUnsubscribe.tsx +++ b/ts/features/bonus/cgn/hooks/useCgnUnsubscribe.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef } from "react"; -import { Alert } from "react-native"; +import { Alert, Platform } from "react-native"; import { IOToast } from "@pagopa/io-app-design-system"; import { useIODispatch, useIOSelector } from "../../../../store/hooks"; import { cgnUnsubscribeSelector } from "../store/reducers/unsubscribe"; @@ -20,14 +20,19 @@ export function useCgnUnsubscribe() { I18n.t("bonus.cgn.activation.deactivate.alert.message"), [ { - text: I18n.t("global.buttons.cancel"), - style: "cancel" + text: + Platform.OS === "ios" + ? I18n.t(`wallet.delete.ios.confirm`) + : I18n.t(`wallet.delete.android.confirm`), + style: "destructive", + onPress: () => dispatch(cgnUnsubscribe.request()) }, { - text: I18n.t("global.buttons.deactivate"), - onPress: () => dispatch(cgnUnsubscribe.request()) + text: I18n.t("global.buttons.cancel"), + style: "default" } - ] + ], + { cancelable: false } ); }; @@ -37,7 +42,7 @@ export function useCgnUnsubscribe() { IOToast.success(I18n.t("bonus.cgn.activation.deactivate.toast")); } if (isError(unsubscriptionStatus) && !isFirstRender.current) { - IOToast.error(I18n.t("global.genericError")); + IOToast.error(I18n.t("wallet.delete.failed")); } // eslint-disable-next-line functional/immutable-data