-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IT Wallet): [SIW-1802] Handle remotely disabled credentials and …
…alert (#6442) > [!WARNING] > Depends on #6441 ## Short description This PR handles the remote configuration for the credential selection screen, in order to - Display an alert to inform the user of any problems with credentials; - Disable specific credentials so the user cannot start the issuance flow. ## List of changes proposed in this pull request - Modified `WalletCardOnboardingScreen` - Created `ItwOnboardingModuleCredential` to keep the parent component cleaner ## How to test Mock the response of `/status/backend.json` with the following configuration: ```json { "statusMessages": { "items": [ { "routes": ["ITW_CARD_ONBOARDING"], "level": "warning", "message": { "it-IT": "C'è un problema temporaneo sul servizio di emissione della versione digitale della Patente. Riprova più tardi.", "en-EN": "C'è un problema temporaneo sul servizio di emissione della versione digitale della Patente. Riprova più tardi." } } ] }, "config": { "itw": { "disabled_credentials": ["MDL"] } } } ``` <img src="https://github.com/user-attachments/assets/f8d0c87a-2331-4ef5-8101-7cfe723a1e3d" width="340" /> --------- Co-authored-by: Riccardo.Molinari <[email protected]> Co-authored-by: RiccardoMolinari95 <[email protected]> Co-authored-by: RiccardoMolinari95 <[email protected]> Co-authored-by: Federico Mastrini <[email protected]>
- Loading branch information
1 parent
4136f6d
commit bb7e753
Showing
6 changed files
with
153 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
ts/features/itwallet/onboarding/components/ItwOnboardingModuleCredential.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useMemo, memo } from "react"; | ||
import { Badge, IOIcons, ModuleCredential } from "@pagopa/io-app-design-system"; | ||
import I18n from "../../../../i18n"; | ||
import { getCredentialNameFromType } from "../../common/utils/itwCredentialUtils"; | ||
import { CredentialType } from "../../common/utils/itwMocksUtils"; | ||
|
||
type Props = { | ||
type: string; | ||
onPress: (type: string) => void; | ||
isActive: boolean; | ||
isDisabled: boolean; | ||
isCredentialIssuancePending: boolean; | ||
isSelectedCredential: boolean; | ||
}; | ||
|
||
const credentialIconByType: Record<string, IOIcons> = { | ||
[CredentialType.DRIVING_LICENSE]: "car", | ||
[CredentialType.EUROPEAN_DISABILITY_CARD]: "accessibility", | ||
[CredentialType.EUROPEAN_HEALTH_INSURANCE_CARD]: "healthCard" | ||
}; | ||
|
||
const activeBadge: Badge = { | ||
variant: "success", | ||
text: I18n.t("features.wallet.onboarding.badge.active") | ||
}; | ||
|
||
const disabledBadge: Badge = { | ||
variant: "default", | ||
text: I18n.t("features.wallet.onboarding.badge.unavailable") | ||
}; | ||
|
||
const ItwOnboardingModuleCredential = ({ | ||
type, | ||
onPress, | ||
isActive, | ||
isDisabled, | ||
isSelectedCredential, | ||
isCredentialIssuancePending | ||
}: Props) => { | ||
const badge = useMemo((): Badge | undefined => { | ||
if (isActive) { | ||
return activeBadge; | ||
} | ||
if (isDisabled) { | ||
return disabledBadge; | ||
} | ||
return undefined; | ||
}, [isActive, isDisabled]); | ||
|
||
const handleOnPress = () => { | ||
onPress(type); | ||
}; | ||
|
||
const isPressable = !(isActive || isDisabled || isCredentialIssuancePending); | ||
|
||
return ( | ||
<ModuleCredential | ||
testID={`${type}ModuleTestID`} | ||
icon={credentialIconByType[type]} | ||
label={getCredentialNameFromType(type)} | ||
onPress={isPressable ? handleOnPress : undefined} | ||
isFetching={isCredentialIssuancePending && isSelectedCredential} | ||
badge={badge} | ||
/> | ||
); | ||
}; | ||
|
||
const MemoizedComponent = memo(ItwOnboardingModuleCredential); | ||
export { MemoizedComponent as ItwOnboardingModuleCredential }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters