mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-07 20:53:54 -05:00
* [INJIMOB-3647] refactor: modify data type of isRevoked to EvaluationStatus Type representing any possible value of EvaluationStatus. - "TRUE" → Condition was evaluated and is positively true - "FALSE" → Condition was evaluated and is definitively false - "UNDETERMINED" → Condition could not be evaluated due to an error Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3647] refactor: modify data type of isRevoked to EvaluationStatus Type representing any possible value of EvaluationStatus. - "TRUE" → Condition was evaluated and is positively true - "FALSE" → Condition was evaluated and is definitively false - "UNDETERMINED" → Condition could not be evaluated due to an error Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3647] refactor: change statuslistVC type to record from string Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> # Conflicts: # shared/vcjs/verifyCredential.ts * [INJIMOB-3647] refactor: update status revoke check to check for null status Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3647] refactor: VCMetadat constructor isRevoked param Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3647] refactor: rename EvaluationStatus to RevocationStatus Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3647] refactor: modify revocation status logs Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import React from 'react';
|
|
import {View} from 'react-native';
|
|
import testIDProps from '../shared/commonUtil';
|
|
import {Display} from './VC/common/VCUtils';
|
|
import VerifiedIcon from './VerifiedIcon';
|
|
import PendingIcon from './PendingIcon';
|
|
import {Row, Text} from './ui';
|
|
import {Theme} from './ui/styleUtils';
|
|
import {useTranslation} from 'react-i18next';
|
|
import {VCMetadata} from '../shared/VCMetadata';
|
|
import {RevocationStatus} from '../shared/vcVerifier/VcVerifier';
|
|
|
|
export const VCVerification: React.FC<VCVerificationProps> = ({
|
|
vcMetadata,
|
|
display,
|
|
showLastChecked = true,
|
|
}) => {
|
|
const {t} = useTranslation('VcDetails');
|
|
|
|
let statusText: string;
|
|
let statusIcon: JSX.Element;
|
|
|
|
if (vcMetadata.isVerified) {
|
|
if (vcMetadata.isRevoked === RevocationStatus.TRUE) {
|
|
statusText = t('revoked');
|
|
statusIcon = <PendingIcon color="brown" />;
|
|
} else if (vcMetadata.isExpired) {
|
|
statusText = t('expired');
|
|
statusIcon = <PendingIcon color="red" />;
|
|
} else if (vcMetadata.isRevoked === RevocationStatus.UNDETERMINED) {
|
|
statusText = t('pending');
|
|
statusIcon = <PendingIcon color="orange" />;
|
|
} else {
|
|
statusText = t('valid');
|
|
statusIcon = <VerifiedIcon />;
|
|
}
|
|
} else {
|
|
statusText = t('pending');
|
|
statusIcon = <PendingIcon color="orange" />;
|
|
}
|
|
|
|
return (
|
|
<View
|
|
{...testIDProps('verified')}
|
|
style={{
|
|
flexDirection: 'column',
|
|
alignItems: 'flex-start',
|
|
paddingVertical: 6,
|
|
}}>
|
|
{/* First Row: Status Icon + Text */}
|
|
<View style={{flexDirection: 'row', alignItems: 'center'}}>
|
|
{statusIcon}
|
|
<Text
|
|
testID="verificationStatus"
|
|
color={display.getTextColor(Theme.Colors.Details)}
|
|
style={Theme.Styles.verificationStatus}>
|
|
{statusText}
|
|
</Text>
|
|
</View>
|
|
|
|
{showLastChecked && vcMetadata.lastKnownStatusTimestamp && (
|
|
<View style={{marginTop: 4}}>
|
|
<Text
|
|
testID="lastCheckedLabel"
|
|
color={display.getTextColor(Theme.Colors.Details)}
|
|
style={[
|
|
Theme.Styles.verificationStatus,
|
|
{fontFamily: 'Inter_400'},
|
|
]}>
|
|
{t('lastChecked')}
|
|
</Text>
|
|
<Text
|
|
testID="lastKnownStatusTimestamp"
|
|
color={display.getTextColor(Theme.Colors.Details)}
|
|
style={[
|
|
Theme.Styles.verificationStatus,
|
|
{fontFamily: 'Inter_400'},
|
|
]}>
|
|
{new Date(vcMetadata.lastKnownStatusTimestamp).toLocaleString()}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
</View>
|
|
);
|
|
};
|
|
|
|
export interface VCVerificationProps {
|
|
vcMetadata: VCMetadata;
|
|
display: Display;
|
|
showLastChecked?: boolean;
|
|
}
|