-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a363468
commit 90e2226
Showing
8 changed files
with
232 additions
and
27 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
58 changes: 58 additions & 0 deletions
58
ts/features/wallet/components/OnboardingModuleCredential.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,58 @@ | ||
import React, {useMemo, memo} from 'react'; | ||
import {Badge, IOIcons, ModuleCredential} from '@pagopa/io-app-design-system'; | ||
import i18next from 'i18next'; | ||
import { | ||
wellKnownCredential, | ||
getCredentialNameByType | ||
} from '../utils/credentials'; | ||
|
||
type Props = { | ||
type: string; | ||
onPress: (type: string) => void; | ||
isSaved: boolean; | ||
isFetching: boolean; | ||
}; | ||
|
||
const credentialIconByType: Record<string, IOIcons> = { | ||
[wellKnownCredential.DRIVING_LICENSE]: 'car', | ||
[wellKnownCredential.PID]: 'fingerprint' | ||
}; | ||
|
||
const activeBadge: Badge = { | ||
variant: 'success', | ||
text: i18next.t('home.badges.saved', {ns: 'wallet'}) | ||
}; | ||
|
||
const OnboardingModuleCredential = ({ | ||
type, | ||
onPress, | ||
isSaved, | ||
isFetching | ||
}: Props) => { | ||
const badge = useMemo((): Badge | undefined => { | ||
if (isSaved) { | ||
return activeBadge; | ||
} | ||
return undefined; | ||
}, [isSaved]); | ||
|
||
const handleOnPress = () => { | ||
onPress(type); | ||
}; | ||
|
||
const isPressable = !isSaved; | ||
|
||
return ( | ||
<ModuleCredential | ||
testID={`${type}ModuleTestID`} | ||
icon={credentialIconByType[type]} | ||
label={getCredentialNameByType(type)} | ||
onPress={isPressable ? handleOnPress : undefined} | ||
isFetching={isFetching} | ||
badge={badge} | ||
/> | ||
); | ||
}; | ||
|
||
const MemoizedComponent = memo(OnboardingModuleCredential); | ||
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
56 changes: 56 additions & 0 deletions
56
ts/features/wallet/screens/credentialIssuance/IssuanceList.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,56 @@ | ||
import { | ||
Badge, | ||
IOVisualCostants, | ||
ListItemHeader, | ||
VStack | ||
} from '@pagopa/io-app-design-system'; | ||
import React from 'react'; | ||
import {StyleSheet, View} from 'react-native'; | ||
import {useTranslation} from 'react-i18next'; | ||
import {useAppSelector} from '../../../../store'; | ||
import {lifecycleIsValidSelector} from '../../store/lifecycle'; | ||
import {IOScrollViewWithLargeHeader} from '../../../../components/IOScrollViewWithLargeHeader'; | ||
import {wellKnownCredential} from '../../utils/credentials'; | ||
import {ItwOnboardingModuleCredential} from '../../components/OnboardingModuleCredential'; | ||
|
||
const IssuanceList = () => { | ||
const isWalletValid = useAppSelector(lifecycleIsValidSelector); | ||
const {t} = useTranslation('wallet'); | ||
|
||
const activeBadge: Badge = { | ||
variant: 'success', | ||
text: t('home.badges.saved') | ||
}; | ||
|
||
return ( | ||
<IOScrollViewWithLargeHeader | ||
title={{ | ||
label: t('credentialIssuance.list.title') | ||
}}> | ||
<View style={styles.wrapper}> | ||
<ListItemHeader label={'TEST'} /> | ||
<VStack space={8}> | ||
{Object.entries(wellKnownCredential).map(([_, type]) => ( | ||
<ItwOnboardingModuleCredential | ||
key={`itw_credential_${type}`} | ||
type={type} | ||
isSaved={false} | ||
isFetching={false} | ||
onPress={() => void 0} | ||
/> | ||
))} | ||
</VStack> | ||
</View> | ||
</IOScrollViewWithLargeHeader> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: { | ||
paddingVertical: 16, | ||
paddingHorizontal: IOVisualCostants.appMarginDefault, | ||
gap: 16 | ||
} | ||
}); | ||
|
||
export default IssuanceList; |
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,19 @@ | ||
import i18next from 'i18next'; | ||
|
||
type CredentialsKeys = 'DRIVING_LICENSE' | 'PID'; | ||
|
||
export const wellKnownCredential: Record<CredentialsKeys, string> = { | ||
DRIVING_LICENSE: 'MDL', | ||
PID: 'PersonIdentificationData' | ||
}; | ||
|
||
export const getCredentialNameByType = (type: string): string => { | ||
switch (type) { | ||
case wellKnownCredential.DRIVING_LICENSE: | ||
return i18next.t('credentials.names.mdl', {ns: 'wallet'}); | ||
case wellKnownCredential.PID: | ||
return i18next.t('credentials.names.pid', {ns: 'wallet'}); | ||
default: | ||
return i18next.t('credentials.names.unknown', {ns: 'wallet'}); | ||
} | ||
}; |
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