diff --git a/ts/features/it-wallet/hooks/useItwResetFlow.tsx b/ts/features/it-wallet/hooks/useItwResetFlow.tsx index 50ce43eed46..cb6c4e5fb2a 100644 --- a/ts/features/it-wallet/hooks/useItwResetFlow.tsx +++ b/ts/features/it-wallet/hooks/useItwResetFlow.tsx @@ -1,12 +1,9 @@ import * as React from "react"; import { View } from "react-native"; import { useDispatch } from "react-redux"; -import { IOColors } from "@pagopa/io-app-design-system"; +import { BlockButtons, Body, IOStyles } from "@pagopa/io-app-design-system"; import { useIOBottomSheetModal } from "../../../utils/hooks/bottomSheet"; -import { IOStyles } from "../../../components/core/variables/IOStyles"; -import FooterWithButtons from "../../../components/ui/FooterWithButtons"; import I18n from "../../../i18n"; -import { H4 } from "../../../components/core/typography/H4"; import { itwLifecycleOperational } from "../store/actions/itwLifecycleActions"; /** @@ -16,30 +13,49 @@ export const useItwResetFlow = () => { const dispatch = useDispatch(); const BottomSheetBody = () => ( -

+ {I18n.t("features.itWallet.homeScreen.reset.bottomSheet.body")} -

+
); const Footer = () => ( - dismiss(), - title: I18n.t("features.itWallet.homeScreen.reset.bottomSheet.cancel") + { - dispatch(itwLifecycleOperational()); - dismiss(); - }, - primary: true, - labelColor: IOColors.white, - title: I18n.t("features.itWallet.homeScreen.reset.bottomSheet.confirm") - }} - /> + > + dismiss() + } + }} + secondary={{ + type: "Solid", + buttonProps: { + accessibilityLabel: I18n.t( + "features.itWallet.homeScreen.reset.bottomSheet.confirm" + ), + label: I18n.t( + "features.itWallet.homeScreen.reset.bottomSheet.confirm" + ), + onPress: () => { + dispatch(itwLifecycleOperational()); + dismiss(); + } + } + }} + /> + ); const { present, bottomSheet, dismiss } = useIOBottomSheetModal({ title: I18n.t("features.itWallet.homeScreen.reset.bottomSheet.title"), diff --git a/ts/features/it-wallet/store/actions/itwLifecycleActions.ts b/ts/features/it-wallet/store/actions/itwLifecycleActions.ts index af59c9bf7bf..791517aac72 100644 --- a/ts/features/it-wallet/store/actions/itwLifecycleActions.ts +++ b/ts/features/it-wallet/store/actions/itwLifecycleActions.ts @@ -2,6 +2,7 @@ import { ActionType, createStandardAction } from "typesafe-actions"; /** * Actions which sets the wallet lifecycle status to operational. + * It is intercepted by itw reducers to reset their state. */ export const itwLifecycleOperational = createStandardAction( "ITW_LIFECYCLE_OPERATIONAL" diff --git a/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts b/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts index 3cef3b45862..da6600b23b0 100644 --- a/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts @@ -15,6 +15,7 @@ import { IssuerConfiguration, PidResponse } from "../../utils/types"; +import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; /** * Type for a stored credential. @@ -81,6 +82,11 @@ const reducer = ( O.some(action.payload) ] }); + /** + * Reset the state when the wallet is operational. + */ + case getType(itwLifecycleOperational): + return emptyState; } return state; }; diff --git a/ts/features/it-wallet/store/reducers/itwPidDecodeReducer.ts b/ts/features/it-wallet/store/reducers/itwPidDecodeReducer.ts index 2c50efbb99c..e8fc110edf7 100644 --- a/ts/features/it-wallet/store/reducers/itwPidDecodeReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwPidDecodeReducer.ts @@ -6,6 +6,7 @@ import { Action } from "../../../../store/actions/types"; import { GlobalState } from "../../../../store/reducers/types"; import { itwDecodePid } from "../actions/itwCredentialsActions"; import { ItWalletError } from "../../utils/errors/itwErrors"; +import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; type ItwDecodedPidType = { decodedPid: O.Option; @@ -33,6 +34,11 @@ const reducer = ( return pot.some({ decodedPid: action.payload }); case getType(itwDecodePid.failure): return pot.toError(state, action.payload); + /** + * Reset the state when the wallet is operational. + */ + case getType(itwLifecycleOperational): + return emptyState; } return state; }; diff --git a/ts/features/it-wallet/store/reducers/itwWiaReducer.ts b/ts/features/it-wallet/store/reducers/itwWiaReducer.ts index 59eb72a7a47..75004cab688 100644 --- a/ts/features/it-wallet/store/reducers/itwWiaReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwWiaReducer.ts @@ -5,6 +5,7 @@ import { Action } from "../../../../store/actions/types"; import { GlobalState } from "../../../../store/reducers/types"; import { ItWalletError } from "../../utils/errors/itwErrors"; import { itwWiaRequest } from "../actions/itwWiaActions"; +import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; export type ItwWIAState = pot.Pot, ItWalletError>; @@ -29,6 +30,11 @@ const reducer = ( return pot.some(O.some(action.payload)); case getType(itwWiaRequest.failure): return pot.toError(state, action.payload); + /** + * Reset the state when the wallet is operational. + */ + case getType(itwLifecycleOperational): + return emptyState; } return state; };