Skip to content

Commit

Permalink
chore(IT Wallet): [SIW-1804] Already activated wallet screen (#6376)
Browse files Browse the repository at this point in the history
## Short description
This PR adds a new error screen visible if the user tries to activate
the wallet when it is already active, starting with the CTA of the
activation message

## List of changes proposed in this pull request
- Added a new `ItwAlreadyActiveScreen`
- Mapped the navigation inside `useItwLinkingOptions`

## How to test
From the message CTA with an active eID try to navigate to the Discovery
screen.
You can also use the deep link to test the navigation
`ioit://itw/discovery/info`

Preview:
![IMAGE 2024-11-06
15:07:35](https://github.com/user-attachments/assets/9e8dabd1-3491-47a6-858c-90a0edaa94f4)
  • Loading branch information
ale-mazz authored Nov 8, 2024
1 parent 36d2985 commit 5bff7b3
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 9 deletions.
4 changes: 4 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,10 @@ features:
title: "Novità in arrivo: i tuoi Documenti su IO"
content: Presto potrai aggiungere anche tu le versioni digitali dei tuoi documenti personali, come Patente e Tessera Sanitaria, al tuo Portafoglio di IO!
action: Scopri di più
alreadyActive:
title: "Documenti su IO è già attiva"
content: "Continua ad aggiungere le versioni digitali dei tuoi documenti al Portafoglio."
action: "Vai al Portafoglio"
identification:
mode:
title: Verifica la tua identità
Expand Down
4 changes: 4 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,10 @@ features:
title: "Novità in arrivo: i tuoi Documenti su IO"
content: Presto potrai aggiungere anche tu le versioni digitali dei tuoi documenti personali, come Patente e Tessera Sanitaria, al tuo Portafoglio di IO!
action: Scopri di più
alreadyActive:
title: "Documenti su IO è già attiva"
content: "Continua ad aggiungere le versioni digitali dei tuoi documenti al Portafoglio."
action: "Vai al Portafoglio"
identification:
mode:
title: Verifica la tua identità
Expand Down
3 changes: 2 additions & 1 deletion ts/features/itwallet/analytics/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export enum ITW_ERRORS_EVENTS {
ITW_ID_REQUEST_UNEXPECTED_FAILURE = "ITW_ID_REQUEST_UNEXPECTED_FAILURE",
ITW_LOGIN_ID_NOT_MATCH = "ITW_LOGIN_ID_NOT_MATCH",
ITW_ALREADY_HAS_CREDENTIAL = "ITW_ALREADY_HAS_CREDENTIAL",
ITW_ADD_CREDENTIAL_INVALID_STATUS = "ITW_ADD_CREDENTIAL_INVALID_STATUS"
ITW_ADD_CREDENTIAL_INVALID_STATUS = "ITW_ADD_CREDENTIAL_INVALID_STATUS",
ITW_ALREADY_ACTIVATED = "ITW_ALREADY_ACTIVATED"
}

export enum ITW_EXIT_EVENTS {
Expand Down
7 changes: 7 additions & 0 deletions ts/features/itwallet/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,13 @@ export const trackItwIdRequestUnexpected = ({
);
};

export const trackItwAlreadyActivated = () => {
void mixpanelTrack(
ITW_ERRORS_EVENTS.ITW_ALREADY_ACTIVATED,
buildEventProperties("KO", "error")
);
};

// #endregion ERRORS

// #region PROFILE PROPERTIES
Expand Down
61 changes: 61 additions & 0 deletions ts/features/itwallet/discovery/screens/ItwAlreadyActiveScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { useCallback } from "react";
import { useFocusEffect } from "@react-navigation/native";
import I18n from "../../../../i18n";
import { OperationResultScreenContent } from "../../../../components/screens/OperationResultScreenContent";
import { useAvoidHardwareBackButton } from "../../../../utils/useAvoidHardwareBackButton";
import ROUTES from "../../../../navigation/routes";
import { useIONavigation } from "../../../../navigation/params/AppParamsList";
import { useItwDisableGestureNavigation } from "../../common/hooks/useItwDisableGestureNavigation";
import { trackItwAlreadyActivated } from "../../analytics";

export const ItwAlreadyActiveScreen = () => {
useItwDisableGestureNavigation();
useAvoidHardwareBackButton();

const navigation = useIONavigation();

const navigateToWallet = () => {
navigation.reset({
index: 1,
routes: [
{
name: ROUTES.MAIN,
params: {
screen: ROUTES.WALLET_HOME
}
}
]
});
};

const handleClose = () => {
navigation.pop();
};

useFocusEffect(
useCallback(() => {
trackItwAlreadyActivated();
}, [])
);

return (
<OperationResultScreenContent
pictogram="itWallet"
title={I18n.t("features.itWallet.discovery.alreadyActive.title")}
subtitle={I18n.t("features.itWallet.discovery.alreadyActive.content")}
isHeaderVisible={false}
action={{
label: I18n.t("features.itWallet.discovery.alreadyActive.action"),
accessibilityLabel: I18n.t(
"features.itWallet.discovery.alreadyActive.action"
),
onPress: navigateToWallet
}}
secondaryAction={{
label: I18n.t("global.buttons.close"),
accessibilityLabel: I18n.t("global.buttons.close"),
onPress: handleClose
}}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react";
import { createStore } from "redux";
import { applicationChangeState } from "../../../../../store/actions/application";
import { appReducer } from "../../../../../store/reducers";
import { GlobalState } from "../../../../../store/reducers/types";
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper";
import { ITW_ROUTES } from "../../../navigation/routes";
import { ItwAlreadyActiveScreen } from "../ItwAlreadyActiveScreen";

describe("Test ItwAlreadyActive screen", () => {
it("it should render the screen correctly", () => {
const component = renderComponent();
expect(component).toBeTruthy();
});
});

const renderComponent = () => {
const globalState = appReducer(undefined, applicationChangeState("active"));

return renderScreenWithNavigationStoreContext<GlobalState>(
() => <ItwAlreadyActiveScreen />,
ITW_ROUTES.DISCOVERY.ALREADY_ACTIVE_SCREEN,
{},
createStore(appReducer, globalState as any)
);
};
1 change: 1 addition & 0 deletions ts/features/itwallet/navigation/ItwParamsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type ItwParamsList = {
// DISCOVERY
[ITW_ROUTES.DISCOVERY.INFO]: undefined;
[ITW_ROUTES.DISCOVERY.IPZS_PRIVACY]: undefined;
[ITW_ROUTES.DISCOVERY.ALREADY_ACTIVE_SCREEN]: undefined;
// IDENTIFICATION
[ITW_ROUTES.IDENTIFICATION.MODE_SELECTION]: undefined;
[ITW_ROUTES.IDENTIFICATION.IDP_SELECTION]: undefined;
Expand Down
10 changes: 8 additions & 2 deletions ts/features/itwallet/navigation/ItwStackNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
TransitionPresets,
createStackNavigator
createStackNavigator,
TransitionPresets
} from "@react-navigation/stack";
import * as React from "react";
import { Platform } from "react-native";
Expand Down Expand Up @@ -34,6 +34,7 @@ import { ItwPresentationCredentialAttachmentScreen } from "../presentation/scree
import { ItwPresentationCredentialDetailScreen } from "../presentation/screens/ItwPresentationCredentialDetailScreen";
import { ItwIssuanceCredentialAsyncContinuationScreen } from "../issuance/screens/ItwIssuanceCredentialAsyncContinuationScreen";
import ItwIpzsPrivacyScreen from "../discovery/screens/ItwIpzsPrivacyScreen";
import { ItwAlreadyActiveScreen } from "../discovery/screens/ItwAlreadyActiveScreen";
import { ItwParamsList } from "./ItwParamsList";
import { ITW_ROUTES } from "./routes";

Expand Down Expand Up @@ -79,6 +80,11 @@ const InnerNavigator = () => {
name={ITW_ROUTES.DISCOVERY.IPZS_PRIVACY}
component={ItwIpzsPrivacyScreen}
/>
<Stack.Screen
name={ITW_ROUTES.DISCOVERY.ALREADY_ACTIVE_SCREEN}
component={ItwAlreadyActiveScreen}
options={hiddenHeader}
/>
{/* IDENTIFICATION */}
<Stack.Screen
name={ITW_ROUTES.IDENTIFICATION.MODE_SELECTION}
Expand Down
3 changes: 2 additions & 1 deletion ts/features/itwallet/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const ITW_ROUTES = {
ONBOARDING: "ITW_CARD_ONBOARDING" as const,
DISCOVERY: {
INFO: "ITW_DISCOVERY_INFO",
IPZS_PRIVACY: "ITW_IPZS_PRIVACY"
IPZS_PRIVACY: "ITW_IPZS_PRIVACY",
ALREADY_ACTIVE_SCREEN: "ITW_ALREADY_ACTIVE_SCREEN"
} as const,
IDENTIFICATION: {
MODE_SELECTION: "ITW_IDENTIFICATION_MODE_SELECTION",
Expand Down
9 changes: 4 additions & 5 deletions ts/features/itwallet/navigation/useItwLinkingOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ export const useItwLinkingOptions = (): PathConfigMap<AppParamsList> => {
const isItwEnabled = useIOSelector(isItwEnabledSelector);

const isUserAllowedToItw = isItwEnabled && isItwTrialActive;
const canItwBeActivated = isUserAllowedToItw && !isItwValid;

return {
[ITW_ROUTES.MAIN]: {
path: "itw",
screens: {
...(isUserAllowedToItw && {
[ITW_ROUTES.ISSUANCE.CREDENTIAL_ASYNC_FLOW_CONTINUATION]:
"credential/issuance"
}),
...(canItwBeActivated && {
[ITW_ROUTES.DISCOVERY.INFO]: "discovery/info"
"credential/issuance",
[isItwValid
? ITW_ROUTES.DISCOVERY.ALREADY_ACTIVE_SCREEN
: ITW_ROUTES.DISCOVERY.INFO]: "discovery/info"
})
}
}
Expand Down

0 comments on commit 5bff7b3

Please sign in to comment.