diff --git a/client/src/App.tsx b/client/src/App.tsx index 3b45b055..de3afec4 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -143,7 +143,7 @@ const App = () => { path="/clientlist" element={} allowedRoles={['admin', 'user']} />} /> - + } allowedRoles={['admin', 'user']} />} diff --git a/client/src/components/clientlist/AddClientForm.tsx b/client/src/components/clientlist/AddClientForm.tsx index e1745a4e..0e873ddb 100644 --- a/client/src/components/clientlist/AddClientForm.tsx +++ b/client/src/components/clientlist/AddClientForm.tsx @@ -204,7 +204,7 @@ export const AddClientForm = ({ onClientAdded, setShowUnfinishedAlert}: AddClien <> { const [filterQuery, setFilterQuery] = useState([]); const [sorting, setSorting] = useState([]); const [loading, setLoading] = useState(true); - // const [displayName, setDisplayName] = useState(""); + const navigate = useNavigate(); const [showUnfinishedAlert, setShowUnfinishedAlert] = useState(false) + const [showSearch, setShowSearch] = useState(false); + const columns = useMemo[]>( () => [ { @@ -350,13 +355,12 @@ export const ClientList = ({ admin }: ClientListProps) => { clientsRequest = backend.get(`/clients?page=&filter=${encodeURIComponent(filterQuery.join(" "))}&search=`); } else { clientsRequest = backend.get("/clients"); - const [lastUpdatedResponse, clientsResponse] = await Promise.all([lastUpdatedRequest, clientsRequest]); - - const date = new Date(lastUpdatedResponse.data[0]?.lastUpdatedAt); - setLastUpdated(date.toLocaleString()); - setClients(clientsResponse.data); - } + const [lastUpdatedResponse, clientsResponse] = await Promise.all([lastUpdatedRequest, clientsRequest]); + + const date = new Date(lastUpdatedResponse.data[0]?.lastUpdatedAt); + setLastUpdated(date.toLocaleString()); + setClients(clientsResponse.data); } catch (error) { console.error("Error fetching data:", error); } finally { @@ -368,162 +372,166 @@ export const ClientList = ({ admin }: ClientListProps) => { fetchData(); }, [backend, searchKey, filterQuery]); - return ( - {showUnfinishedAlert && } - Welcome, {currentUser?.displayName} - - My Complete Client Table - + {showUnfinishedAlert && } + + Welcome, {currentUser?.displayName} + Complete Client Table + + Last Updated: {lastUpdated} + + + {admin && } + + - Last Updated: {lastUpdated} - - - {admin && } - - - setSearchKey(e.target.value)} - /> - - - {/* - showing {clients.length} results on this page - */} - - {/* */} - {/* - page {} of {Math.ceil(clients.length / 20)} - */} - {/* */} - - - - {/* */} - - onPressCSVButton()} - > - - - - - - {/* If you want to have a fixed bottom height I'd prob have to change the css of this whole thing no? */} + + + + + + + + + {loading ? : - - - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - - ))} - - ))} - - - {table.getRowModel().rows.map((row, index) => ( - navigate(`/ViewClient/2`) - } - > - {row.getVisibleCells().map((cell) => ( - - ))} - - ))} - -
- {flexRender( - header.column.columnDef.header, - header.getContext() - )} - {header.column.getCanSort() && ( - - {header.column.getIsSorted() === "asc" ? ( - - ) : header.column.getIsSorted() === "desc" ? ( - - ) : null} - - )} -
{ - if (cell.column.id === "rowNumber") { - e.stopPropagation(); - } - }} - > - {cell.column.id === "rowNumber" ? ( - - ) : ( - flexRender(cell.column.columnDef.cell, cell.getContext()) - )} -
-
- } -
- setDeleteModalOpen(false)} - onConfirm={handleDelete} - /> + + + + + setSearchKey(e.target.value)} display={showSearch ? 'block' : 'none'}> + {setShowSearch(!showSearch); setSearchKey("")}} + > + + + onPressCSVButton()} + > + + + + + + + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => ( + + ))} + + ))} + + + {table.getRowModel().rows.map((row, index) => ( + {navigate(`/ViewClient/${row.original.id}`)}} + > + {row.getVisibleCells().map((cell) => ( + + ))} + + ))} + +
+ {flexRender( + header.column.columnDef.header, + header.getContext() + )} + {header.column.getCanSort() && ( + + {header.column.getIsSorted() === "asc" ? ( + + ) : header.column.getIsSorted() === "desc" ? ( + + ) : null} + + )} +
{ + if (cell.column.id === "rowNumber") { + e.stopPropagation(); + } + }} + > + {cell.column.id === "rowNumber" ? ( + + ) : ( + flexRender(cell.column.columnDef.cell, cell.getContext()) + )} +
+
+
+ } + + setDeleteModalOpen(false)} + onConfirm={handleDelete} + /> ); }; diff --git a/client/src/components/clientlist/ClientListFilter.tsx b/client/src/components/clientlist/ClientListFilter.tsx index 9f8c93d8..f3729358 100644 --- a/client/src/components/clientlist/ClientListFilter.tsx +++ b/client/src/components/clientlist/ClientListFilter.tsx @@ -182,7 +182,7 @@ export const ClientListFilter = ({setFilterQuery}: ClientListFilterProps) => { return ( -