1- import { Button } from '@chakra-ui/react'
2- import {
3- Table ,
4- TableCaption ,
5- TableContainer ,
6- Tbody ,
7- Thead ,
8- Tr ,
9- } from '@chakra-ui/table'
1+ import { Button , Table } from '@chakra-ui/react'
102import React from "react"
3+ import { toaster } from "./ui/toast"
114
125import { withAuth , withData } from "../hoc"
136import {
@@ -25,7 +18,7 @@ class BaseResources<T> extends React.Component<ITableResourceProps<T>, IActionSt
2518 }
2619
2720 render ( ) {
28- const { data, name, headers : Headers , row : Row , title , user} = this . props
21+ const { data, name, headers : Headers , row : Row , user} = this . props
2922 const rows = data . state . data ?. [ name ]
3023 const { user : userData } = user . state || { }
3124 const { login} = userData || { }
@@ -35,30 +28,36 @@ class BaseResources<T> extends React.Component<ITableResourceProps<T>, IActionSt
3528 }
3629
3730 if ( ! rows || ! Array . isArray ( rows ) ) {
38- return < Button onClick = { ( ) => this . updateResources ( ) } > Update { name } </ Button >
31+ return (
32+ < Button
33+ variant = "subtle"
34+ onClick = { ( ) => this . updateResources ( ) } >
35+ Update { name }
36+ </ Button > )
3937 }
4038
4139 return (
4240 < >
43- < Button onClick = { ( ) => this . updateResources ( ) } > Update { name } </ Button >
44- < TableContainer >
45- < Table variant = "simple" >
46- < TableCaption > { title } </ TableCaption >
47- < Thead >
48- < Tr >
49- < Headers />
50- </ Tr >
51- </ Thead >
52- < Tbody >
53- { rows . map ( ( resource , index : number ) => (
54- < Tr key = { index } >
55- < Row resource = { resource as T } />
56- </ Tr >
57- ) ) }
58- </ Tbody >
59- </ Table >
60- </ TableContainer >
61- </ >
41+ < Button
42+ variant = "subtle"
43+ onClick = { ( ) => this . updateResources ( ) } >
44+ Update { name }
45+ </ Button >
46+ < Table . Root striped >
47+ < Table . Header >
48+ < Table . Row >
49+ < Headers />
50+ </ Table . Row >
51+ </ Table . Header >
52+ < Table . Body >
53+ { rows . map ( ( resource , index : number ) => (
54+ < Table . Row key = { index } >
55+ < Row resource = { resource as T } />
56+ </ Table . Row >
57+ ) ) }
58+ </ Table . Body >
59+ </ Table . Root >
60+ </ >
6261 )
6362 }
6463
@@ -79,6 +78,12 @@ class BaseResources<T> extends React.Component<ITableResourceProps<T>, IActionSt
7978 type : 'UPDATE' ,
8079 payload,
8180 } )
81+ toaster . create ( {
82+ description : `Updated: ${ name } ` ,
83+ type : "info" ,
84+ closable : true ,
85+ duration : 3000 ,
86+ } )
8287 } catch ( error ) {
8388 const e = error as Record < 'message' , string >
8489 this . setState ( {
0 commit comments