@@ -17,6 +17,59 @@ import {
17
17
import { useAuth } from "../../providers/AuthProvider" ;
18
18
import { useQueryClient } from "../../providers/QueryClientProvider" ;
19
19
import { ConnectionStatus , useWallet } from "../../providers/WalletProvider" ;
20
+ import * as SectionedTable from "../SectionedTable/SectionedTable" ;
21
+ import AppButton from "../common/Buttons/AppButton" ;
22
+
23
+ interface DummyTableItem {
24
+ identity : {
25
+ name : string ;
26
+ role : string ;
27
+ } ;
28
+ value : string ;
29
+ }
30
+
31
+ const dummyTableItems : SectionedTable . SectionItem < DummyTableItem > [ ] = [
32
+ {
33
+ titleId : "AppSideBar.navigation.overview" ,
34
+ className : cn ( "bg-likecoin-secondarygreen" , "text-likecoin-green" ) ,
35
+ items : [
36
+ {
37
+ identity : {
38
+ name : "John Doe" ,
39
+ role : "Developer" ,
40
+ } ,
41
+ value : "NO" ,
42
+ } ,
43
+ {
44
+ identity : {
45
+ name : "Sam Tsui" ,
46
+ role : "Developer" ,
47
+ } ,
48
+ value : "Yes" ,
49
+ } ,
50
+ ] ,
51
+ } ,
52
+ {
53
+ titleId : "AppSideBar.navigation.portfolio" ,
54
+ className : cn ( "bg-[#F0ECDA]" , "text-[#666666]" ) ,
55
+ items : [
56
+ {
57
+ identity : {
58
+ name : "John Doe" ,
59
+ role : "Developer" ,
60
+ } ,
61
+ value : "NO" ,
62
+ } ,
63
+ {
64
+ identity : {
65
+ name : "Sam Tsui" ,
66
+ role : "Developer" ,
67
+ } ,
68
+ value : "Yes" ,
69
+ } ,
70
+ ] ,
71
+ } ,
72
+ ] ;
20
73
21
74
const DummyScreen : React . FC = ( ) => {
22
75
const { setLocale } = useLocale ( ) ;
@@ -25,12 +78,20 @@ const DummyScreen: React.FC = () => {
25
78
const wallet = useWallet ( ) ;
26
79
27
80
const [ profile , setProfile ] = useState < Profile | null > ( null ) ;
81
+ const [ dummyTableSort , setDummyTableSort ] =
82
+ useState < SectionedTable . ColumnOrder | null > ( null ) ;
28
83
29
84
// Fetch block height every 6 seconds (i.e average block time)
30
- const { loading , data, error } = useQuery < TestQueryQuery > ( TestQuery , {
85
+ const { data } = useQuery < TestQueryQuery > ( TestQuery , {
31
86
pollInterval : 6000 ,
32
87
} ) ;
33
88
89
+ const onDummyItemClick = useCallback ( ( item : DummyTableItem ) => {
90
+ return ( ) => {
91
+ console . log ( item ) ;
92
+ } ;
93
+ } , [ ] ) ;
94
+
34
95
const [ loadMe , { loading : meLoading , data : meData , error : meError } ] =
35
96
useLazyQuery < MeQueryQuery > ( MeQuery , { } ) ;
36
97
@@ -76,14 +137,6 @@ const DummyScreen: React.FC = () => {
76
137
}
77
138
} , [ setProfile , wallet , desmosQuery ] ) ;
78
139
79
- if ( loading ) {
80
- return < div > Loading...</ div > ;
81
- }
82
-
83
- if ( error ) {
84
- return < div > Failed to fetch data</ div > ;
85
- }
86
-
87
140
return (
88
141
< div
89
142
className = { cn (
@@ -105,9 +158,11 @@ const DummyScreen: React.FC = () => {
105
158
>
106
159
< LocalizedText messageID = "App.title" />
107
160
108
- < h1 >
109
- Block Height: < span > { data ?. latestBlock ?. height ?? - 1 } </ span >
110
- </ h1 >
161
+ { data && (
162
+ < h1 >
163
+ Block Height: < span > { data . latestBlock ?. height ?? - 1 } </ span >
164
+ </ h1 >
165
+ ) }
111
166
</ div >
112
167
< div className = { cn ( "flex" , "flex-col" , "gap-y-5" ) } >
113
168
< button
@@ -244,6 +299,47 @@ const DummyScreen: React.FC = () => {
244
299
{ meData && < div > Signed In As: { meData . me } </ div > }
245
300
246
301
{ meError && < div > Failed to sign in: { meError . message } </ div > }
302
+
303
+ < SectionedTable . Table
304
+ sections = { dummyTableItems }
305
+ sortOrder = { dummyTableSort ?? undefined }
306
+ onSort = { setDummyTableSort }
307
+ >
308
+ < SectionedTable . Column < DummyTableItem >
309
+ id = "title"
310
+ titleId = "App.title"
311
+ sortable = { true }
312
+ >
313
+ { ( item ) => (
314
+ < div className = { cn ( "flex" , "flex-col" , "gap-y-2" ) } >
315
+ < span className = { cn ( "font-bold" ) } > { item . identity . name } </ span >
316
+ < span > { item . identity . role } </ span >
317
+ </ div >
318
+ ) }
319
+ </ SectionedTable . Column >
320
+ < SectionedTable . Column < DummyTableItem >
321
+ id = "name"
322
+ titleId = "App.title"
323
+ sortable = { true }
324
+ >
325
+ { ( item ) => (
326
+ < span className = { cn ( "text-likecoin-green" ) } > { item . value } </ span >
327
+ ) }
328
+ </ SectionedTable . Column >
329
+ < SectionedTable . Column < DummyTableItem >
330
+ id = "action"
331
+ className = { cn ( "text-right" ) }
332
+ >
333
+ { ( item ) => (
334
+ < AppButton
335
+ theme = "primary"
336
+ size = "regular"
337
+ messageID = "AppSideBar.title"
338
+ onClick = { onDummyItemClick ( item ) }
339
+ />
340
+ ) }
341
+ </ SectionedTable . Column >
342
+ </ SectionedTable . Table >
247
343
</ div >
248
344
) ;
249
345
} ;
0 commit comments