From f6e418890890ea420e35719d8e0575a012277e9e Mon Sep 17 00:00:00 2001 From: Anand Suthar Date: Tue, 20 Aug 2024 23:21:48 +0530 Subject: [PATCH] fix: minor ui --- app/(pages)/admin/users/page.tsx | 170 +++++++++++-------------------- 1 file changed, 60 insertions(+), 110 deletions(-) diff --git a/app/(pages)/admin/users/page.tsx b/app/(pages)/admin/users/page.tsx index b163914..987f203 100644 --- a/app/(pages)/admin/users/page.tsx +++ b/app/(pages)/admin/users/page.tsx @@ -6,15 +6,11 @@ import { Button, Input, Dropdown, - Modal, TableHeader, TableColumn, TableBody, TableRow, TableCell, - ModalHeader, - ModalBody, - ModalFooter, Pagination, User, Card, @@ -26,6 +22,7 @@ import { AiOutlinePlus as PlusIcon, AiOutlineStop as BlockIcon, } from "react-icons/ai"; +import SpinnerLoader from "@/components/SpinnerLoader"; interface UserData { id: string; @@ -48,9 +45,10 @@ interface PaginationMetadata { const UserManagement: React.FC = () => { const [users, setUsers] = useState([]); + const [loading, setLoading] = useState(false); const [searchTerm, setSearchTerm] = useState(""); const [selectedRole, setSelectedRole] = useState("All"); - const [isModalOpen, setIsModalOpen] = useState(false); + const [currentUser, setCurrentUser] = useState(null); const [pagination, setPagination] = useState({ currentPage: 1, @@ -65,6 +63,7 @@ const UserManagement: React.FC = () => { const fetchUsers = async () => { try { + setLoading(true); const response = await fetch( `/api/admin/users?page=${pagination.currentPage}&limit=${pagination.pageSize}` ); @@ -74,6 +73,8 @@ const UserManagement: React.FC = () => { setPagination(data.pagination); } catch (error) { console.error("Error fetching users:", error); + } finally { + setLoading(false); } }; @@ -126,129 +127,78 @@ const UserManagement: React.FC = () => { startContent={} onClick={() => { setCurrentUser(null); - setIsModalOpen(true); }} > Blocked Users -
- - - User - Role - Username - Gender - Contact - Location - Actions - - - {filteredUsers.map((user) => ( - - - - - {user.role} - {user.username} - {user.gender} - {user.contact} - {`${user.city}, ${user.state}`} - - - - - ))} - -
-
+ {loading ? ( +
+ +
+ ) : ( +
+ + + User + Role + Username + Gender + Contact + Location + Actions + + + {filteredUsers.map((user) => ( + + + + + {user.role} + {user.username} + {user.gender} + {user.contact} + {`${user.city}, ${user.state}`} + + + + + ))} + +
+
+ )}
setPagination({ ...pagination, currentPage: page }) } showControls - showShadow - color="primary" + showShadow={false} page={pagination.currentPage} + classNames={{ + cursor: "bg-foreground text-background", + }} />
- - setIsModalOpen(false)} - > - - - - - - - - - Patient - Doctor - Receptionist - Hospital - Admin - - - - - - - - - - - - - );