-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.tsx
79 lines (70 loc) · 2.39 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react'
import { MetaNode } from '@/spec/metanode'
import { z } from 'zod'
import { additional_info_icon } from '@/icons';
// Mano: 2023/08/01: adding more fields and making some optional
const MetSummaryObjC = z.object({
name: z.string().optional(),
refmet_name: z.string().optional(),
pubchem_cid: z.string().optional(),
inchi_key: z.string().optional(),
exactmass: z.string().optional(),
formula: z.string().optional(),
super_class: z.string().optional(),
main_class: z.string().optional(),
sub_class: z.string().optional(),
});
export type MetSummaryObj = z.infer<typeof MetSummaryObjC>
export const MetSummaryObjArrayC = z.array(
MetSummaryObjC
)
export type MetSummaryObjArray = z.infer<typeof MetSummaryObjArrayC>
// A unique name for your data type is used here
export const MetaboliteSummary = MetaNode('MetaboliteSummary')
// Human readble descriptors about this node should go here
.meta({
label: 'Metabolite Summary',
description: 'Metabolite Summary, rendered',
icon: [additional_info_icon],
})
// this should have a codec which can encode or decode the data type represented by this node
// using zod, a compile-time and runtime type-safe codec can be constructed
.codec(MetSummaryObjArrayC)
// react component rendering your data goes here
.view(data => {
//var data1 = [data];
return (
//<div>{JSON.stringify(data)}</div>
<div className="prose max-w-none">
<h2>Metabolite Summary</h2>
<table>
<th> Name </th>
<th> RefMet Name </th>
<th> PubChem CID</th>
<th> Exact Mass</th>
<th> Formula </th>
<th> Super class </th>
<th> Main class </th>
<th> Sub class </th>
<th> InChI</th>
{data.map((val: MetSummaryObj, i: number) => {
//window.alert(val); // console.log(val) // //window.alert(dataobj[0]);
return (
<tr key={i}>
<td>{val.name}</td>
<td>{val.refmet_name}</td>
<td>{val.pubchem_cid}</td>
<td>{val.exactmass}</td>
<td>{val.formula}</td>
<td>{val.super_class}</td>
<td>{val.sub_class}</td>
<td>{val.main_class}</td>
<td>{val.inchi_key}</td>
</tr>
)
})}
</table>
</div>
)
})
.build()