-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.tsx
70 lines (62 loc) · 2.85 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
import React from 'react'
import { MetaNode } from '@/spec/metanode'
import { z } from 'zod'
const MetGeneSummaryObjC = z.object({
Pathways: z.number(),
Reactions: z.number(),
Metabolites: z.number(),
Studies: z.number(),
Genes: z.string(),
});
export type MetGeneSummaryObj = z.infer<typeof MetGeneSummaryObjC>
// important ref: https://rsinohara.github.io/json-to-zod-react/
// array of objects: [{}]
export const MetGeneSummaryObjArrayC = z.array(
MetGeneSummaryObjC
)
export type MetGeneSummaryObjArray = z.infer<typeof MetGeneSummaryObjArrayC>
// A unique name for your data type is used here
export const MetGeneSummaryTable = MetaNode('MetGeneSummaryTable')
// Human readble descriptors about this node should go here
.meta({
label: 'Metgene Summary Table',
description: 'Metgene Summary Table comprises of the number of pathways, reactions, metabolites and studies corresponding to the given gene.',
external: true,
})
// 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(MetGeneSummaryObjArrayC)
// react component rendering your data goes here
.view(data => {
const heading1 = "Gene"
const heading2 = "Pathways"
const heading3 = "Reactions"
const heading4 = "Metabolites"
const heading5 = "Studies"
return (
<div className="prose max-w-none">
<h2>MetGENE Summary</h2>
<table>
<tr>
<th>{heading1}</th>
<th>{heading2}</th>
<th>{heading3}</th>
<th>{heading4}</th>
<th>{heading5}</th>
</tr>
{data.map((val : MetGeneSummaryObj, key : number) => {
return (
<tr key={key}>
<td><a href = {`https://bdcw.org/MetGENE/geneInfo.php?species=hsa&GeneIDType=SYMBOL&anatomy=NA&disease=NA&phenotype=NA&GeneInfoStr=${val.Genes}`} target = "_blank">{val.Genes}</a></td>
<td><a href = {`https://bdcw.org/MetGENE/pathways.php?species=hsa&GeneIDType=SYMBOL&anatomy=NA&disease=NA&phenotype=NA&GeneInfoStr=${val.Genes}`} target = "_blank">{val.Pathways}</a></td>
<td><a href = {`https://bdcw.org/MetGENE/reactions.php?species=hsa&GeneIDType=SYMBOL&anatomy=NA&disease=NA&phenotype=NA&GeneInfoStr=${val.Genes}`} target = "_blank">{val.Reactions}</a></td>
<td><a href = {`https://bdcw.org/MetGENE/metabolites.php?species=hsa&GeneIDType=SYMBOL&anatomy=NA&disease=NA&phenotype=NA&GeneInfoStr=${val.Genes}`} target = "_blank">{val.Metabolites}</a></td>
<td><a href = {`https://bdcw.org/MetGENE/studies.php?species=hsa&GeneIDType=SYMBOL&anatomy=NA&disease=NA&phenotype=NA&GeneInfoStr=${val.Genes}`} target = "_blank">{val.Studies}</a></td>
</tr>
)
})}
</table>
</div>
)
})
.build()