mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-10 14:07:59 -05:00
* [INJIMOB-2415] show credential type in mini view Previously, it was showing hardcoded fullName in mini view Other changes include - Handling of display property -> unavailable in wellknown -> empty array in wellknown -> expected credential type (name) is not available in display property of wellknown Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] rename getIDType to getCredentialType Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415]: update logic to get credential type Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-2415]: update the translation for mso mdoc fallback for credential type Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> * [INJIMOB-2415] update getCredentialType method comments Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2369] remove commented code Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] get backgroundColor of VC from curr lang's display property Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] get background image of VC from curr lang's display property Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] get text color of VC from curr lang's display property Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] add prop types for VCVerification component Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] introduce fieldColor prop in VCItemField for VC mini & detail view As of now, for each and every field that is getting rendered we are calling getTextColor with wellknown param, if we start bringing in logic of getDisplayObjectForCurrentLanguage and then get the text_color from it, we will end up in running a filter for each and every field. For reducing this complexity, VCItemField component is accepting fieldColor prop from the caller. Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] move fallback miniview kebab popup color to const Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] move fallback detailview border color to const Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] move fallback verification text color to const Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] remove unnecessary sending of props Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor type error Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor type error Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor - remove unused prop Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor getBackgroundColor to accept display element as per app languange Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor getBackgroundImage to accept display element as per app languange Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] refactor getTextColor to accept display element as per app languange Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] fix credential type to be shown based on app lang Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] extract card's display related functions to class Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2415] fix build fail for accessing Theme in static block Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Signed-off-by: Alka Prasad <prasadalka1998@gmail.com> Co-authored-by: Alka Prasad <prasadalka1998@gmail.com>
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import {formatDistanceToNow} from 'date-fns';
|
|
import {getCredentialTypeFromWellKnown} from './VC/common/VCUtils';
|
|
import * as DateFnsLocale from 'date-fns/locale';
|
|
import {VCItemContainerFlowType} from '../shared/Utils';
|
|
import {TFunction} from 'react-i18next';
|
|
|
|
export type ActivityLogType =
|
|
| '' // replacement for undefined
|
|
| 'VC_SHARED'
|
|
| 'VC_RECEIVED'
|
|
| 'VC_RECEIVED_NOT_SAVED'
|
|
| 'VC_DELETED'
|
|
| 'VC_DOWNLOADED'
|
|
| 'VC_SHARED_WITH_VERIFICATION_CONSENT'
|
|
| 'VC_RECEIVED_WITH_PRESENCE_VERIFIED'
|
|
| 'VC_RECEIVED_BUT_PRESENCE_VERIFICATION_FAILED'
|
|
| 'PRESENCE_VERIFIED_AND_VC_SHARED'
|
|
| 'PRESENCE_VERIFICATION_FAILED'
|
|
| 'QRLOGIN_SUCCESFULL'
|
|
| 'WALLET_BINDING_SUCCESSFULL'
|
|
| 'WALLET_BINDING_FAILURE'
|
|
| 'VC_REMOVED'
|
|
| 'TAMPERED_VC_REMOVED';
|
|
|
|
export interface ActivityLog {
|
|
getActionText(t: TFunction, wellknown: Object | undefined);
|
|
}
|
|
|
|
export class VCActivityLog implements ActivityLog {
|
|
id: string;
|
|
credentialConfigurationId: string;
|
|
_vcKey: string;
|
|
timestamp: number;
|
|
deviceName: string;
|
|
type: ActivityLogType;
|
|
issuer: string;
|
|
flow: string;
|
|
|
|
constructor({
|
|
id = '',
|
|
idType = [],
|
|
_vcKey = '',
|
|
type = '',
|
|
timestamp = Date.now(),
|
|
deviceName = '',
|
|
issuer = '',
|
|
credentialConfigurationId = '',
|
|
flow = VCItemContainerFlowType.VC_SHARE,
|
|
} = {}) {
|
|
this.id = id;
|
|
this.idType = idType;
|
|
this._vcKey = _vcKey;
|
|
this.type = type;
|
|
this.timestamp = timestamp;
|
|
this.deviceName = deviceName;
|
|
this.issuer = issuer;
|
|
this.credentialConfigurationId = credentialConfigurationId;
|
|
this.flow = flow;
|
|
}
|
|
|
|
getActionText(t: TFunction, wellknown: Object | undefined) {
|
|
if (!!this.credentialConfigurationId && wellknown) {
|
|
const cardType = getCredentialTypeFromWellKnown(
|
|
wellknown,
|
|
this.credentialConfigurationId,
|
|
);
|
|
return `${t(this.type, {idType: cardType})}`;
|
|
}
|
|
return `${t(this.type, {idType: ''})}`;
|
|
}
|
|
|
|
static getLogFromObject(data: Object): VCActivityLog {
|
|
return new VCActivityLog(data);
|
|
}
|
|
|
|
getActionLabel(language: string) {
|
|
return [
|
|
this.deviceName,
|
|
formatDistanceToNow(this.timestamp, {
|
|
addSuffix: true,
|
|
locale: DateFnsLocale[language],
|
|
}),
|
|
]
|
|
.filter(label => label?.trim() !== '')
|
|
.join(' · ');
|
|
}
|
|
}
|