From 7c9d2c8c79283d6737bfc63653551192686d5adf Mon Sep 17 00:00:00 2001 From: Ryan Salazar Date: Fri, 8 May 2026 15:03:16 +0000 Subject: [PATCH] remove rocket.new leaderboard banner; re-add admin nav guard - src/app/home-page/components/LeaderboardAd.tsx: drop the hardcoded img.rocket.new image (rocket_gen_img_1bebfd3c7) at the top of the homepage. Replaced with to keep the slot for the eventual ad-server wiring while removing the rocket.new dependency entirely. - src/components/Header.tsx: re-add the isAdmin gate that was reverted in 0d51dad. Reads bb.user_profiles.role and only renders the desktop admin nav block (WP Import, Articles, Editorial, Users, Analytics, Audit Log, Notifications, Newsletter, Forum Seed, Company Tracker, Show Calendar, AI Console, Banned Terms, Dashboard) and the mobile WP Import link when role is in (administrator, admin, super_admin, editor, support). 'support' is admin-tier per the new RBAC matrix. Page-level auth checks on each /admin/* route remain authoritative; this only suppresses menu visibility for non-admin/anonymous. --- .../home-page/components/LeaderboardAd.tsx | 18 +-- src/components/Header.tsx | 128 ++++++++++-------- 2 files changed, 79 insertions(+), 67 deletions(-) diff --git a/src/app/home-page/components/LeaderboardAd.tsx b/src/app/home-page/components/LeaderboardAd.tsx index 242a7f8..bd4bc4a 100644 --- a/src/app/home-page/components/LeaderboardAd.tsx +++ b/src/app/home-page/components/LeaderboardAd.tsx @@ -1,22 +1,12 @@ import React from "react"; -import AppImage from "@/components/ui/AppImage"; +import AdSlot from "@/components/AdSlot"; -// DO NOT OVERRIDE — Leaderboard ad placeholder layout export default function LeaderboardAd() { return (
- {/* Leaderboard ad unit — 728x90 — stub links to advertise page */} - - - - +
-
); - + + ); } \ No newline at end of file diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 2721c42..59f4440 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -48,6 +48,7 @@ export default function Header() { const [searchFocused, setSearchFocused] = useState(false); const [currentUserId, setCurrentUserId] = useState(null); const [currentUserEmail, setCurrentUserEmail] = useState(null); + const [isAdmin, setIsAdmin] = useState(false); const [subEmail, setSubEmail] = useState(""); const [subStatus, setSubStatus] = useState<"idle" | "loading" | "success" | "error">("idle"); const [subMessage, setSubMessage] = useState(""); @@ -65,14 +66,29 @@ export default function Header() { useEffect(() => { const supabase = createClient(); + const ADMIN_ROLES = new Set([ + "administrator", "admin", "super_admin", "editor", "support", + ]); + + const refreshAdmin = async (userId: string | null) => { + if (!userId) { setIsAdmin(false); return; } + const { data } = await supabase + .from("user_profiles") + .select("role") + .eq("id", userId) + .maybeSingle(); + setIsAdmin(!!data?.role && ADMIN_ROLES.has(data.role)); + }; + supabase.auth.getUser().then(({ data: { user } }) => { setCurrentUserId(user?.id || null); setCurrentUserEmail(user?.email || null); + refreshAdmin(user?.id || null); }); - const supabase2 = createClient(); - const { data: { subscription } } = supabase2.auth.onAuthStateChange((_event, session) => { + const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => { setCurrentUserId(session?.user?.id || null); setCurrentUserEmail(session?.user?.email || null); + refreshAdmin(session?.user?.id || null); }); return () => subscription.unsubscribe(); }, []); @@ -237,48 +253,52 @@ export default function Header() { My Profile )} - - WP Import - - - Articles - - - Editorial - - - Users - - - Analytics - - - Audit Log - - - Notifications - - - Newsletter - - - Forum Seed - - - Company Tracker - - - Show Calendar - - - AI Console - - - Banned Terms - - - Dashboard - + {isAdmin && ( + <> + + WP Import + + + Articles + + + Editorial + + + Users + + + Analytics + + + Audit Log + + + Notifications + + + Newsletter + + + Forum Seed + + + Company Tracker + + + Show Calendar + + + AI Console + + + Banned Terms + + + Dashboard + + + )} {/* Inline Email Subscription Form */} {subStatus === "success" ? ( {subMessage} @@ -448,15 +468,17 @@ export default function Header() { Account {/* WP Import mobile link */} - setMobileOpen(false)}> - - WP Import - + {isAdmin && ( + setMobileOpen(false)}> + + WP Import + + )}
{categoryLinks?.map((link) => (