forked from FilOzone/filecoin-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolumn-definition.tsx
More file actions
82 lines (77 loc) · 2.31 KB
/
Copy pathcolumn-definition.tsx
File metadata and controls
82 lines (77 loc) · 2.31 KB
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
80
81
82
import { ID } from '@filecoin-foundation/ui-filecoin/Table/ID'
import { createColumnHelper } from '@tanstack/react-table'
import { CompactPeerID } from '@/components/compact-peer-id'
import { PdpScanLink } from '@/components/PdpScanLink'
import { ProviderOverview } from '@/components/ProviderOverview'
import { SoftwareVersion } from '@/components/SoftwareVersion'
import { locationFilterFn } from '@/app/service-providers/utils/service-provider-filters'
import type { ServiceProvider } from '@/schemas/provider-schema'
import { sortSoftwareVersion } from '@/utils/sort-software-version'
const columnHelper = createColumnHelper<ServiceProvider>()
export const columns = [
columnHelper.accessor('id', {
header: 'ID',
cell: (info) => <ID number={info.getValue()} />,
sortingFn: 'basic',
}),
columnHelper.accessor((row) => row.name, {
id: 'provider',
header: 'Provider',
cell: (info) => {
const {
name,
description,
serviceProviderAddress,
serviceUrl,
isEndorsed,
} = info.row.original
return (
<ProviderOverview
name={name}
description={description}
address={serviceProviderAddress}
serviceUrl={serviceUrl}
isEndorsed={isEndorsed}
/>
)
},
sortingFn: 'alphanumeric',
}),
columnHelper.accessor('softwareVersion', {
header: 'Version',
cell: (info) => {
const softwareVersion = info.getValue()
return softwareVersion ? <SoftwareVersion info={softwareVersion} /> : '-'
},
sortingFn: sortSoftwareVersion,
sortUndefined: 'last',
}),
columnHelper.accessor('checkActivityUrl', {
header: 'Check Activity',
cell: (info) => (
<PdpScanLink
pdpScanUrl={info.getValue()}
providerName={info.row.original.name}
/>
),
enableSorting: false,
}),
columnHelper.accessor('location', {
header: 'Location',
cell: (info) => info.getValue(),
sortingFn: 'text',
sortUndefined: 'last',
filterFn: locationFilterFn,
}),
columnHelper.accessor('peerId', {
id: 'peerId',
header: 'Peer ID',
cell: (info) => {
const peerId = info.getValue()
if (!peerId) return <span>-</span>
return <CompactPeerID peerId={peerId} />
},
sortingFn: 'alphanumeric',
sortUndefined: 'last',
}),
]