From 23b940bde13ca3b19d597a01d75cea47006e8667 Mon Sep 17 00:00:00 2001 From: Neeraj-gagat Date: Fri, 14 Nov 2025 14:52:31 +0530 Subject: [PATCH] Added loading Skeleton --- .../HomeComponents/Tasks/Task-Skeleton.tsx | 26 + .../components/HomeComponents/Tasks/Tasks.tsx | 671 +++++++++--------- 2 files changed, 369 insertions(+), 328 deletions(-) create mode 100644 frontend/src/components/HomeComponents/Tasks/Task-Skeleton.tsx diff --git a/frontend/src/components/HomeComponents/Tasks/Task-Skeleton.tsx b/frontend/src/components/HomeComponents/Tasks/Task-Skeleton.tsx new file mode 100644 index 00000000..6b722d62 --- /dev/null +++ b/frontend/src/components/HomeComponents/Tasks/Task-Skeleton.tsx @@ -0,0 +1,26 @@ +import { TableCell, TableRow } from '@/components/ui/table'; + +export const Taskskeleton = ({ count }: { count: number }) => { + return ( + <> + {Array.from({ length: count }).map((_, i) => ( + + +
+
+ + +
+
+
+
+
+
+ +
+
+
+ ))} + + ); +}; diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index 2f2e4b7d..816a01ef 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -60,6 +60,7 @@ import { TasksDatabase, } from './hooks'; import { debounce } from '@/components/utils/utils'; +import { Taskskeleton } from './Task-Skeleton'; const db = new TasksDatabase(); export let syncTasksWithTwAndDb: () => any; @@ -250,6 +251,8 @@ export const Tasks = ( } catch (error) { console.error('Error syncing tasks:', error); toast.error(`Failed to sync tasks. Please try again.`); + } finally { + props.setIsLoading(false); } }, [props.email, props.encryptionSecret, props.UUID]); // Add dependencies @@ -723,7 +726,13 @@ export const Tasks = (
-
@@ -770,96 +779,200 @@ export const Tasks = ( {/* Display tasks */} - {currentTasks.map((task: Task, index: number) => ( - - handleDialogOpenChange(_isDialogOpen, task) - } - key={index} - > - - - {/* Display task details */} - - - {task.id} - - - - {task.priority === 'H' && ( -
- )} - {task.priority === 'M' && ( -
- )} - {task.priority != 'H' && - task.priority != 'M' && ( -
+ {props.isLoading ? ( + + ) : ( + currentTasks.map((task: Task, index: number) => ( + + handleDialogOpenChange(_isDialogOpen, task) + } + key={index} + > + + + {/* Display task details */} + + + {task.id} + + + + {task.priority === 'H' && ( +
)} - - {task.description} - - {task.project != '' && ( - - - {task.project === '' ? '' : task.project} - - )} -
- - + )} + {task.priority != 'H' && + task.priority != 'M' && ( +
+ )} + + {task.description} + + {task.project != '' && ( + + + {task.project === '' ? '' : task.project} + + )} +
+ + + {task.status === 'completed' + ? 'C' : task.status === 'deleted' - ? 'destructive' - : 'default' - } - > - {task.status === 'completed' - ? 'C' - : task.status === 'deleted' - ? 'D' - : 'P'} - - -
-
- - - - - - Task{' '} + ? 'D' + : 'P'} + +
+
+
+ + + + + + Task{' '} + + Details - Details - - - + + - {/* Scrollable content */} -
- - - - - ID: - {task.id} - - - Description: - - {isEditing ? ( - <> + {/* Scrollable content */} +
+ +
+ + + ID: + {task.id} + + + Description: + + {isEditing ? ( + <> +
+ + setEditedDescription( + e.target.value + ) + } + className="flex-grow mr-2" + /> + + +
+ + ) : ( + <> + {task.description} + + + )} +
+
+ + Due: + + {formattedDate(task.due)} + + + + Start: + + {formattedDate(task.start)} + + + + End: + + {formattedDate(task.end)} + + + + Wait: + + {formattedDate(task.wait)} + + + + Depends: + {task.depends} + + + Recur: + {task.recur} + + + RType: + {task.rtype} + + + Priority: + {task.priority} + + + Project: + {task.project} + + + Status: + {task.status} + + + Tags: + + {isEditingTags ? (
- setEditedDescription( + setEditedTags( e.target.value + .split(',') + .map((tag) => tag.trim()) ) } className="flex-grow mr-2" @@ -868,7 +981,7 @@ export const Tasks = ( variant="ghost" size="icon" onClick={() => - handleSaveClick(task) + handleSaveTags(task) } > @@ -876,261 +989,163 @@ export const Tasks = (
- - ) : ( - <> - {task.description} - - - )} -
-
- - Due: - - {formattedDate(task.due)} - - - - Start: - - {formattedDate(task.start)} - - - - End: - - {formattedDate(task.end)} - - - - Wait: - - {formattedDate(task.wait)} - - - - Depends: - {task.depends} - - - Recur: - {task.recur} - - - RType: - {task.rtype} - - - Priority: - {task.priority} - - - Project: - {task.project} - - - Status: - {task.status} - - - Tags: - - {isEditingTags ? ( -
- - setEditedTags( - e.target.value - .split(',') - .map((tag) => tag.trim()) - ) - } - className="flex-grow mr-2" - /> - - -
- ) : ( -
- {task.tags !== null && - task.tags.length >= 1 ? ( - task.tags.map((tag, index) => ( - - - {tag} - - )) - ) : ( - No Tags - )} - -
- )} -
-
- - Urgency: - {task.urgency} - - - UUID: - - {task.uuid} - handleCopy('Task UUID')} - > - - - - -
-
-
-
+ ) : ( +
+ {task.tags !== null && + task.tags.length >= 1 ? ( + task.tags.map((tag, index) => ( + + + {tag} + + )) + ) : ( + No Tags + )} + +
+ )} + + + + Urgency: + {task.urgency} + + + UUID: + + {task.uuid} + + handleCopy('Task UUID') + } + > + + + + +
+ + + - {/* Non-scrollable footer */} - - {task.status == 'pending' ? ( - - - - - - - - - Are you{' '} + {/* Non-scrollable footer */} + + {task.status == 'pending' ? ( + + + + + + + + + Are you{' '} + + sure? - sure? - - - - - - - - - - - - - ) : null} + + + + + + + + + + + + ) : null} - {task.status != 'deleted' ? ( - - - - - - - - - Are you{' '} + {task.status != 'deleted' ? ( + + + + + + + + + Are you{' '} + + sure? - sure? - - - - - - - - - - - - - ) : null} - - - - - - - ))} + + + + + + + + + + + + ) : null} + + + + + + + )) + )} {/* Display empty rows */} - {emptyRows > 0 && ( + {!props.isLoading && emptyRows > 0 && (