mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 13:38:01 -05:00
* [INJIMOB-3581] add revocation and reverification logic Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3581] refactor readable array conversion to a shared utility Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> --------- Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
90 lines
2.7 KiB
TypeScript
90 lines
2.7 KiB
TypeScript
import {useTranslation} from 'react-i18next';
|
|
import {SvgImage} from './ui/svg';
|
|
import {useKebabPopUp} from './KebabPopUpController';
|
|
import {isActivationNeeded} from '../shared/openId4VCI/Utils';
|
|
import {VCShareFlowType} from '../shared/Utils';
|
|
|
|
export const getKebabMenuOptions = props => {
|
|
const controller = useKebabPopUp(props);
|
|
const {t} = useTranslation('HomeScreenKebabPopUp');
|
|
|
|
const loadScanScreen = flowType => () => {
|
|
controller.SELECT_VC_ITEM(props.service, flowType),
|
|
controller.GOTO_SCANSCREEN(),
|
|
props.service.send('CLOSE_VC_MODAL');
|
|
};
|
|
|
|
const activationNotCompleted =
|
|
!controller.walletBindingResponse &&
|
|
isActivationNeeded(props?.vcMetadata.issuer);
|
|
|
|
const vcActionsList = [
|
|
{
|
|
label: props.vcMetadata.isPinned ? t('unPinCard') : t('pinCard'),
|
|
icon: SvgImage.OutlinedPinIcon(),
|
|
onPress: controller.PIN_CARD,
|
|
testID: 'pinOrUnPinCard',
|
|
},
|
|
{
|
|
label: t('viewActivityLog'),
|
|
icon: SvgImage.OutlinedScheduleIcon(),
|
|
onPress: controller.SHOW_ACTIVITY,
|
|
testID: 'viewActivityLog',
|
|
},
|
|
{
|
|
label: t('reverify'),
|
|
icon: SvgImage.ReverifyIcon(),
|
|
onPress: controller.REVERIFY_VC,
|
|
testID: 'reverify',
|
|
},
|
|
{
|
|
label: t('removeFromWallet'),
|
|
icon: SvgImage.outlinedDeleteIcon(),
|
|
onPress: () => controller.REMOVE(props.vcMetadata),
|
|
testID: 'removeFromWallet',
|
|
},
|
|
];
|
|
|
|
const share = {
|
|
label: t('share'),
|
|
icon: SvgImage.OutlinedShareIcon(),
|
|
onPress: loadScanScreen(VCShareFlowType.MINI_VIEW_SHARE),
|
|
testID: 'shareVcFromKebab',
|
|
};
|
|
|
|
const shareWithSelfieOption = {
|
|
label: t('shareWithSelfie'),
|
|
icon: SvgImage.OutlinedShareWithSelfieIcon(),
|
|
onPress: loadScanScreen(VCShareFlowType.MINI_VIEW_SHARE_WITH_SELFIE),
|
|
testID: 'shareVcWithSelfieFromKebab',
|
|
};
|
|
|
|
const VCActivationOption = {
|
|
label: activationNotCompleted
|
|
? t('WalletBinding:offlineAuthenticationDisabled')
|
|
: isActivationNeeded(props.vcMetadata.issuer)
|
|
? t('WalletBinding:profileAuthenticated')
|
|
: t('WalletBinding:credentialActivated'),
|
|
icon: SvgImage.OutlinedShieldedIcon(),
|
|
onPress: activationNotCompleted
|
|
? controller.ADD_WALLET_BINDING_ID
|
|
: loadScanScreen(VCShareFlowType.MINI_VIEW_QR_LOGIN),
|
|
testID: 'pendingActivationOrActivated',
|
|
};
|
|
|
|
if (props.vcMetadata.isVerified) {
|
|
vcActionsList.splice(1, 0, share);
|
|
if (props.vcHasImage) {
|
|
vcActionsList.splice(2, 0, shareWithSelfieOption, VCActivationOption);
|
|
}
|
|
if (props.vcMetadata.isExpired) {
|
|
const indexOfActivation = vcActionsList.indexOf(VCActivationOption);
|
|
if (indexOfActivation !== -1) {
|
|
vcActionsList.splice(indexOfActivation, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return vcActionsList;
|
|
};
|