@@ -4,7 +4,6 @@ import { User, Post, UserProject, Activity } from '../../entities';
44import useIDBOperations from '../../hook/useIDBOperations' ;
55
66const { Title, Paragraph } = Typography ;
7- const { TabPane } = Tabs ;
87
98const Context = React . createContext ( { name : 'Default' } ) ;
109
@@ -60,10 +59,10 @@ const Landing = () => {
6059 const loadData = async ( ) => {
6160 try {
6261 const [ usersData , postsData , projectsData , activitiesData ] = await Promise . all ( [
63- listItems < User > ( ' User' ) ,
64- listItems < Post > ( ' Post' ) ,
65- listItems < UserProject > ( ' UserProject' ) ,
66- listItems < Activity > ( ' Activity' )
62+ listItems < User > ( User ) ,
63+ listItems < Post > ( Post ) ,
64+ listItems < UserProject > ( UserProject ) ,
65+ listItems < Activity > ( Activity )
6766 ] ) ;
6867
6968 setUsers ( usersData ) ;
@@ -91,15 +90,15 @@ const Landing = () => {
9190 const handleCreateUser = async ( ) => {
9291 try {
9392 const user = new User ( newUser . name , newUser . email , newUser . age , newUser . address ) ;
94- await createItem ( ' User' , user ) ;
93+ await createItem ( User , user ) ;
9594
9695 // Create login activity
9796 const loginActivity = new Activity ( newUser . email , 'login' , {
9897 ip : '192.168.1.100' ,
9998 browser : 'Chrome' ,
10099 timestamp : Date . now ( )
101100 } ) ;
102- await createItem ( ' Activity' , loginActivity ) ;
101+ await createItem ( Activity , loginActivity ) ;
103102
104103 setIsUserModalVisible ( false ) ;
105104 setNewUser ( { name : '' , email : '' , age : 18 , address : '' } ) ;
@@ -113,7 +112,7 @@ const Landing = () => {
113112
114113 const handleDeleteUser = async ( id : number ) => {
115114 try {
116- await deleteItem ( ' User' , id ) ;
115+ await deleteItem ( User , id ) ;
117116 await loadData ( ) ;
118117 showNotification ( 'success' , 'User deleted successfully!' ) ;
119118 } catch ( err ) {
@@ -126,14 +125,14 @@ const Landing = () => {
126125 const handleCreatePost = async ( ) => {
127126 try {
128127 const post = new Post ( newPost . title , newPost . content , newPost . authorEmail , newPost . category ) ;
129- await createItem ( ' Post' , post ) ;
128+ await createItem ( Post , post ) ;
130129
131130 // Create post creation activity
132131 const postActivity = new Activity ( newPost . authorEmail , 'post_created' , {
133132 postTitle : newPost . title ,
134133 category : newPost . category
135134 } ) ;
136- await createItem ( ' Activity' , postActivity ) ;
135+ await createItem ( Activity , postActivity ) ;
137136
138137 setIsPostModalVisible ( false ) ;
139138 setNewPost ( { title : '' , content : '' , authorEmail : '' , category : 'general' } ) ;
@@ -147,7 +146,7 @@ const Landing = () => {
147146
148147 const handleDeletePost = async ( uuid : string ) => {
149148 try {
150- await deleteItem ( ' Post' , uuid ) ;
149+ await deleteItem ( Post , uuid ) ;
151150 await loadData ( ) ;
152151 showNotification ( 'success' , 'Post deleted successfully!' ) ;
153152 } catch ( err ) {
@@ -160,7 +159,7 @@ const Landing = () => {
160159 const handleCreateProject = async ( ) => {
161160 try {
162161 const project = new UserProject ( newProject . userId , newProject . projectId , newProject . role ) ;
163- await createItem ( ' UserProject' , project ) ;
162+ await createItem ( UserProject , project ) ;
164163
165164 setIsProjectModalVisible ( false ) ;
166165 setNewProject ( { userId : '' , projectId : '' , role : 'member' } ) ;
@@ -174,7 +173,7 @@ const Landing = () => {
174173
175174 const handleDeleteProject = async ( userId : string , projectId : string ) => {
176175 try {
177- await deleteItem ( ' UserProject' , [ userId , projectId ] ) ;
176+ await deleteItem ( UserProject , [ userId , projectId ] ) ;
178177 await loadData ( ) ;
179178 showNotification ( 'success' , 'Project relationship deleted successfully!' ) ;
180179 } catch ( err ) {
@@ -187,21 +186,21 @@ const Landing = () => {
187186 const handleAdvancedQueries = async ( ) => {
188187 try {
189188 // Query active users older than 25
190- const activeUsers = await queryItems < User > ( ' User' , ( query ) =>
189+ const activeUsers = await queryItems < User > ( User , ( query ) =>
191190 query . where ( 'status' ) . equals ( 'active' )
192191 . and ( 'age' ) . gt ( 25 )
193192 . orderBy ( 'age' , 'asc' )
194193 ) ;
195194
196195 // Query posts by category
197- const tutorialPosts = await queryItems < Post > ( ' Post' , ( query ) =>
196+ const tutorialPosts = await queryItems < Post > ( Post , ( query ) =>
198197 query . where ( 'category' ) . equals ( 'tutorial' )
199198 . orderBy ( 'publishedAt' , 'desc' )
200199 . limit ( 5 )
201200 ) ;
202201
203202 // Query recent activities
204- const recentActivities = await queryItems < Activity > ( ' Activity' , ( query ) =>
203+ const recentActivities = await queryItems < Activity > ( Activity , ( query ) =>
205204 query . where ( 'timestamp' ) . gte ( Date . now ( ) - 24 * 60 * 60 * 1000 )
206205 . orderBy ( 'timestamp' , 'desc' )
207206 . limit ( 10 )
@@ -227,7 +226,7 @@ const Landing = () => {
227226 ] ;
228227
229228 for ( const user of demoUsers ) {
230- await createItem ( ' User' , user ) ;
229+ await createItem ( User , user ) ;
231230 }
232231
233232 // Create demo posts
@@ -238,7 +237,7 @@ const Landing = () => {
238237 ] ;
239238
240239 for ( const post of demoPosts ) {
241- await createItem ( ' Post' , post ) ;
240+ await createItem ( Post , post ) ;
242241 }
243242
244243 // Create demo projects
@@ -249,7 +248,7 @@ const Landing = () => {
249248 ] ;
250249
251250 for ( const project of demoProjects ) {
252- await createItem ( ' UserProject' , project ) ;
251+ await createItem ( UserProject , project ) ;
253252 }
254253
255254 await loadData ( ) ;
@@ -368,52 +367,68 @@ const Landing = () => {
368367 </ Space >
369368
370369 { /* Data Tables */ }
371- < Tabs defaultActiveKey = "1" >
372- < TabPane tab = "Users (Auto-increment ID)" key = "1" >
373- < Table
374- columns = { userColumns }
375- dataSource = { users }
376- rowKey = "id"
377- loading = { loading }
378- pagination = { { pageSize : 5 } }
379- />
380- </ TabPane >
381-
382- < TabPane tab = "Posts (UUID Keys)" key = "2" >
383- < Table
384- columns = { postColumns }
385- dataSource = { posts }
386- rowKey = "uuid"
387- loading = { loading }
388- pagination = { { pageSize : 5 } }
389- />
390- </ TabPane >
391-
392- < TabPane tab = "Projects (Composite Keys)" key = "3" >
393- < Table
394- columns = { projectColumns }
395- dataSource = { userProjects }
396- rowKey = { ( record ) => `${ record . userId } -${ record . projectId } ` }
397- loading = { loading }
398- pagination = { { pageSize : 5 } }
399- />
400- </ TabPane >
401-
402- < TabPane tab = "Activities (Custom Keys)" key = "4" >
403- < Table
404- columns = { activityColumns }
405- dataSource = { activities }
406- rowKey = "activityId"
407- loading = { loading }
408- pagination = { { pageSize : 5 } }
409- />
410- </ TabPane >
411- </ Tabs >
370+ < Tabs
371+ defaultActiveKey = "1"
372+ items = { [
373+ {
374+ key : '1' ,
375+ label : 'Users (Auto-increment ID)' ,
376+ children : (
377+ < Table
378+ columns = { userColumns }
379+ dataSource = { users }
380+ rowKey = "id"
381+ loading = { loading }
382+ pagination = { { pageSize : 5 } }
383+ />
384+ )
385+ } ,
386+ {
387+ key : '2' ,
388+ label : 'Posts (UUID Keys)' ,
389+ children : (
390+ < Table
391+ columns = { postColumns }
392+ dataSource = { posts }
393+ rowKey = "uuid"
394+ loading = { loading }
395+ pagination = { { pageSize : 5 } }
396+ />
397+ )
398+ } ,
399+ {
400+ key : '3' ,
401+ label : 'Projects (Composite Keys)' ,
402+ children : (
403+ < Table
404+ columns = { projectColumns }
405+ dataSource = { userProjects }
406+ rowKey = { ( record ) => `${ record . userId } -${ record . projectId } ` }
407+ loading = { loading }
408+ pagination = { { pageSize : 5 } }
409+ />
410+ )
411+ } ,
412+ {
413+ key : '4' ,
414+ label : 'Activities (Custom Keys)' ,
415+ children : (
416+ < Table
417+ columns = { activityColumns }
418+ dataSource = { activities }
419+ rowKey = "activityId"
420+ loading = { loading }
421+ pagination = { { pageSize : 5 } }
422+ />
423+ )
424+ }
425+ ] }
426+ />
412427
413428 { /* Add User Modal */ }
414429 < Modal
415430 title = "Add New User (Auto-increment ID)"
416- visible = { isUserModalVisible }
431+ open = { isUserModalVisible }
417432 onOk = { handleCreateUser }
418433 onCancel = { ( ) => setIsUserModalVisible ( false ) }
419434 okText = "Create User"
@@ -447,7 +462,7 @@ const Landing = () => {
447462 { /* Add Post Modal */ }
448463 < Modal
449464 title = "Add New Post (UUID Key)"
450- visible = { isPostModalVisible }
465+ open = { isPostModalVisible }
451466 onOk = { handleCreatePost }
452467 onCancel = { ( ) => setIsPostModalVisible ( false ) }
453468 okText = "Create Post"
@@ -480,7 +495,7 @@ const Landing = () => {
480495 { /* Add Project Modal */ }
481496 < Modal
482497 title = "Add New Project (Composite Key)"
483- visible = { isProjectModalVisible }
498+ open = { isProjectModalVisible }
484499 onOk = { handleCreateProject }
485500 onCancel = { ( ) => setIsProjectModalVisible ( false ) }
486501 okText = "Create Project"
0 commit comments