From c7e78a30b41b2c0ed446e5a8fcaf66e4e4376324 Mon Sep 17 00:00:00 2001 From: arnavk377 Date: Sun, 11 May 2025 11:17:52 -0700 Subject: [PATCH 1/3] functionality and styling fixes for the pull request Co-authored-by: Kainoa Nishida --- .../components/clientlist/AddClientForm.tsx | 4 +- .../src/components/clientlist/ClientList.tsx | 324 ++++++++++-------- .../clientlist/ClientListFilter.tsx | 2 +- 3 files changed, 181 insertions(+), 149 deletions(-) diff --git a/client/src/components/clientlist/AddClientForm.tsx b/client/src/components/clientlist/AddClientForm.tsx index f78d2386..0e873ddb 100644 --- a/client/src/components/clientlist/AddClientForm.tsx +++ b/client/src/components/clientlist/AddClientForm.tsx @@ -203,8 +203,8 @@ export const AddClientForm = ({ onClientAdded, setShowUnfinishedAlert}: AddClien return ( <> { const [filterQuery, setFilterQuery] = useState([]); const [sorting, setSorting] = useState([]); const [loading, setLoading] = useState(true); + const navigate = useNavigate(); const [showUnfinishedAlert, setShowUnfinishedAlert] = useState(false) + const [showSearch, setShowSearch] = useState(false); + const columns = useMemo[]>( () => [ { @@ -347,13 +353,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 { @@ -365,159 +370,186 @@ export const ClientList = ({ admin }: ClientListProps) => { fetchData(); }, [backend, searchKey, filterQuery]); - return ( - {showUnfinishedAlert && } - Welcome, {currentUser?.displayName} - - My Complete Client Table - - Last Updated: {lastUpdated} - - - {admin && } - - - setSearchKey(e.target.value)} - /> - - - - showing {clients.length} results on this page + + {showUnfinishedAlert && } + + Welcome, {currentUser?.displayName} + Complete Client Table + + Last Updated: {lastUpdated} - - - - page {} of {Math.ceil(clients.length / 20)} + + {admin && } + {/* im ded bruh what is this vstack */} + + + + {/* + showing {clients.length} results on this page - - - - - {/* */} - - onPressCSVButton()} - > - - - - - - {/* If you want to have a fixed bottom height I'd prob have to change the css of this whole thing no? */} + + + + page {} of {Math.ceil(clients.length / 20)} + + + */} + + + {/* */} + + + + + {/* 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) => ( - - {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)} + /> */} + 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 ( - - - page {} of {Math.ceil(clients.length / 20)} - - - */} + - {/* */} + - {/* If you want to have a fixed bottom height I'd prob have to change the css of this whole thing no? */} { - - {/* setSearchKey(e.target.value)} - /> */} + setSearchKey(e.target.value)} display={showSearch ? 'block' : 'none'}> {setShowSearch(!showSearch); setSearchKey("")}} @@ -452,13 +433,13 @@ export const ClientList = ({ admin }: ClientListProps) => { onPressCSVButton()} > From 5a0c951df6728be39bf00a376f5ab2c75a0bcc58 Mon Sep 17 00:00:00 2001 From: Alexander Yin <68826416+alexy-ok@users.noreply.github.com> Date: Tue, 13 May 2025 22:14:21 +0200 Subject: [PATCH 3/3] keep protected route --- client/src/App.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 74bd09dc..542f5a4a 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -139,14 +139,11 @@ const App = () => { /> } /> - {/* } allowedRoles={['admin', 'user']} />} - /> */} - } /> + } allowedRoles={['admin', 'user']} />}