From 0ec194b82420981ef15f7b2879b7f4ff0d499b2b Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Tue, 24 Sep 2024 23:55:51 +0530 Subject: [PATCH] Login button fix --- app/(default)/events/EventCard.css | 14 ++- app/(default)/events/page.tsx | 177 ++++++++++++++++------------- 2 files changed, 108 insertions(+), 83 deletions(-) diff --git a/app/(default)/events/EventCard.css b/app/(default)/events/EventCard.css index 21221da..449977a 100644 --- a/app/(default)/events/EventCard.css +++ b/app/(default)/events/EventCard.css @@ -32,7 +32,6 @@ h2 { transform: rotateY(180deg); } - .event-card-front, .event-card-back { width: 100%; @@ -116,7 +115,12 @@ h2 { font-size: 1em; } -button { +/* Updated button styles */ +.toggle-form-button, +.toggle-edit-button, +.submit-event-button, +.update-event-button, +.remove-event-button { margin-top: 70px !important; background-color: black; color: yellow; @@ -129,7 +133,11 @@ button { margin: 10px; } -button:hover { +.toggle-form-button:hover, +.toggle-edit-button:hover, +.submit-event-button:hover, +.update-event-button:hover, +.remove-event-button:hover { background-color: yellow; color: black; } diff --git a/app/(default)/events/page.tsx b/app/(default)/events/page.tsx index 0644fe3..17f25ef 100644 --- a/app/(default)/events/page.tsx +++ b/app/(default)/events/page.tsx @@ -44,13 +44,23 @@ const EventCard: React.FC = () => { // Fetch admin status useEffect(() => { const checkAdminStatus = async () => { - const user = auth.currentUser; - if (user) { - const adminDocSnap = await getDoc(doc(db, "admin", user.uid)); - setIsAdmin(adminDocSnap.exists()); - } + onAuthStateChanged(auth, async (user) => { + if (user) { + const uid = user.uid; + try { + const adminDocRef = doc(db, "admin", uid); + const adminDocSnap = await getDoc(adminDocRef); + if (adminDocSnap.exists()) { + setIsAdmin(true); + } + } catch (error) { + console.log("Error getting document:", error); + } + } + }); }; - onAuthStateChanged(auth, checkAdminStatus); + + checkAdminStatus(); }, []); // Fetch events from Firestore @@ -219,8 +229,11 @@ const EventCard: React.FC = () => {
{isAdmin && ( <> - {formVisible && ( @@ -274,16 +287,21 @@ const EventCard: React.FC = () => { required />
- + )} - {editFormVisible && ( -
+
- - {eventDataToEdit && ( - <> -
- - setEventName(e.target.value)} - required - /> -
-
- -