@@ -4,7 +4,15 @@ import { getDocumentsList, getUser } from '../../services/auth/auth';
44import { AuthContext } from '../../utils/context/checkToken' ;
55import CommonButton from './button/Button' ;
66import { useTranslation } from 'react-i18next' ;
7- import { Box , Text , Alert , AlertIcon , IconButton , useToast , Progress } from '@chakra-ui/react' ;
7+ import {
8+ Box ,
9+ Text ,
10+ Alert ,
11+ AlertIcon ,
12+ IconButton ,
13+ useToast ,
14+ Progress ,
15+ } from '@chakra-ui/react' ;
816import { ArrowBackIcon } from '@chakra-ui/icons' ;
917
1018// Type definitions for better type safety
@@ -30,6 +38,7 @@ interface UploadPayload {
3038 imported_from : string ;
3139 doc_datatype : string ;
3240 doc_data_link : string ;
41+ issuer ?: string ;
3342}
3443
3544interface ProcessResult {
@@ -118,7 +127,9 @@ const UploadDocumentEwallet = () => {
118127 new URL ( VITE_EWALLET_IFRAME_SRC ) ;
119128 } catch ( error ) {
120129 console . error ( 'Invalid wallet URL configuration:' , error ) ;
121- setError ( 'Invalid wallet URL configuration. Please check your environment variables.' ) ;
130+ setError (
131+ 'Invalid wallet URL configuration. Please check your environment variables.'
132+ ) ;
122133 return ;
123134 }
124135
@@ -134,21 +145,25 @@ const UploadDocumentEwallet = () => {
134145 // Send authentication data to iframe
135146 const sendAuthToIframe = ( ) => {
136147 if ( ! iframeRef . current ) return ;
137-
148+
138149 // Get specific wallet authentication data
139150 const walletToken = localStorage . getItem ( 'walletToken' ) ;
140151 const userStr = localStorage . getItem ( 'user' ) ;
141-
152+
142153 if ( ! walletToken || ! userStr ) {
143- setError ( 'Wallet authentication data not found. Please ensure wallet is properly configured.' ) ;
154+ setError (
155+ 'Wallet authentication data not found. Please ensure wallet is properly configured.'
156+ ) ;
144157 return ;
145158 }
146159
147160 let user ;
148161 try {
149162 user = JSON . parse ( userStr ) ;
150163 } catch {
151- setError ( 'Invalid user data found. Please check wallet configuration.' ) ;
164+ setError (
165+ 'Invalid user data found. Please check wallet configuration.'
166+ ) ;
152167 return ;
153168 }
154169
@@ -239,6 +254,7 @@ const UploadDocumentEwallet = () => {
239254 imported_from : 'e-wallet' ,
240255 doc_datatype : 'Application/JSON' ,
241256 doc_data_link : doc_data_link ,
257+ issuer : 'dhiway' ,
242258 } ,
243259 ] ;
244260 } ;
@@ -268,18 +284,29 @@ const UploadDocumentEwallet = () => {
268284 Failed to Upload:
269285 </ Text >
270286 { failedDocs . map ( ( doc , idx ) => {
271- const showFullError = doc . fullError && doc . error === 'Document type not accepted' ;
287+ const showFullError =
288+ doc . fullError &&
289+ doc . error === 'Document type not accepted' ;
272290 return (
273291 < Box key = { doc . docName ?? idx } ml = { 2 } mb = { 2 } >
274292 < Text color = "red.700" fontWeight = "semibold" >
275293 • { doc . docName }
276294 </ Text >
277295 { showFullError ? (
278- < Text ml = { 4 } fontSize = "sm" mt = { 1 } color = "red.600" >
296+ < Text
297+ ml = { 4 }
298+ fontSize = "sm"
299+ mt = { 1 }
300+ color = "red.600"
301+ >
279302 { doc . fullError }
280303 </ Text >
281304 ) : (
282- < Text ml = { 4 } fontSize = "sm" color = "red.600" >
305+ < Text
306+ ml = { 4 }
307+ fontSize = "sm"
308+ color = "red.600"
309+ >
283310 { doc . error }
284311 </ Text >
285312 ) }
@@ -316,12 +343,19 @@ const UploadDocumentEwallet = () => {
316343 } else {
317344 parsedJson = vc . json ;
318345 }
319- const documentName = parsedJson ?. credentialSchema ?. title ?? 'Unknown document' ;
346+ const documentName =
347+ parsedJson ?. credentialSchema ?. title ?? 'Unknown document' ;
320348 let errorMessage ;
321- if ( docError instanceof Error && docError . message . includes ( 'does not match any of the accepted document types' ) ) {
349+ if (
350+ docError instanceof Error &&
351+ docError . message . includes (
352+ 'does not match any of the accepted document types'
353+ )
354+ ) {
322355 errorMessage = 'Document type not accepted' ;
323356 } else if ( isApiError ( docError ) ) {
324- errorMessage = docError . response ?. data ?. message || 'API error occurred' ;
357+ errorMessage =
358+ docError . response ?. data ?. message || 'API error occurred' ;
325359 } else if ( docError instanceof Error ) {
326360 errorMessage = docError . message ;
327361 } else {
@@ -331,7 +365,7 @@ const UploadDocumentEwallet = () => {
331365 success : false ,
332366 docName : documentName ,
333367 error : errorMessage ,
334- fullError : docError instanceof Error ? docError . message : undefined
368+ fullError : docError instanceof Error ? docError . message : undefined ,
335369 } ;
336370 } ;
337371
@@ -408,23 +442,31 @@ const UploadDocumentEwallet = () => {
408442
409443 // Listen for messages from the iframe
410444 useEffect ( ( ) => {
411- const processingToastIdRef = { current : undefined as string | number | undefined } ;
445+ const processingToastIdRef = {
446+ current : undefined as string | number | undefined ,
447+ } ;
412448
413449 const handleMessage = async ( event : MessageEvent ) => {
414450 if ( event . origin !== VITE_EWALLET_ORIGIN ) return ;
415451
416452 try {
417453 // Type check the event data structure
418454 if ( ! event . data || typeof event . data !== 'object' ) {
419- console . warn ( 'Received invalid message format:' , event . data ) ;
455+ console . warn (
456+ 'Received invalid message format:' ,
457+ event . data
458+ ) ;
420459 return ;
421460 }
422461
423462 const { type, data } = event . data ;
424463 console . log ( 'Received message from wallet:' , type , data ) ;
425464
426465 if ( ! type || typeof type !== 'string' ) {
427- console . warn ( 'Received message without valid type:' , event . data ) ;
466+ console . warn (
467+ 'Received message without valid type:' ,
468+ event . data
469+ ) ;
428470 return ;
429471 }
430472
@@ -442,7 +484,11 @@ const UploadDocumentEwallet = () => {
442484 }
443485 toast ( {
444486 title : 'Error' ,
445- description : ( error instanceof Error ? error . message : undefined ) ?? 'Failed to process documents' ,
487+ description :
488+ ( error instanceof Error
489+ ? error . message
490+ : undefined ) ??
491+ 'Failed to process documents' ,
446492 status : 'error' ,
447493 duration : 5000 ,
448494 isClosable : true ,
@@ -548,7 +594,9 @@ const UploadDocumentEwallet = () => {
548594 setTimeout ( ( ) => sendAuthToIframe ( ) ) ;
549595 } }
550596 onError = { ( ) => {
551- setError ( 'Failed to load wallet interface. Please check your connection and try again.' ) ;
597+ setError (
598+ 'Failed to load wallet interface. Please check your connection and try again.'
599+ ) ;
552600 } }
553601 allow = "camera"
554602 style = { {
@@ -582,7 +630,11 @@ const UploadDocumentEwallet = () => {
582630 textAlign = "center"
583631 maxW = "sm"
584632 >
585- < Text mb = { 4 } fontSize = "lg" fontWeight = "medium" >
633+ < Text
634+ mb = { 4 }
635+ fontSize = "lg"
636+ fontWeight = "medium"
637+ >
586638 Processing Documents...
587639 </ Text >
588640 < Progress
0 commit comments