mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 21:48:04 -05:00
* Revert "[INJIMOB-3622] Fix alignment in history screen (#2140)" This reverts commita0b08914e5. Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * Revert "Injimob [3622] [3627] - BANNER ISSUE AND BRANDING CHANGES ISSUES (#2130)" This reverts commit522104811c. Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * Revert "[INJIMOB-3633][INJIMOB-3636] fix icon bg color across app (#2134)" This reverts commitd8d718693d. Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * Revert "[INJIMOB-3633] fix search bar clear icon not apperaing (#2133)" This reverts commit6a202b11af. Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * Injimob-3651: revert all the old branding changes and add new changes #2150 Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3651]: Update all the test snapshots Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> --------- Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com>
151 lines
5.1 KiB
TypeScript
151 lines
5.1 KiB
TypeScript
import React, {useEffect, useState} from 'react';
|
|
import {useTranslation} from 'react-i18next';
|
|
import {DeviceInfoList} from '../../components/DeviceInfoList';
|
|
import {Button, Column, Text} from '../../components/ui';
|
|
import {Theme} from '../../components/ui/styleUtils';
|
|
import {useReceiveVcScreen} from './ReceiveVcScreenController';
|
|
import {MessageOverlay} from '../../components/MessageOverlay';
|
|
import {useOverlayVisibleAfterTimeout} from '../../shared/hooks/useOverlayVisibleAfterTimeout';
|
|
import {VcDetailsContainer} from '../../components/VC/VcDetailsContainer';
|
|
import {SharingStatusModal} from '../Scan/SharingStatusModal';
|
|
import {SvgImage} from '../../components/ui/svg';
|
|
import {DETAIL_VIEW_DEFAULT_FIELDS} from '../../components/VC/common/VCUtils';
|
|
import {getDetailedViewFields} from '../../shared/openId4VCI/Utils';
|
|
import {VCProcessor} from '../../components/VC/common/VCProcessor';
|
|
import VcRenderer from '../../shared/vcRenderer/VcRenderer';
|
|
|
|
export const ReceiveVcScreen: React.FC = () => {
|
|
const {t} = useTranslation('ReceiveVcScreen');
|
|
const [fields, setFields] = useState([]);
|
|
const [wellknown, setWellknown] = useState(null);
|
|
const controller = useReceiveVcScreen();
|
|
const savingOverlayVisible = useOverlayVisibleAfterTimeout(
|
|
controller.isAccepting,
|
|
);
|
|
const verifiableCredentialData = controller.verifiableCredentialData;
|
|
const profileImage = verifiableCredentialData.face;
|
|
|
|
const [credential, setCredential] = useState(null);
|
|
|
|
const [svgTemplate, setSvgTemplate] = useState<string[] | null>(null);
|
|
const [svgRendererError, setSvgRendererError] = useState<string[] | null>(
|
|
null,
|
|
);
|
|
const [loadingSvg, setLoadingSvg] = useState<boolean>(true);
|
|
|
|
useEffect(() => {
|
|
async function processVC() {
|
|
if (controller.credential) {
|
|
const vcData = await VCProcessor.processForRendering(
|
|
controller.credential,
|
|
verifiableCredentialData.vcMetadata.format,
|
|
);
|
|
setCredential(vcData);
|
|
}
|
|
}
|
|
|
|
processVC();
|
|
}, [controller.credential]);
|
|
|
|
useEffect(() => {
|
|
const fetchSvg = async () => {
|
|
try {
|
|
setLoadingSvg(true);
|
|
|
|
const vcJsonString = JSON.stringify(controller.credential.credential);
|
|
const result = await VcRenderer.getInstance().generateCredentialDisplayContent(
|
|
verifiableCredentialData.vcMetadata.format,
|
|
wellknown ?? null,
|
|
vcJsonString,
|
|
);
|
|
|
|
setSvgTemplate(result);
|
|
setSvgRendererError(null);
|
|
} catch (err: any) {
|
|
setSvgTemplate(null);
|
|
setSvgRendererError(err.errorCode ?? 'Unknown error');
|
|
} finally {
|
|
setLoadingSvg(false);
|
|
}
|
|
};
|
|
|
|
if (controller.credential?.credential['renderMethod']) {
|
|
requestAnimationFrame(fetchSvg);
|
|
} else {
|
|
setLoadingSvg(false);
|
|
}
|
|
}, [controller.credential?.credential, wellknown]);
|
|
|
|
useEffect(() => {
|
|
getDetailedViewFields(
|
|
verifiableCredentialData.vcMetadata.issuerHost,
|
|
verifiableCredentialData.credentialConfigurationId,
|
|
DETAIL_VIEW_DEFAULT_FIELDS,
|
|
verifiableCredentialData.vcMetadata.format,
|
|
verifiableCredentialData.vcMetadata.issuerHost,
|
|
).then(response => {
|
|
setWellknown(response.matchingCredentialIssuerMetadata);
|
|
setFields(response.fields);
|
|
controller.STORE_INCOMING_VC_WELLKNOWN_CONFIG(
|
|
verifiableCredentialData?.issuer,
|
|
response.wellknownResponse,
|
|
);
|
|
});
|
|
}, [verifiableCredentialData?.wellKnown]);
|
|
|
|
return (
|
|
<React.Fragment>
|
|
{controller.isDisplayingIncomingVC && (
|
|
<Column
|
|
scroll
|
|
padding="24 0 48 0"
|
|
backgroundColor={Theme.Colors.lightGreyBackgroundColor}>
|
|
<Column>
|
|
<DeviceInfoList of="sender" deviceInfo={controller.senderInfo} />
|
|
<Text weight="semibold" margin="24 24 0 24">
|
|
{t('header')}
|
|
</Text>
|
|
<VcDetailsContainer
|
|
fields={fields}
|
|
wellknown={wellknown}
|
|
credential={credential}
|
|
credentialWrapper={controller.credential}
|
|
verifiableCredentialData={verifiableCredentialData}
|
|
isBindingPending={false}
|
|
activeTab={1}
|
|
vcHasImage={profileImage !== undefined}
|
|
svgTemplate={svgTemplate}
|
|
svgRendererError={svgRendererError}
|
|
loadingSvg={loadingSvg}
|
|
/>
|
|
</Column>
|
|
<Column padding="0 24" margin="32 0 0 0">
|
|
<Button
|
|
title={t('goToReceivedVCTab')}
|
|
margin="0 0 12 0"
|
|
type="gradient"
|
|
onPress={controller.GO_TO_RECEIVED_VC_TAB}
|
|
/>
|
|
</Column>
|
|
</Column>
|
|
)}
|
|
|
|
<MessageOverlay
|
|
isVisible={savingOverlayVisible}
|
|
message={t('saving')}
|
|
progress={true}
|
|
/>
|
|
|
|
<SharingStatusModal
|
|
isVisible={controller.isSavingFailedInIdle}
|
|
testId={'savingFailedError'}
|
|
image={SvgImage.ErrorLogo()}
|
|
title={t('errors.savingFailed.title')}
|
|
message={t('errors.savingFailed.message')}
|
|
gradientButtonTitle={t('common:ok')}
|
|
onGradientButton={controller.RESET}
|
|
/>
|
|
</React.Fragment>
|
|
);
|
|
};
|