@@ -4,6 +4,7 @@ import { FaShare } from 'react-icons/fa';
4
4
import { useTranslation } from 'react-i18next' ;
5
5
import StatusRibbon from '../../components/Credentials/StatusRibbon' ;
6
6
import { useApi } from '../../api' ;
7
+ import { parseCredentialDependingOnFormat } from '../../components/Credentials/ApiFetchCredential' ;
7
8
8
9
9
10
function SelectCredentials ( { showPopup, setShowPopup, setSelectionMap, conformantCredentialsMap, verifierDomainName } ) {
@@ -20,7 +21,6 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
20
21
const [ renderContent , setRenderContent ] = useState ( showRequestedFields ) ;
21
22
const [ applyTransition , setApplyTransition ] = useState ( false ) ;
22
23
23
-
24
24
useEffect ( ( ) => {
25
25
const getData = async ( ) => {
26
26
if ( currentIndex == Object . keys ( conformantCredentialsMap ) . length ) {
@@ -31,13 +31,18 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
31
31
32
32
try {
33
33
const response = await api . get ( '/storage/vc' ) ;
34
- const simplifiedCredentials = response . data . vc_list
34
+ const simplifiedCredentialsPromises = response . data . vc_list
35
35
. filter ( vc => conformantCredentialsMap [ keys [ currentIndex ] ] . credentials . includes ( vc . credentialIdentifier ) )
36
- . map ( vc => ( {
37
- id : vc . credentialIdentifier ,
38
- imageURL : vc . logoURL ,
39
- } ) ) ;
40
- console . log ( "FIelds = " , conformantCredentialsMap [ keys [ currentIndex ] ] . requestedFields )
36
+ . map ( async vc => {
37
+ const credentialPayload = await parseCredentialDependingOnFormat ( vc . credential , vc . format ) ;
38
+ return ( {
39
+ id : vc . credentialIdentifier ,
40
+ imageURL : vc . logoURL ,
41
+ expdate : credentialPayload [ 'vc' ] [ "expirationDate" ] ,
42
+ } )
43
+ } ) ;
44
+ const simplifiedCredentials = await Promise . all ( simplifiedCredentialsPromises ) ;
45
+ console . log ( "Fields = " , conformantCredentialsMap [ keys [ currentIndex ] ] . requestedFields )
41
46
setRequestedFields ( conformantCredentialsMap [ keys [ currentIndex ] ] . requestedFields ) ;
42
47
setImages ( simplifiedCredentials ) ;
43
48
} catch ( error ) {
0 commit comments