@velocitycareerlabs/vc-renderer-sample 1.25.0-dev-build.158b56827
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +128 -0
- package/LICENSE +248 -0
- package/README.md +46 -0
- package/package.json +62 -0
- package/public/index.html +40 -0
- package/public/vite.svg +1 -0
- package/src/App.css +5 -0
- package/src/App.tsx +396 -0
- package/src/assets/index.tsx +5 -0
- package/src/assets/logo192.png +0 -0
- package/src/assets/regular-share-blue.svg +3 -0
- package/src/assets/round-share-black.svg +4 -0
- package/src/assets/trash.svg +4 -0
- package/src/components/PDFReport/index.tsx +248 -0
- package/src/components/Sidebar/index.tsx +61 -0
- package/src/components/SummaryFooter/index.tsx +23 -0
- package/src/components/VcDetailsFooter/index.tsx +15 -0
- package/src/index.css +13 -0
- package/src/index.tsx +13 -0
- package/src/mocks/credentials.tsx +769 -0
- package/src/mocks/credentialsMapped.tsx +520 -0
- package/src/mocks/descriptors.tsx +799 -0
- package/src/mocks/index.tsx +7 -0
- package/src/mocks/issuers.tsx +69 -0
- package/src/mocks/status.tsx +8 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/setupTests.ts +5 -0
- package/tsconfig.json +25 -0
package/src/App.tsx
ADDED
@@ -0,0 +1,396 @@
|
|
1
|
+
/* eslint-disable better-mutation/no-mutation */
|
2
|
+
import { useCallback, useState } from 'react';
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
4
|
+
import {
|
5
|
+
VcsSummaryRenderer,
|
6
|
+
VcDetailsRenderer,
|
7
|
+
} from '@velocitycareerlabs/vc-renderer';
|
8
|
+
import { Typography, Box, Button } from '@mui/material';
|
9
|
+
import { pdf } from '@react-pdf/renderer';
|
10
|
+
import { Sidebar } from './components/Sidebar';
|
11
|
+
import { SummaryFooter } from './components/SummaryFooter';
|
12
|
+
import { VcDetailsFooter } from './components/VcDetailsFooter';
|
13
|
+
import {
|
14
|
+
PdfCredentialDetailsVcPrepared,
|
15
|
+
PdfCredentialsDetailsVcPrepared,
|
16
|
+
PdfCredentialDetailsVcRaw,
|
17
|
+
PdfCredentialsDetailsVcsRaw,
|
18
|
+
PdfCredentialDetailsVcPreparedMissingData,
|
19
|
+
PdfCredentialsDetailsVcPreparedMissingData,
|
20
|
+
PdfCredentialsDetailsVcsRawMissingData,
|
21
|
+
} from './components/PDFReport';
|
22
|
+
import {
|
23
|
+
CREDENTIALS,
|
24
|
+
ISSUERS,
|
25
|
+
DESCRIPTORS,
|
26
|
+
CREDENTIALS_MAPPED,
|
27
|
+
STATUS,
|
28
|
+
} from './mocks';
|
29
|
+
import './App.css';
|
30
|
+
|
31
|
+
const App = () => {
|
32
|
+
const [vcsSelected, setVcsSelected] = useState<Record<string, boolean>>({});
|
33
|
+
|
34
|
+
const handleSelectMapped = useCallback((vcId?: string) => {
|
35
|
+
setVcsSelected((prev) => {
|
36
|
+
if (!vcId) return prev;
|
37
|
+
if (prev[vcId]) {
|
38
|
+
delete prev[vcId];
|
39
|
+
|
40
|
+
return { ...prev };
|
41
|
+
}
|
42
|
+
|
43
|
+
return { ...prev, [vcId]: true };
|
44
|
+
});
|
45
|
+
}, []);
|
46
|
+
|
47
|
+
const printVc = async (Component: any) => {
|
48
|
+
const blob = await pdf(Component).toBlob();
|
49
|
+
const iframe: HTMLIFrameElement = document.createElement('iframe');
|
50
|
+
document.body.appendChild(iframe);
|
51
|
+
iframe.style.display = 'none';
|
52
|
+
iframe.src = URL.createObjectURL(blob);
|
53
|
+
iframe.onload = () => {
|
54
|
+
setTimeout(() => {
|
55
|
+
iframe.focus();
|
56
|
+
const contectWindow = iframe?.contentWindow;
|
57
|
+
if (contectWindow) {
|
58
|
+
contectWindow.print();
|
59
|
+
}
|
60
|
+
}, 1);
|
61
|
+
};
|
62
|
+
};
|
63
|
+
|
64
|
+
return (
|
65
|
+
<div className="App">
|
66
|
+
<Typography variant="h6" pt={8} mb={1}>
|
67
|
+
Using vcsPrepared
|
68
|
+
</Typography>
|
69
|
+
<Box sx={[styles.demoContainer, styles.containerSize2]}>
|
70
|
+
<VcsSummaryRenderer
|
71
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
72
|
+
vcsData={{ vcsPrepared: CREDENTIALS_MAPPED }}
|
73
|
+
vcsStatus={STATUS}
|
74
|
+
vcsRecentlyAdded={{ '6703a5192f771a68797aceb1': true }}
|
75
|
+
onSelect={handleSelectMapped}
|
76
|
+
vcsSelected={vcsSelected}
|
77
|
+
/>
|
78
|
+
</Box>
|
79
|
+
<Typography variant="h6" pt={8} mb={1}>
|
80
|
+
Using vcsPrepared + Footer
|
81
|
+
</Typography>
|
82
|
+
<Box sx={[styles.demoContainer, styles.containerSize2]}>
|
83
|
+
<VcsSummaryRenderer
|
84
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
85
|
+
vcsData={{ vcsPrepared: CREDENTIALS_MAPPED }}
|
86
|
+
vcsStatus={STATUS}
|
87
|
+
onSelect={handleSelectMapped}
|
88
|
+
vcsSelected={vcsSelected}
|
89
|
+
Footer={SummaryFooter}
|
90
|
+
/>
|
91
|
+
</Box>
|
92
|
+
<Typography variant="h6" pt={8} mb={1}>
|
93
|
+
Using vcsPrepared + Styles
|
94
|
+
</Typography>
|
95
|
+
<Box sx={[styles.demoContainer, styles.containerSize2]}>
|
96
|
+
<VcsSummaryRenderer
|
97
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
98
|
+
vcsData={{ vcsPrepared: CREDENTIALS_MAPPED }}
|
99
|
+
vcsStatus={STATUS}
|
100
|
+
onSelect={handleSelectMapped}
|
101
|
+
vcsSelected={vcsSelected}
|
102
|
+
style={styles.overriddenStyle}
|
103
|
+
/>
|
104
|
+
</Box>
|
105
|
+
<Typography variant="h6" pt={8}>
|
106
|
+
Using raw data
|
107
|
+
</Typography>
|
108
|
+
<VcsSummaryRenderer
|
109
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
110
|
+
vcsData={{
|
111
|
+
vcs: CREDENTIALS,
|
112
|
+
descriptors: DESCRIPTORS,
|
113
|
+
issuers: ISSUERS,
|
114
|
+
}}
|
115
|
+
vcsStatus={STATUS}
|
116
|
+
isSelectable={false}
|
117
|
+
/>
|
118
|
+
<Typography variant="h6" pt={8} color="red">
|
119
|
+
Using raw data. Missing Descriptors
|
120
|
+
</Typography>
|
121
|
+
<VcsSummaryRenderer
|
122
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
123
|
+
vcsData={{ vcs: CREDENTIALS, descriptors: {}, issuers: ISSUERS }}
|
124
|
+
vcsStatus={STATUS}
|
125
|
+
isSelectable={false}
|
126
|
+
/>
|
127
|
+
<Typography variant="h6" pt={8} color="red">
|
128
|
+
Using raw data. Missing Issuers
|
129
|
+
</Typography>
|
130
|
+
<VcsSummaryRenderer
|
131
|
+
onClick={(id) => alert(`credential id: ${id}`)}
|
132
|
+
vcsData={{ vcs: CREDENTIALS, descriptors: DESCRIPTORS, issuers: {} }}
|
133
|
+
vcsStatus={STATUS}
|
134
|
+
isSelectable={false}
|
135
|
+
/>
|
136
|
+
<Typography variant="h6" pt={8}>
|
137
|
+
Credential Details: Assessments. Using vcsPrepared{' '}
|
138
|
+
</Typography>
|
139
|
+
<VcDetailsRenderer
|
140
|
+
categoryTitle="Assessments"
|
141
|
+
vcData={{ vcPrepared: CREDENTIALS_MAPPED[0] }}
|
142
|
+
/>
|
143
|
+
|
144
|
+
<Typography variant="h6" pt={8}>
|
145
|
+
Credential Details: Assessments. Using Raw Data{' '}
|
146
|
+
</Typography>
|
147
|
+
<VcDetailsRenderer
|
148
|
+
categoryTitle="Assessments"
|
149
|
+
vcData={{
|
150
|
+
vc: CREDENTIALS[0],
|
151
|
+
descriptor: DESCRIPTORS['AssessmentV1.1'],
|
152
|
+
issuer:
|
153
|
+
ISSUERS['did:ion:EiBMsw27IKRYIdwUOfDeBd0LnWVeG2fPxxJi9L1fvjM20g'],
|
154
|
+
}}
|
155
|
+
/>
|
156
|
+
|
157
|
+
<Typography variant="h6" pt={8}>
|
158
|
+
Credential Details: Assessments. Using Raw Data outside of
|
159
|
+
credentialSubject. Relative to credential root.
|
160
|
+
</Typography>
|
161
|
+
<VcDetailsRenderer
|
162
|
+
categoryTitle="Assessments"
|
163
|
+
vcData={{
|
164
|
+
vc: CREDENTIALS[7],
|
165
|
+
descriptor: DESCRIPTORS['AssessmentV1.1'],
|
166
|
+
issuer:
|
167
|
+
ISSUERS['did:ion:EiBMsw27IKRYIdwUOfDeBd0LnWVeG2fPxxJi9L1fvjM20g'],
|
168
|
+
}}
|
169
|
+
/>
|
170
|
+
|
171
|
+
<Typography variant="h6" pt={8}>
|
172
|
+
Credential Details: Badges & Achievements. Using vcsPrepared + Footer{' '}
|
173
|
+
</Typography>
|
174
|
+
<VcDetailsRenderer
|
175
|
+
categoryTitle="Badges & Achievements"
|
176
|
+
vcData={{ vcPrepared: CREDENTIALS_MAPPED[2] }}
|
177
|
+
Footer={VcDetailsFooter}
|
178
|
+
/>
|
179
|
+
|
180
|
+
<Typography variant="h6" pt={8}>
|
181
|
+
Credential Details: Contacts. Using vcsPrepared{' '}
|
182
|
+
</Typography>
|
183
|
+
<VcDetailsRenderer
|
184
|
+
categoryTitle="Contacts"
|
185
|
+
vcData={{ vcPrepared: CREDENTIALS_MAPPED[1] }}
|
186
|
+
/>
|
187
|
+
|
188
|
+
<Typography variant="h6" pt={8}>
|
189
|
+
Credential Details: Contacts. Using vcsPrepared + Footer
|
190
|
+
</Typography>
|
191
|
+
<VcDetailsRenderer
|
192
|
+
categoryTitle="Contacts"
|
193
|
+
vcData={{ vcPrepared: CREDENTIALS_MAPPED[1] }}
|
194
|
+
Footer={VcDetailsFooter}
|
195
|
+
/>
|
196
|
+
|
197
|
+
<Typography variant="h6" pt={8}>
|
198
|
+
Credential Details: Contacts. Using Raw Data + Footer{' '}
|
199
|
+
</Typography>
|
200
|
+
<VcDetailsRenderer
|
201
|
+
categoryTitle="Contacts"
|
202
|
+
vcData={{
|
203
|
+
vc: CREDENTIALS[1],
|
204
|
+
descriptor: DESCRIPTORS['EmailV1.0'],
|
205
|
+
issuer:
|
206
|
+
ISSUERS['did:ion:EiAehWmpX5mHBuc93SIhPXF8bsEx68G6mPcdIaLNGbozPA'],
|
207
|
+
}}
|
208
|
+
Footer={VcDetailsFooter}
|
209
|
+
/>
|
210
|
+
|
211
|
+
<Typography variant="h6" pt={8}>
|
212
|
+
Credential Details: Contacts. Using Raw Data + style
|
213
|
+
</Typography>
|
214
|
+
<VcDetailsRenderer
|
215
|
+
categoryTitle="Contacts"
|
216
|
+
vcData={{
|
217
|
+
vc: CREDENTIALS[1],
|
218
|
+
descriptor: DESCRIPTORS['EmailV1.0'],
|
219
|
+
issuer:
|
220
|
+
ISSUERS['did:ion:EiAehWmpX5mHBuc93SIhPXF8bsEx68G6mPcdIaLNGbozPA'],
|
221
|
+
}}
|
222
|
+
style={styles.overriddenStyle2}
|
223
|
+
/>
|
224
|
+
|
225
|
+
<Typography variant="h6" pt={8}>
|
226
|
+
Credential Details: Badge. Using Raw Data + Footer{' '}
|
227
|
+
</Typography>
|
228
|
+
<VcDetailsRenderer
|
229
|
+
categoryTitle="Badges & Achievements"
|
230
|
+
vcData={{
|
231
|
+
vc: CREDENTIALS[2],
|
232
|
+
descriptor: DESCRIPTORS.OpenBadgeCredential,
|
233
|
+
issuer:
|
234
|
+
ISSUERS['did:ion:EiBMsw27IKRYIdwUOfDeBd0LnWVeG2fPxxJi9L1fvjM20g'],
|
235
|
+
}}
|
236
|
+
Footer={VcDetailsFooter}
|
237
|
+
/>
|
238
|
+
|
239
|
+
<Typography variant="h6" pt={8}>
|
240
|
+
Credential Details: Employment History. Using Raw Data + Sidebar{' '}
|
241
|
+
</Typography>
|
242
|
+
<VcDetailsRenderer
|
243
|
+
categoryTitle="Employment History"
|
244
|
+
vcData={{
|
245
|
+
vc: CREDENTIALS[3],
|
246
|
+
descriptor: DESCRIPTORS['EmploymentPastV1.1'],
|
247
|
+
issuer:
|
248
|
+
ISSUERS['did:ion:EiBMsw27IKRYIdwUOfDeBd0LnWVeG2fPxxJi9L1fvjM20g'],
|
249
|
+
}}
|
250
|
+
Sidebar={Sidebar}
|
251
|
+
/>
|
252
|
+
|
253
|
+
<Typography variant="h6" pt={8} color="red">
|
254
|
+
Credential Details: Employment History. Using Raw Data. Missing
|
255
|
+
Descriptor{' '}
|
256
|
+
</Typography>
|
257
|
+
<VcDetailsRenderer
|
258
|
+
categoryTitle="Employment History"
|
259
|
+
vcData={{
|
260
|
+
vc: CREDENTIALS[3],
|
261
|
+
descriptor: {},
|
262
|
+
issuer:
|
263
|
+
ISSUERS['did:ion:EiBMsw27IKRYIdwUOfDeBd0LnWVeG2fPxxJi9L1fvjM20g'],
|
264
|
+
}}
|
265
|
+
/>
|
266
|
+
|
267
|
+
<Typography variant="h6" pt={8} color="red">
|
268
|
+
Credential Details: Employment History. Using Raw Data. Missing Issuer{' '}
|
269
|
+
</Typography>
|
270
|
+
<VcDetailsRenderer
|
271
|
+
categoryTitle="Employment History"
|
272
|
+
vcData={{
|
273
|
+
vc: CREDENTIALS[3],
|
274
|
+
descriptor: DESCRIPTORS['EmploymentPastV1.1'],
|
275
|
+
issuer:
|
276
|
+
ISSUERS['did:ion:EiAehWmpX5mHBuc93SIhPXF8bsEx68G6mPcdIaLNGbozPA'],
|
277
|
+
}}
|
278
|
+
/>
|
279
|
+
|
280
|
+
<Typography variant="h6" pt={8}>
|
281
|
+
Printable. Using vcsPrepared
|
282
|
+
</Typography>
|
283
|
+
|
284
|
+
<Button
|
285
|
+
onClick={() => printVc(<PdfCredentialDetailsVcPrepared />)}
|
286
|
+
variant="contained"
|
287
|
+
>
|
288
|
+
Print Credentail Details
|
289
|
+
</Button>
|
290
|
+
<Button
|
291
|
+
onClick={() => printVc(<PdfCredentialsDetailsVcPrepared />)}
|
292
|
+
variant="contained"
|
293
|
+
sx={{ marginLeft: 4 }}
|
294
|
+
>
|
295
|
+
Print Multiple Credentils
|
296
|
+
</Button>
|
297
|
+
|
298
|
+
<Typography variant="h6" pt={8}>
|
299
|
+
Printable. Using Raw Data
|
300
|
+
</Typography>
|
301
|
+
<Button
|
302
|
+
onClick={() => printVc(<PdfCredentialDetailsVcRaw />)}
|
303
|
+
variant="contained"
|
304
|
+
>
|
305
|
+
Print Credentail Details
|
306
|
+
</Button>
|
307
|
+
<Button
|
308
|
+
onClick={() => printVc(<PdfCredentialsDetailsVcsRaw />)}
|
309
|
+
variant="contained"
|
310
|
+
sx={{ marginLeft: 4 }}
|
311
|
+
>
|
312
|
+
Print Multiple Credentails
|
313
|
+
</Button>
|
314
|
+
|
315
|
+
<Typography variant="h6" pt={8}>
|
316
|
+
Printable. Missing Data
|
317
|
+
</Typography>
|
318
|
+
<Button
|
319
|
+
onClick={() => printVc(<PdfCredentialDetailsVcPreparedMissingData />)}
|
320
|
+
variant="contained"
|
321
|
+
>
|
322
|
+
Print Credentail wo header data
|
323
|
+
</Button>
|
324
|
+
<Button
|
325
|
+
onClick={() => printVc(<PdfCredentialsDetailsVcPreparedMissingData />)}
|
326
|
+
variant="contained"
|
327
|
+
sx={{ marginLeft: 4 }}
|
328
|
+
>
|
329
|
+
Print Multiple Credentails wo header data
|
330
|
+
</Button>
|
331
|
+
|
332
|
+
<Typography variant="h6" pt={8}>
|
333
|
+
Printable. Missing Data Raw
|
334
|
+
</Typography>
|
335
|
+
<Button
|
336
|
+
onClick={() => printVc(<PdfCredentialsDetailsVcsRawMissingData />)}
|
337
|
+
variant="contained"
|
338
|
+
>
|
339
|
+
Print Credentail missing data
|
340
|
+
</Button>
|
341
|
+
</div>
|
342
|
+
);
|
343
|
+
};
|
344
|
+
|
345
|
+
export default App;
|
346
|
+
|
347
|
+
const styles = {
|
348
|
+
demoContainer: {
|
349
|
+
marginBottom: '2em',
|
350
|
+
background: 'rgb(244, 244, 244)',
|
351
|
+
padding: '40px',
|
352
|
+
borderRadius: '10px',
|
353
|
+
boxSizing: 'border-box',
|
354
|
+
},
|
355
|
+
containerSize2: {
|
356
|
+
width: '800px',
|
357
|
+
},
|
358
|
+
overriddenStyle: {
|
359
|
+
background: '#190048',
|
360
|
+
padding: '0',
|
361
|
+
borderRadius: '0px',
|
362
|
+
boxSizing: 'border-box',
|
363
|
+
'& > button': {
|
364
|
+
background: '#190048',
|
365
|
+
borderRadius: '0px',
|
366
|
+
padding: '10px',
|
367
|
+
color: '#FFF',
|
368
|
+
fontFamily: 'monospace',
|
369
|
+
'& > div': {
|
370
|
+
borderRadius: '0px',
|
371
|
+
},
|
372
|
+
},
|
373
|
+
},
|
374
|
+
overriddenStyle2: {
|
375
|
+
background: '#190048',
|
376
|
+
padding: '0',
|
377
|
+
borderRadius: '10px',
|
378
|
+
boxSizing: 'border-box',
|
379
|
+
'& div': {
|
380
|
+
background: '#190048',
|
381
|
+
color: '#FFF',
|
382
|
+
},
|
383
|
+
'& img': {
|
384
|
+
maxWidth: '50px',
|
385
|
+
maxHeight: '50px !important',
|
386
|
+
borderRadius: '0px !important',
|
387
|
+
},
|
388
|
+
'& #vcDetailsContent': {
|
389
|
+
padding: '10px',
|
390
|
+
},
|
391
|
+
'& #vcDetailsHeader': {
|
392
|
+
padding: '10px',
|
393
|
+
height: '100px',
|
394
|
+
},
|
395
|
+
},
|
396
|
+
};
|
Binary file
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg width="13" height="14" viewBox="0 0 13 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path d="M4.26083 7.906L8.245 10.294M8.23917 3.706L4.26083 6.094M11.5 2.8C11.5 3.79411 10.7165 4.6 9.75 4.6C8.7835 4.6 8 3.79411 8 2.8C8 1.80589 8.7835 1 9.75 1C10.7165 1 11.5 1.80589 11.5 2.8ZM4.5 7C4.5 7.99411 3.7165 8.8 2.75 8.8C1.7835 8.8 1 7.99411 1 7C1 6.00589 1.7835 5.2 2.75 5.2C3.7165 5.2 4.5 6.00589 4.5 7ZM11.5 11.2C11.5 12.1941 10.7165 13 9.75 13C8.7835 13 8 12.1941 8 11.2C8 10.2059 8.7835 9.4 9.75 9.4C10.7165 9.4 11.5 10.2059 11.5 11.2Z" stroke="#007AFF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
3
|
+
</svg>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg width="52" height="52" viewBox="0 0 52 52" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<rect x="0.5" y="0.499878" width="51" height="51" rx="25.5" stroke="black"/>
|
3
|
+
<path d="M22.3478 27.2079L27.66 30.3919M27.6522 21.6079L22.3478 24.7919M32 20.3999C32 21.7254 30.9553 22.7999 29.6667 22.7999C28.378 22.7999 27.3333 21.7254 27.3333 20.3999C27.3333 19.0744 28.378 17.9999 29.6667 17.9999C30.9553 17.9999 32 19.0744 32 20.3999ZM22.6667 25.9999C22.6667 27.3254 21.622 28.3999 20.3333 28.3999C19.0447 28.3999 18 27.3254 18 25.9999C18 24.6744 19.0447 23.5999 20.3333 23.5999C21.622 23.5999 22.6667 24.6744 22.6667 25.9999ZM32 31.5999C32 32.9254 30.9553 33.9999 29.6667 33.9999C28.378 33.9999 27.3333 32.9254 27.3333 31.5999C27.3333 30.2744 28.378 29.1999 29.6667 29.1999C30.9553 29.1999 32 30.2744 32 31.5999Z" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
4
|
+
</svg>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg width="52" height="52" viewBox="0 0 52 52" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<rect x="0.5" y="0.499878" width="51" height="51" rx="25.5" stroke="#FF3824"/>
|
3
|
+
<path d="M17 19.9999H35M33 19.9999V33.9999C33 34.9999 32 35.9999 31 35.9999H21C20 35.9999 19 34.9999 19 33.9999V19.9999M22 19.9999V17.9999C22 16.9999 23 15.9999 24 15.9999H28C29 15.9999 30 16.9999 30 17.9999V19.9999M24 24.9999V30.9999M28 24.9999V30.9999" stroke="#FF3824" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
4
|
+
</svg>
|
@@ -0,0 +1,248 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Document, Text, StyleSheet } from '@react-pdf/renderer';
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
4
|
+
import { VcRendererPDF } from '@velocitycareerlabs/vc-renderer';
|
5
|
+
import {
|
6
|
+
CREDENTIALS,
|
7
|
+
CREDENTIALS_MAPPED,
|
8
|
+
DESCRIPTORS,
|
9
|
+
ISSUERS,
|
10
|
+
} from '../../mocks';
|
11
|
+
import logo192 from '../../assets/logo192.png';
|
12
|
+
|
13
|
+
const styles = StyleSheet.create({
|
14
|
+
sideBarItem: {
|
15
|
+
fontSize: 8,
|
16
|
+
fontWeight: 500,
|
17
|
+
color: 'rgb(51, 51, 51)',
|
18
|
+
display: 'flex',
|
19
|
+
flexDirection: 'row',
|
20
|
+
gap: 4,
|
21
|
+
},
|
22
|
+
});
|
23
|
+
|
24
|
+
const sidebarItems = [
|
25
|
+
<Text style={styles.sideBarItem}>Issuer verified</Text>,
|
26
|
+
<Text style={styles.sideBarItem}>Data secured</Text>,
|
27
|
+
<Text style={styles.sideBarItem}>Issued to Olivia Hafez</Text>,
|
28
|
+
<Text style={styles.sideBarItem}>Data secured</Text>,
|
29
|
+
<Text style={styles.sideBarItem}>In validity period</Text>,
|
30
|
+
];
|
31
|
+
|
32
|
+
export const PdfCredentialDetailsVcPrepared = () => {
|
33
|
+
return (
|
34
|
+
<Document>
|
35
|
+
<VcRendererPDF
|
36
|
+
vcsData={{ vcsPrepared: [CREDENTIALS_MAPPED[2]] }}
|
37
|
+
applicantName="John Doe"
|
38
|
+
userName="Jane Doe"
|
39
|
+
appLogo={logo192}
|
40
|
+
categoriesTitle={{
|
41
|
+
[CREDENTIALS_MAPPED[2].summary.id]: 'Badges & Achievements',
|
42
|
+
}}
|
43
|
+
vcsStatus={{ [CREDENTIALS_MAPPED[2].summary.id]: 'Revoked' as any }}
|
44
|
+
sidebarItems={{ [CREDENTIALS_MAPPED[2].summary.id]: sidebarItems }}
|
45
|
+
/>
|
46
|
+
</Document>
|
47
|
+
);
|
48
|
+
};
|
49
|
+
|
50
|
+
export const PdfCredentialsDetailsVcPrepared = () => {
|
51
|
+
const categoriesTitle = {
|
52
|
+
[CREDENTIALS_MAPPED[2].summary.id]: 'Badges & Achievements',
|
53
|
+
[CREDENTIALS_MAPPED[1].summary.id]: 'Employment History',
|
54
|
+
[CREDENTIALS_MAPPED[0].summary.id]: 'Assessments',
|
55
|
+
};
|
56
|
+
const vcsStatus = CREDENTIALS_MAPPED.reduce<{ [key: string]: string }>(
|
57
|
+
(acc, vc) => {
|
58
|
+
const { id } = vc.summary;
|
59
|
+
acc[id] = 'Verified';
|
60
|
+
return acc;
|
61
|
+
},
|
62
|
+
{}
|
63
|
+
);
|
64
|
+
|
65
|
+
const sidebarItemsMapped = CREDENTIALS_MAPPED.reduce<{
|
66
|
+
[key: string]: React.ReactNode[];
|
67
|
+
}>((acc, vc) => {
|
68
|
+
const { id } = vc.summary;
|
69
|
+
acc[id] = sidebarItems;
|
70
|
+
return acc;
|
71
|
+
}, {});
|
72
|
+
|
73
|
+
return (
|
74
|
+
<Document>
|
75
|
+
<VcRendererPDF
|
76
|
+
vcsData={{ vcsPrepared: CREDENTIALS_MAPPED }}
|
77
|
+
applicantName="John Doe"
|
78
|
+
userName="Jane Doe"
|
79
|
+
appLogo={logo192}
|
80
|
+
categoriesTitle={categoriesTitle}
|
81
|
+
vcsStatus={vcsStatus as any}
|
82
|
+
sidebarItems={sidebarItemsMapped}
|
83
|
+
/>
|
84
|
+
</Document>
|
85
|
+
);
|
86
|
+
};
|
87
|
+
|
88
|
+
export const PdfCredentialDetailsVcRaw = () => {
|
89
|
+
return (
|
90
|
+
<Document>
|
91
|
+
<VcRendererPDF
|
92
|
+
vcsData={{
|
93
|
+
vcs: [CREDENTIALS[0]],
|
94
|
+
descriptors: DESCRIPTORS,
|
95
|
+
issuers: ISSUERS,
|
96
|
+
}}
|
97
|
+
applicantName="John Doe"
|
98
|
+
userName="Jane Doe"
|
99
|
+
appLogo={logo192}
|
100
|
+
categoriesTitle={{ [CREDENTIALS[0].did]: 'Assessments' }}
|
101
|
+
vcsStatus={{ [CREDENTIALS[0].did]: 'Verified' as any }}
|
102
|
+
sidebarItems={{ [CREDENTIALS[0].did]: sidebarItems }}
|
103
|
+
/>
|
104
|
+
</Document>
|
105
|
+
);
|
106
|
+
};
|
107
|
+
|
108
|
+
export const PdfCredentialsDetailsVcsRaw = () => {
|
109
|
+
const categoriesTitle = {
|
110
|
+
[CREDENTIALS[6].did]: 'Contacts',
|
111
|
+
[CREDENTIALS[5].did]: 'Contacts',
|
112
|
+
[CREDENTIALS[4].did]: 'Documents',
|
113
|
+
[CREDENTIALS[3].did]: 'Employment History',
|
114
|
+
[CREDENTIALS[2].did]: 'Badges & Achievements',
|
115
|
+
[CREDENTIALS[1].did]: 'Contacts',
|
116
|
+
[CREDENTIALS[0].did]: 'Assessments',
|
117
|
+
};
|
118
|
+
const vcsStatus = CREDENTIALS.reduce<{ [key: string]: string }>((acc, vc) => {
|
119
|
+
const { did } = vc;
|
120
|
+
acc[did] = 'Verified';
|
121
|
+
return acc;
|
122
|
+
}, {});
|
123
|
+
|
124
|
+
const sidebarItemsMapped = CREDENTIALS.reduce<{
|
125
|
+
[key: string]: React.ReactNode[];
|
126
|
+
}>((acc, vc) => {
|
127
|
+
const { did } = vc;
|
128
|
+
acc[did] = sidebarItems;
|
129
|
+
return acc;
|
130
|
+
}, {});
|
131
|
+
return (
|
132
|
+
<Document>
|
133
|
+
<VcRendererPDF
|
134
|
+
vcsData={{
|
135
|
+
vcs: CREDENTIALS,
|
136
|
+
descriptors: DESCRIPTORS,
|
137
|
+
issuers: ISSUERS,
|
138
|
+
}}
|
139
|
+
applicantName="John Doe"
|
140
|
+
userName="Jane Doe"
|
141
|
+
appLogo={logo192}
|
142
|
+
categoriesTitle={categoriesTitle}
|
143
|
+
vcsStatus={vcsStatus as any}
|
144
|
+
sidebarItems={sidebarItemsMapped}
|
145
|
+
/>
|
146
|
+
</Document>
|
147
|
+
);
|
148
|
+
};
|
149
|
+
|
150
|
+
export const PdfCredentialDetailsVcPreparedMissingData = () => {
|
151
|
+
// Missing sidebarItems, applicantName, userName, appLogo, for some credentials: vcsStatus and categoriesTitle
|
152
|
+
return (
|
153
|
+
<Document>
|
154
|
+
<VcRendererPDF
|
155
|
+
vcsData={{ vcsPrepared: [CREDENTIALS_MAPPED[2]] }}
|
156
|
+
applicantName=""
|
157
|
+
userName=""
|
158
|
+
appLogo=""
|
159
|
+
categoriesTitle={{
|
160
|
+
[CREDENTIALS_MAPPED[2].summary.id]: 'Badges & Achievements',
|
161
|
+
}}
|
162
|
+
vcsStatus={{ [CREDENTIALS_MAPPED[2].summary.id]: 'Verified' as any }}
|
163
|
+
/>
|
164
|
+
</Document>
|
165
|
+
);
|
166
|
+
};
|
167
|
+
|
168
|
+
export const PdfCredentialsDetailsVcPreparedMissingData = () => {
|
169
|
+
const categoriesTitle = {
|
170
|
+
[CREDENTIALS_MAPPED[2].summary.id]: 'Badges & Achievements',
|
171
|
+
[CREDENTIALS_MAPPED[1].summary.id]: 'Employment History',
|
172
|
+
};
|
173
|
+
const vcsStatus = [CREDENTIALS_MAPPED[1]].reduce<{ [key: string]: string }>(
|
174
|
+
(acc, vc) => {
|
175
|
+
const { id } = vc.summary;
|
176
|
+
acc[id] = 'Verified';
|
177
|
+
return acc;
|
178
|
+
},
|
179
|
+
{}
|
180
|
+
);
|
181
|
+
|
182
|
+
const sidebarItemsMapped = [CREDENTIALS_MAPPED[1]].reduce<{
|
183
|
+
[key: string]: React.ReactNode[];
|
184
|
+
}>((acc, vc) => {
|
185
|
+
const { id } = vc.summary;
|
186
|
+
acc[id] = sidebarItems;
|
187
|
+
return acc;
|
188
|
+
}, {});
|
189
|
+
|
190
|
+
return (
|
191
|
+
<Document>
|
192
|
+
<VcRendererPDF
|
193
|
+
vcsData={{ vcsPrepared: CREDENTIALS_MAPPED }}
|
194
|
+
applicantName=""
|
195
|
+
userName="Jane Doe"
|
196
|
+
appLogo=""
|
197
|
+
categoriesTitle={categoriesTitle}
|
198
|
+
vcsStatus={vcsStatus as any}
|
199
|
+
sidebarItems={sidebarItemsMapped}
|
200
|
+
/>
|
201
|
+
</Document>
|
202
|
+
);
|
203
|
+
};
|
204
|
+
|
205
|
+
export const PdfCredentialsDetailsVcsRawMissingData = () => {
|
206
|
+
const categoriesTitle = {
|
207
|
+
[CREDENTIALS[5].did]: 'Contacts',
|
208
|
+
[CREDENTIALS[4].did]: 'Documents',
|
209
|
+
[CREDENTIALS[3].did]: 'Employment History',
|
210
|
+
[CREDENTIALS[2].did]: 'Badges & Achievements',
|
211
|
+
[CREDENTIALS[1].did]: 'Contacts',
|
212
|
+
};
|
213
|
+
const vcsStatus = [CREDENTIALS[1]].reduce<{ [key: string]: string }>(
|
214
|
+
(acc, vc) => {
|
215
|
+
const { did } = vc;
|
216
|
+
acc[did] = 'Verified';
|
217
|
+
return acc;
|
218
|
+
},
|
219
|
+
{}
|
220
|
+
);
|
221
|
+
|
222
|
+
const sidebarItemsMapped = [CREDENTIALS[1]].reduce<{
|
223
|
+
[key: string]: React.ReactNode[];
|
224
|
+
}>((acc, vc) => {
|
225
|
+
const { did } = vc;
|
226
|
+
acc[did] = sidebarItems;
|
227
|
+
return acc;
|
228
|
+
}, {});
|
229
|
+
|
230
|
+
const oneIssuer = ISSUERS[CREDENTIALS[1].issuer.id];
|
231
|
+
return (
|
232
|
+
<Document>
|
233
|
+
<VcRendererPDF
|
234
|
+
vcsData={{
|
235
|
+
vcs: CREDENTIALS,
|
236
|
+
descriptors: DESCRIPTORS,
|
237
|
+
issuers: oneIssuer,
|
238
|
+
}}
|
239
|
+
applicantName="John Doe"
|
240
|
+
userName="Jane Doe"
|
241
|
+
appLogo={logo192}
|
242
|
+
categoriesTitle={categoriesTitle}
|
243
|
+
vcsStatus={vcsStatus as any}
|
244
|
+
sidebarItems={sidebarItemsMapped}
|
245
|
+
/>
|
246
|
+
</Document>
|
247
|
+
);
|
248
|
+
};
|