From d792414d2931930a779a28ee11b0d2ac338c59d1 Mon Sep 17 00:00:00 2001 From: BalachandarG Date: Wed, 13 Nov 2024 08:52:11 +0530 Subject: [PATCH] [INJIMOB-2272]: Expired Vc UI changes based on error code Signed-off-by: BalachandarG --- .talismanrc | 2 +- components/VC/Views/VCCardView.tsx | 1 + components/VC/Views/VCCardViewContent.tsx | 2 ++ components/VC/common/VCUtils.tsx | 1 + components/VCVerification.tsx | 24 +++++++++++++++---- locales/ara.json | 1 + locales/en.json | 1 + locales/fil.json | 1 + locales/hin.json | 1 + locales/kan.json | 1 + locales/tam.json | 1 + machines/Issuers/IssuersActions.ts | 29 +++++++++++++++++++++-- machines/Issuers/IssuersMachine.ts | 8 +++++-- machines/Issuers/IssuersService.ts | 1 + shared/VCMetadata.ts | 3 +++ 15 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.talismanrc b/.talismanrc index 742a377a..bae68964 100644 --- a/.talismanrc +++ b/.talismanrc @@ -166,7 +166,7 @@ fileignoreconfig: - filename: shared/storage.ts checksum: 181bbdfe1f4a7daa82c7e8ea1050028c4c50f72200ab2a5eff5bfe1915c7de68 - filename: shared/constants.ts - checksum: 69aa79ed25fee2162de7c8e065930e18168551377420a520092bdf6a86c7712d + checksum: b183a74ebd7bdba4efe44e6fc4cc87d3f14f6f83ffc007b7ec1f1697a6c73f0e - filename: machines/backupAndRestore/backup.ts checksum: 9810de8d626df3a2cf8266e4be0c1b50aa3bce3c6e3b082afaa3e3ecab66af17 - filename: machines/backupAndRestore/backup.typegen.ts diff --git a/components/VC/Views/VCCardView.tsx b/components/VC/Views/VCCardView.tsx index 6c2963d0..51c8383d 100644 --- a/components/VC/Views/VCCardView.tsx +++ b/components/VC/Views/VCCardView.tsx @@ -102,6 +102,7 @@ export const VCCardView: React.FC = props => { KEBAB_POPUP={controller.KEBAB_POPUP} isVerified={props.vcMetadata.isVerified} isInitialLaunch={props.isInitialLaunch} + isExpired={props.vcMetadata.isExpired} /> ); diff --git a/components/VC/Views/VCCardViewContent.tsx b/components/VC/Views/VCCardViewContent.tsx index 19dac3a8..916e9058 100644 --- a/components/VC/Views/VCCardViewContent.tsx +++ b/components/VC/Views/VCCardViewContent.tsx @@ -87,6 +87,7 @@ export const VCCardViewContent: React.FC = props => { @@ -164,6 +165,7 @@ export interface VCItemContentProps { vcMetadata: VCMetadata; isVerified?: boolean; isInitialLaunch?: boolean; + isExpired?: boolean; } VCCardViewContent.defaultProps = { diff --git a/components/VC/common/VCUtils.tsx b/components/VC/common/VCUtils.tsx index 024fe9d7..33c903e8 100644 --- a/components/VC/common/VCUtils.tsx +++ b/components/VC/common/VCUtils.tsx @@ -80,6 +80,7 @@ export const getFieldValue = ( ); case 'idType': diff --git a/components/VCVerification.tsx b/components/VCVerification.tsx index 7f7ca716..9fcb19df 100644 --- a/components/VCVerification.tsx +++ b/components/VCVerification.tsx @@ -8,13 +8,27 @@ import {useTranslation} from 'react-i18next'; import PendingIcon from './PendingIcon'; import {VCMetadata} from '../shared/VCMetadata'; -export const VCVerification: React.FC = ({ - isVerified, +export const VCVerification: React.FC = ({ display, -}) => { + isVerified, + isExpired, +}: any) => { const {t} = useTranslation('VcDetails'); - const statusText = isVerified ? t('valid') : t('pending'); - const statusIcon = isVerified ? : ; + const statusText = isVerified + ? isExpired + ? t('expired') + : t('valid') + : t('pending'); + + const statusIcon = isVerified ? ( + isExpired ? ( + + ) : ( + + ) + ) : ( + + ); return ( { isVerified: false, }), }), + setIsExpired: assign({ + vcMetadata: (context: any, event: any) => { + return new VCMetadata({ + ...context.vcMetadata, + isExpired: event.data.verificationErrorCode == EXPIRED_VC_ERROR_CODE, + }); + }, + }), + resetIsExpired: assign({ + vcMetadata: (context: any, event: any) => + new VCMetadata({ + ...context.vcMetadata, + isExpired: false, + }), + }), setIssuers: model.assign({ issuers: (_: any, event: any) => event.data, }), @@ -106,7 +126,12 @@ export const IssuersActions = (model: any) => { if (error.includes(REQUEST_TIMEOUT)) { return ErrorMessage.REQUEST_TIMEDOUT; } - if (error.includes(OIDCErrors.AUTHORIZATION_ENDPOINT_DISCOVERY.GRANT_TYPE_NOT_SUPPORTED)) { + if ( + error.includes( + OIDCErrors.AUTHORIZATION_ENDPOINT_DISCOVERY + .GRANT_TYPE_NOT_SUPPORTED, + ) + ) { return ErrorMessage.AUTHORIZATION_GRANT_TYPE_NOT_SUPPORTED; } return ErrorMessage.GENERIC; diff --git a/machines/Issuers/IssuersMachine.ts b/machines/Issuers/IssuersMachine.ts index 8ceadb54..f2a4ee5d 100644 --- a/machines/Issuers/IssuersMachine.ts +++ b/machines/Issuers/IssuersMachine.ts @@ -432,14 +432,18 @@ export const IssuersMachine = model.createMachine( src: 'verifyCredential', onDone: [ { - actions: ['sendSuccessEndEvent', 'setIsVerified'], + actions: ['sendSuccessEndEvent', 'setIsVerified', 'setIsExpired'], target: 'storing', }, ], onError: [ { cond: 'isVerificationPendingBecauseOfNetworkIssue', - actions: ['resetLoadingReason', 'resetIsVerified'], + actions: [ + 'resetLoadingReason', + 'resetIsVerified', + 'resetIsExpired', + ], target: 'storing', }, { diff --git a/machines/Issuers/IssuersService.ts b/machines/Issuers/IssuersService.ts index d93685d8..cd890b39 100644 --- a/machines/Issuers/IssuersService.ts +++ b/machines/Issuers/IssuersService.ts @@ -163,6 +163,7 @@ export const IssuersService = () => { if (!verificationResult.isVerified) { throw new Error(verificationResult.verificationErrorCode); } + return verificationResult; } else { return { isVerified: true, diff --git a/shared/VCMetadata.ts b/shared/VCMetadata.ts index f965afbb..5392a540 100644 --- a/shared/VCMetadata.ts +++ b/shared/VCMetadata.ts @@ -24,6 +24,7 @@ export class VCMetadata { isVerified: boolean = false; mosipIndividualId: string = ''; format: string = ''; + isExpired: boolean = false; downloadKeyType: string = ''; constructor({ @@ -38,6 +39,7 @@ export class VCMetadata { mosipIndividualId = '', format = '', downloadKeyType = '', + isExpired = false, } = {}) { this.idType = idType; this.requestId = requestId; @@ -50,6 +52,7 @@ export class VCMetadata { this.mosipIndividualId = mosipIndividualId; this.format = format; this.downloadKeyType = downloadKeyType; + this.isExpired = isExpired; } //TODO: Remove any typing and use appropriate typing