From 61585d8c63c0e57ef11fb10715fa8c2edd979e5d Mon Sep 17 00:00:00 2001 From: Michelle Date: Wed, 1 Apr 2026 12:05:51 +0200 Subject: [PATCH] feat: add functionality to display all rooms with search and modal support in admin panel --- src/i18n/de.json | 3 +- src/i18n/en.json | 3 +- src/pages/Admin.jsx | 320 ++++++++++++++++++++++++++++++-------------- 3 files changed, 226 insertions(+), 100 deletions(-) diff --git a/src/i18n/de.json b/src/i18n/de.json index 923da47..c5e9384 100644 --- a/src/i18n/de.json +++ b/src/i18n/de.json @@ -497,7 +497,8 @@ "deleteRoomConfirm": "Raum \"{name}\" wirklich löschen? Dies kann nicht rückgängig gemacht werden.", "roomDeleted": "Raum gelöscht", "roomDeleteFailed": "Raum konnte nicht gelöscht werden", - "noRoomsFound": "Keine Räume vorhanden" + "noRoomsFound": "Keine Räume vorhanden", + "showAllRooms": "Alle {count} Räume anzeigen" }, "notifications": { "bell": "Benachrichtigungen", diff --git a/src/i18n/en.json b/src/i18n/en.json index 7cd6bc8..ea76fbd 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -497,7 +497,8 @@ "deleteRoomConfirm": "Really delete room \"{name}\"? This cannot be undone.", "roomDeleted": "Room deleted", "roomDeleteFailed": "Room could not be deleted", - "noRoomsFound": "No rooms found" + "noRoomsFound": "No rooms found", + "showAllRooms": "Show all {count} rooms" }, "notifications": { "bell": "Notifications", diff --git a/src/pages/Admin.jsx b/src/pages/Admin.jsx index 47a8dcf..7ed91d0 100644 --- a/src/pages/Admin.jsx +++ b/src/pages/Admin.jsx @@ -59,6 +59,9 @@ export default function Admin() { const [adminRooms, setAdminRooms] = useState([]); const [adminRoomsLoading, setAdminRoomsLoading] = useState(true); const [roomSearch, setRoomSearch] = useState(''); + const [roomsExpanded, setRoomsExpanded] = useState(false); + const [showAllRoomsModal, setShowAllRoomsModal] = useState(false); + const [allRoomsSearch, setAllRoomsSearch] = useState(''); useEffect(() => { if (user?.role !== 'admin') { @@ -821,109 +824,117 @@ export default function Admin() { {/* Room Management */}
-
- -

{t('admin.roomsTitle')}

-
-

{t('admin.roomsDescription')}

- - {adminRoomsLoading ? ( -
- + -
- - - - - - - - - - - - {adminRooms - .filter(r => - r.name.toLowerCase().includes(roomSearch.toLowerCase()) || - r.owner_name.toLowerCase().includes(roomSearch.toLowerCase()) || - r.uid.toLowerCase().includes(roomSearch.toLowerCase()) - ) - .map(r => ( - - - - - - - - ))} - -
- {t('admin.roomName')} - - {t('admin.roomOwner')} - - {t('admin.roomShares')} - - {t('admin.roomCreated')} - - {t('admin.actions')} -
-
-

{r.name}

-

{r.uid}

-
-
-
-

{r.owner_name}

-

{r.owner_email}

-
-
- {r.share_count} - - {new Date(r.created_at).toLocaleDateString(language === 'de' ? 'de-DE' : 'en-US')} - -
- - -
-
-
+ {roomsExpanded && ( +
+

{t('admin.roomsDescription')}

- {adminRooms.length === 0 && ( -
- -

{t('admin.noRoomsFound')}

+ {adminRoomsLoading ? ( +
+
+ ) : ( + <> + {adminRooms.length > 0 && ( +
+ + + + + + + + + + + + {adminRooms.slice(0, 10).map(r => ( + + + + + + + + ))} + +
+ {t('admin.roomName')} + + {t('admin.roomOwner')} + + {t('admin.roomShares')} + + {t('admin.roomCreated')} + + {t('admin.actions')} +
+
+

{r.name}

+

{r.uid}

+
+
+
+

{r.owner_name}

+

{r.owner_email}

+
+
+ {r.share_count} + + {new Date(r.created_at).toLocaleDateString(language === 'de' ? 'de-DE' : 'en-US')} + +
+ + +
+
+
+ )} + + {adminRooms.length > 10 && ( +
+ +
+ )} + + {adminRooms.length === 0 && ( +
+ +

{t('admin.noRoomsFound')}

+
+ )} + )} - +
)}
@@ -1204,6 +1215,119 @@ export default function Admin() {
)} + + {/* All rooms modal */} + {showAllRoomsModal && ( +
+
setShowAllRoomsModal(false)} /> +
+
+
+ +

{t('admin.roomsTitle')}

+ ({adminRooms.length}) +
+ +
+
+
+ + setAllRoomsSearch(e.target.value)} + className="input-field pl-9 text-sm" + placeholder={t('admin.searchRooms')} + autoFocus + /> +
+
+
+ + + + + + + + + + + + {adminRooms + .filter(r => + r.name.toLowerCase().includes(allRoomsSearch.toLowerCase()) || + r.owner_name.toLowerCase().includes(allRoomsSearch.toLowerCase()) || + r.uid.toLowerCase().includes(allRoomsSearch.toLowerCase()) + ) + .map(r => ( + + + + + + + + ))} + +
+ {t('admin.roomName')} + + {t('admin.roomOwner')} + + {t('admin.roomShares')} + + {t('admin.roomCreated')} + + {t('admin.actions')} +
+
+

{r.name}

+

{r.uid}

+
+
+
+

{r.owner_name}

+

{r.owner_email}

+
+
+ {r.share_count} + + {new Date(r.created_at).toLocaleDateString(language === 'de' ? 'de-DE' : 'en-US')} + +
+ + +
+
+ {adminRooms.filter(r => + r.name.toLowerCase().includes(allRoomsSearch.toLowerCase()) || + r.owner_name.toLowerCase().includes(allRoomsSearch.toLowerCase()) || + r.uid.toLowerCase().includes(allRoomsSearch.toLowerCase()) + ).length === 0 && ( +
+ +

{t('admin.noRoomsFound')}

+
+ )} +
+
+
+ )}
); }