Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(IT Wallet): [SIW-980] Add eID issuing IDP selection screen #5752

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { VSpacer } from "@pagopa/io-app-design-system";
import { useFocusEffect } from "@react-navigation/native";
import React from "react";
import { Alert } from "react-native";
import { SpidIdp } from "../../../../../definitions/content/SpidIdp";
import { isReady } from "../../../../common/model/RemoteValue";
import { RNavScreenWithLargeHeader } from "../../../../components/ui/RNavScreenWithLargeHeader";
import { randomOrderIdps } from "../../../../screens/authentication/IdpSelectionScreen";
import { loadIdps } from "../../../../store/actions/content";
import { useIODispatch, useIOSelector } from "../../../../store/hooks";
import { idpsRemoteValueSelector } from "../../../../store/reducers/content";
import {
LocalIdpsFallback,
idps as idpsFallback
} from "../../../../utils/idps";
import IdpsGrid from "../../../../components/IdpsGrid";

export const ItwIdentificationIdpSelectionScreen = () => {
const dispatch = useIODispatch();
const idps = useIOSelector(idpsRemoteValueSelector);
const idpValue = isReady(idps) ? idps.value.items : idpsFallback;
const randomIdps = React.useRef<ReadonlyArray<SpidIdp | LocalIdpsFallback>>(
randomOrderIdps(idpValue)
);

useFocusEffect(
React.useCallback(() => {
dispatch(loadIdps.request());
}, [dispatch])
);

const onIdpSelected = (_idp: LocalIdpsFallback) => {
Alert.alert("Not implemented");
};

return (
<RNavScreenWithLargeHeader title={{ label: "" }}>
<IdpsGrid
idps={randomIdps.current}
onIdpSelected={onIdpSelected}
headerComponent={undefined}
footerComponent={<VSpacer size={24} />}
/>
</RNavScreenWithLargeHeader>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { useIONavigation } from "../../../../navigation/params/AppParamsList";
import { useIODispatch, useIOSelector } from "../../../../store/hooks";
import { isCieSupportedSelector } from "../../../../store/reducers/cie";
import { cieFlowForDevServerEnabled } from "../../../cieLogin/utils";
import { ITW_ROUTES } from "../../navigation/routes";
import { itwNfcIsEnabled } from "../store/actions";
import { itwIsNfcEnabledSelector } from "../store/selectors";
import { ITW_ROUTES } from "../../navigation/routes";

export const ItwIdentificationModeSelectionScreen = () => {
const navigation = useIONavigation();
Expand All @@ -41,7 +41,9 @@ export const ItwIdentificationModeSelectionScreen = () => {
);

const handleSpidPress = () => {
Alert.alert("Not implemented");
navigation.navigate(ITW_ROUTES.MAIN, {
screen: ITW_ROUTES.IDENTIFICATION.IDP_SELECTION
});
};

const handleCiePinPress = () => {
Expand Down
1 change: 1 addition & 0 deletions ts/features/itwallet/navigation/ItwParamsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type ItwParamsList = {
// IDENTIFICATION
[ITW_ROUTES.IDENTIFICATION.MODE_SELECTION]: undefined;
[ITW_ROUTES.IDENTIFICATION.NFC_INSTRUCTIONS]: undefined;
[ITW_ROUTES.IDENTIFICATION.IDP_SELECTION]: undefined;
};
5 changes: 5 additions & 0 deletions ts/features/itwallet/navigation/ItwStackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { isGestureEnabled } from "../../../utils/navigation";
import { ItwIdentificationModeSelectionScreen } from "../identification/screens/ItwIdentificationModeSelectionScreen";
import { ItwDiscoveryInfoScreen } from "../discovery/screens/ItwDiscoveryInfoScreen";
import { ItwIdentificationNfcInstructionsScreen } from "../identification/screens/ItwIdentificationNfcInstructionsScreen";
import { ItwIdentificationIdpSelectionScreen } from "../identification/screens/ItwIdentificationIdpSelectionScreen";
import { ItwParamsList } from "./ItwParamsList";
import { ITW_ROUTES } from "./routes";

Expand All @@ -28,5 +29,9 @@ export const ItwStackNavigator = () => (
name={ITW_ROUTES.IDENTIFICATION.NFC_INSTRUCTIONS}
component={ItwIdentificationNfcInstructionsScreen}
/>
<Stack.Screen
name={ITW_ROUTES.IDENTIFICATION.IDP_SELECTION}
component={ItwIdentificationIdpSelectionScreen}
/>
</Stack.Navigator>
);
3 changes: 2 additions & 1 deletion ts/features/itwallet/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const ITW_ROUTES = {
} as const,
IDENTIFICATION: {
MODE_SELECTION: "ITW_IDENTIFICATION_MODE_SELECTION",
NFC_INSTRUCTIONS: "ITW_IDENTIFICATION_NFC_INSTRUCTIONS"
NFC_INSTRUCTIONS: "ITW_IDENTIFICATION_NFC_INSTRUCTIONS",
IDP_SELECTION: "ITW_IDENTIFICATION_IDP_SELECTION"
} as const
};
Loading