From 71a0ebef34febc74f2b3b86ce6e1b91d4b554539 Mon Sep 17 00:00:00 2001 From: Mahima Sonwane Date: Tue, 13 May 2025 16:43:31 +0530 Subject: [PATCH 1/3] Updated search box style in entries table to match navbar and Same loading animation on all pages --- src/app/components/TokenTable.jsx | 281 +++++++++++++++--------------- 1 file changed, 136 insertions(+), 145 deletions(-) diff --git a/src/app/components/TokenTable.jsx b/src/app/components/TokenTable.jsx index 73aa564..c210109 100644 --- a/src/app/components/TokenTable.jsx +++ b/src/app/components/TokenTable.jsx @@ -55,15 +55,15 @@ export default function TokenTable({ statusFilter }) { const applyFilters = (data, search) => { let filtered = data.filter((entry) => { - const matchesSearch = + const matchesSearch = entry.patientName.toLowerCase().includes(search.toLowerCase()) || entry.tokenNumber.toString().includes(search); - - const matchesFilter = - statusFilter === "all" || + + const matchesFilter = + statusFilter === "all" || entry.status === statusFilter || (statusFilter === "booked" && entry.status === "booked"); - + return matchesSearch && matchesFilter; }); setFilteredEntries(filtered); @@ -96,162 +96,153 @@ export default function TokenTable({ statusFilter }) { -// Handle theme loading state -if (darkMode === undefined) { - return ( -
-
-
-

- Loading... -

+ // Handle theme loading state + if (darkMode === undefined) { + return ( +
+
+
+

+ Loading... +

+
+ ); + } + if (loading) return ( +
+
+

+ Loading... +

); -} -if (loading) return ( -
-
-

- Loading... -

-
-); -if (error) return ( -
- Error: {error} -
-); + if (error) return ( +
+ Error: {error} +
+ ); -return ( -
- + setSearchQuery(e.target.value)} - /> + }`} + value={searchQuery} + onChange={(e) => setSearchQuery(e.target.value)} + /> - {filteredEntries.length === 0 ? ( -
- No entries found. -
- ) : ( - <> -
- - - - - - - - - - - {currentEntries.map((entry) => ( - - - - + + ))} + +
TokenNameStatusActions
{entry.tokenNumber}{entry.patientName} - + No entries found. + + ) : ( + <> +
+ + + + + + + + + + + {currentEntries.map((entry) => ( + + + + - + - - ))} - -
TokenNameStatusActions
{entry.tokenNumber}{entry.patientName} + - {entry.status === "booked" ? "In-Queue" : entry.status} - - - {entry.status === "booked" && ( - <> - + {entry.status === "booked" && ( + <> + - + - - )} -
-
+ }`} + > + Missed + + + )} +
+
-
- - - Page {currentPage} of {totalPages} - - + + Page {currentPage} of {totalPages} + + -
- - )} -
-); + }`} + > + Next + +
+ + )} +
+ ); } \ No newline at end of file -- 2.45.2 From 82a05e5c6d8bec9ea2f90e2e6f0789a3b3431291 Mon Sep 17 00:00:00 2001 From: Mahima Sonwane Date: Tue, 13 May 2025 16:59:36 +0530 Subject: [PATCH 2/3] Same loading animation on all pages and Updated search box style in entries table to match navbar --- src/app/pages/entries/EntriesTable.js | 278 +++++++++++++------------- 1 file changed, 134 insertions(+), 144 deletions(-) diff --git a/src/app/pages/entries/EntriesTable.js b/src/app/pages/entries/EntriesTable.js index 00b58e3..57d2aca 100644 --- a/src/app/pages/entries/EntriesTable.js +++ b/src/app/pages/entries/EntriesTable.js @@ -1,4 +1,3 @@ - "use client"; import { useEffect, useState } from "react"; import { databases, Query } from "../../lib/appwrite"; @@ -6,6 +5,7 @@ import { DATABASE_ID, COLLECTION_ID } from "../../lib/api"; import Header from "../../components/partials/header"; import { useTheme } from "../../context/ThemeContext"; import { useAuth } from "../../context/AuthContext"; +import { FaSearch } from 'react-icons/fa'; export default function EntriesTable() { const { userRole } = useAuth(); @@ -14,7 +14,7 @@ export default function EntriesTable() { const [filteredEntries, setFilteredEntries] = useState([]); const [searchQuery, setSearchQuery] = useState(""); const [currentPage, setCurrentPage] = useState(1); - const [avgConsultTime, setAvgConsultTime] = useState(15); // Default 15 mins + const [avgConsultTime, setAvgConsultTime] = useState(15); const entriesPerPage = 20; const [currentToken, setCurrentToken] = useState(null); @@ -24,7 +24,6 @@ export default function EntriesTable() { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - // Calculate waiting time based on position in queue const calculateWaitTime = (tokenNumber) => { const bookedEntries = entries.filter((e) => e.status === "booked"); const position = bookedEntries.findIndex( @@ -58,19 +57,13 @@ export default function EntriesTable() { return; } - const currentIndex = entries.findIndex( - (entry) => entry.status === "booked" - ); + const currentIndex = entries.findIndex((entry) => entry.status === "booked"); const current = currentIndex >= 0 ? entries[currentIndex] : null; setCurrentToken(current?.tokenNumber || null); - setPreviousToken( - currentIndex > 0 ? entries[currentIndex - 1]?.tokenNumber : null - ); + setPreviousToken(currentIndex > 0 ? entries[currentIndex - 1]?.tokenNumber : null); setNextToken( - currentIndex < entries.length - 1 - ? entries[currentIndex + 1]?.tokenNumber - : null + currentIndex < entries.length - 1 ? entries[currentIndex + 1]?.tokenNumber : null ); const missed = entries @@ -99,18 +92,13 @@ export default function EntriesTable() { }; useEffect(() => { - if (userRole === "patient") return; // Don't load data if patient - + if (userRole === "patient") return; const loadData = async () => { try { const data = await getEntries(); setEntries(data); setFilteredEntries(data); updateTokenInfo(data); - - // Load settings (avg consultation time) - // const settings = await getSettings(); - // setAvgConsultTime(settings?.avgConsultationTime || 15); } catch (err) { setError(err.message); } finally { @@ -133,32 +121,22 @@ export default function EntriesTable() { const indexOfLastEntry = currentPage * entriesPerPage; const indexOfFirstEntry = indexOfLastEntry - entriesPerPage; - const currentEntries = filteredEntries.slice( - indexOfFirstEntry, - indexOfLastEntry - ); + const currentEntries = filteredEntries.slice(indexOfFirstEntry, indexOfLastEntry); const totalPages = Math.ceil(filteredEntries.length / entriesPerPage); if (loading) return ( -
-
-

Loading...

+
+
+

Loading...

); if (error) return
Error: {error}
; - // Check user role and show permission message if patient if (userRole === "patient") { return ( -
+

Access Denied

@@ -170,129 +148,141 @@ export default function EntriesTable() { } return ( -
+
-

Today's Entries

- setSearchQuery(e.target.value)} - /> - {filteredEntries.length === 0 ? ( -
No entries found for today.
- ) : ( - <> - - - - - - {/* */} - - {/* */} - - - - - {currentEntries.map((entry) => ( - - - - {/* */} - - {/* */} - +
+

Today's Entries

+ + + {filteredEntries.length === 0 ? ( +
No entries found for today.
+ ) : ( + <> +
TokenNameBooked ByStatusWait TimeActions
{entry.tokenNumber}{entry.patientName} - - {entry.bookedBy} - - - - {entry.status === "booked" ? "In-Queue" : entry.status} - - - {entry.status === "booked" ? - `~${calculateWaitTime(entry.tokenNumber)} mins` : - '-'} - - {entry.status === "booked" && ( - <> - - - - )} -
+ + + + + + - ))} - -
TokenNameStatusActions
+ + + {currentEntries.map((entry) => ( + + {entry.tokenNumber} + {entry.patientName} + + + {entry.status === "booked" ? "In-Queue" : entry.status} + + + + {entry.status === "booked" && ( + <> + + + + )} + + + ))} + + - {/* Pagination */} -
- - - Page {currentPage} of {totalPages} - - -
- - )} + + + Page {currentPage} of {totalPages} + + +
+ + )} +
); } -- 2.45.2 From 3c7ff4cceb0f8d671216c8666fdf5140013d2b16 Mon Sep 17 00:00:00 2001 From: Mahima Sonwane Date: Tue, 13 May 2025 17:01:28 +0530 Subject: [PATCH 3/3] Delete Unwanted Sigup Signin Folders --- src/app/components/TokenTable.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/TokenTable.jsx b/src/app/components/TokenTable.jsx index c210109..cb734d5 100644 --- a/src/app/components/TokenTable.jsx +++ b/src/app/components/TokenTable.jsx @@ -102,7 +102,7 @@ export default function TokenTable({ statusFilter }) {