11import React from 'react' ;
22
3+ import styles from './Landing.module.scss' ;
4+
5+ import logo from './landing.svg' ;
6+ // @ts -ignore
7+ import CrudTable from 'antd-crud-table' ;
38// @ts -ignore
49import { usePersistentState } from 'persistent-state-react' ;
510// @ts -ignore
611import { useFetch } from 'network-react' ;
7- import styles from './Landing.module.scss' ;
812
9- import logo from './landing.svg' ;
1013
11- const Landing = ( ) => {
14+ // Example usage
15+ interface User {
16+ id : number ;
17+ name : string ;
18+ age : number ;
19+ createdAt : string ;
20+ status : 'active' | 'inactive' ;
21+ isAdmin : boolean ;
22+ }
23+
24+ class UserService {
25+ async getList ( params : any ) : Promise < { data : User [ ] ; total : number } > {
26+ // Implementation
27+ // return { data: [], total: 0 };
28+ return {
29+ data : [
30+ { id : 1 , name : 'John Doe' , age : 30 , createdAt : '2023-01-01' , status : 'active' , isAdmin : true } ,
31+ { id : 2 , name : 'Jane Smith' , age : 25 , createdAt : '2023-02-01' , status : 'inactive' , isAdmin : false } ,
32+ ] ,
33+ total : 2 ,
34+ }
35+ }
36+
37+ async create ( data : Partial < User > ) {
38+ // Implementation
39+ return data as User ;
40+ }
41+
42+ async update ( id : number , data : Partial < User > ) {
43+ // Implementation
44+ return { id, ...data } as User ;
45+ }
46+
47+ async delete ( id : number ) {
48+ // Implementation
49+ }
50+ }
51+
52+ const UserTable = ( ) => {
53+
1254 const [ count1 , setCount ] = usePersistentState < number > ( 'global/counter' , 0 ) ;
1355
1456 const [ count2 ] = usePersistentState ( 'global/counter' , 0 ) ;
@@ -19,8 +61,8 @@ const Landing = () => {
1961 'Content-Type' : 'application/json' ,
2062 } ,
2163 } ) ;
22-
2364 return (
65+
2466 < div style = { { textAlign : 'center' } } >
2567 < header >
2668 < img src = { logo } className = "animate-spin h-10 mx-auto" alt = "logo" />
@@ -67,9 +109,57 @@ const Landing = () => {
67109 </ p >
68110 </ div >
69111 </ header >
112+
113+ < CrudTable < User >
114+ title = "User Management"
115+ rowKey = "id"
116+ defaultPageSize = { 10 }
117+ service = { new UserService ( ) }
118+ columns = { [
119+ {
120+ dataIndex : 'name' ,
121+ title : 'Name' ,
122+ fieldType : 'string' ,
123+ formConfig : { required : true } ,
124+ } ,
125+ {
126+ dataIndex : 'age' ,
127+ title : 'Age' ,
128+ fieldType : 'number' ,
129+ } ,
130+ {
131+ dataIndex : 'age2' ,
132+ title : 'Age2' ,
133+ fieldType : 'number' ,
134+ } ,
135+ {
136+ dataIndex : 'createdAt' ,
137+ title : 'Created At' ,
138+ fieldType : 'date' ,
139+ } ,
140+ {
141+ dataIndex : 'status' ,
142+ title : 'Status' ,
143+ fieldType : 'enum' ,
144+ enumOptions : {
145+ active : { text : 'Active' } ,
146+ inactive : { text : 'Inactive' } ,
147+ } ,
148+ } ,
149+ {
150+ dataIndex : 'isAdmin' ,
151+ title : 'Administrator' ,
152+ fieldType : 'boolean' ,
153+ } ,
154+ ] }
155+ />
70156 </ div >
157+
158+
71159 ) ;
72160} ;
73161
162+ const Landing = UserTable ;
163+
74164// eslint-disable-next-line import/no-default-export
75165export default Landing ;
0 commit comments