diff --git a/src/hooks/useEventDashboard.ts b/src/hooks/useEventDashboard.ts index d00cc36c..22ecaaff 100644 --- a/src/hooks/useEventDashboard.ts +++ b/src/hooks/useEventDashboard.ts @@ -24,7 +24,7 @@ const REGION_COLORS = [ ]; interface UseEventDashboardOptions { - /** Must be true for relay queries to fire. Pass isAdmin(user.pubkey). */ + /** Must be true for relay queries to fire. */ enabled: boolean; /** Current territorial view level. */ territorialLevel: TerritorialLevel; diff --git a/src/lib/sidebarItems.tsx b/src/lib/sidebarItems.tsx index c65830e7..aef299da 100644 --- a/src/lib/sidebarItems.tsx +++ b/src/lib/sidebarItems.tsx @@ -194,7 +194,7 @@ export const SIDEBAR_ITEMS: SidebarItemDef[] = [ { id: "badges", label: "Badges", path: "/badges", icon: Award }, { id: "communities", label: "Communities", path: "/communities", icon: Users }, { id: "world", label: "World", path: "/world", icon: Earth }, - { id: "dashboard", label: "Dashboard", path: "/dashboard", icon: Activity, requiresAuth: true, requiresAdmin: true }, + { id: "dashboard", label: "Dashboard", path: "/dashboard", icon: Activity }, ]; /** Set of all known sidebar item IDs for quick lookup. */ diff --git a/src/pages/EventDashboardPage.tsx b/src/pages/EventDashboardPage.tsx index 88e2915f..cfda8a1c 100644 --- a/src/pages/EventDashboardPage.tsx +++ b/src/pages/EventDashboardPage.tsx @@ -1,14 +1,13 @@ import { useState } from 'react'; -import { Activity, Lock, Shield, Radio, Settings } from 'lucide-react'; -import { useCurrentUser } from '@/hooks/useCurrentUser'; +import { Activity, PanelLeft, Radio, Settings, Trash2 } from 'lucide-react'; import { useLayoutOptions } from '@/contexts/LayoutContext'; -import { isAdmin } from '@/lib/admins'; -import { LoginArea } from '@/components/auth/LoginArea'; import { PageHeader } from '@/components/PageHeader'; import { Card, CardContent } from '@/components/ui/card'; import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; +import { useFeedSettings } from '@/hooks/useFeedSettings'; +import { useToast } from '@/hooks/useToast'; import { useEventDashboard } from '@/hooks/useEventDashboard'; import { KpiGrid } from '@/components/event-dashboard/KpiGrid'; @@ -22,14 +21,25 @@ import { ConfigDrawer } from '@/components/event-dashboard/ConfigDrawer'; import type { TerritorialLevel } from '@/components/event-dashboard/types'; /** - * Dashboard page — admin-only live monitoring dashboard. - * Phase 2: Connected to real relay data via useEventDashboard. + * Dashboard page — public live monitoring dashboard. */ export function EventDashboardPage() { - const { user } = useCurrentUser(); - const userIsAdmin = !!user && isAdmin(user.pubkey); const [territorialLevel, setTerritorialLevel] = useState('municipalities'); const [configOpen, setConfigOpen] = useState(false); + const { addToSidebar, removeFromSidebar, orderedItems } = useFeedSettings(); + const { toast } = useToast(); + const isInSidebar = orderedItems.includes('dashboard'); + + const handleToggleSidebar = () => { + if (isInSidebar) { + removeFromSidebar('dashboard'); + toast({ title: 'Removed from sidebar' }); + return; + } + + addToSidebar('dashboard'); + toast({ title: 'Added to sidebar' }); + }; // Use wider layout — removes 600px cap but keeps sidebar shell useLayoutOptions({ noMaxWidth: true, rightSidebar: null }); @@ -37,50 +47,7 @@ export function EventDashboardPage() { const { kpis, timeSeries, leaderboard, distribution, participants, activity, status, isLoading, error, - } = useEventDashboard({ enabled: userIsAdmin, territorialLevel }); - - // Not logged in - if (!user) { - return ( -
- } /> -
-
-
- -
-
-

Sign in required

-

Log in with an authorized account to access the dashboard.

-
- -
-
-
- ); - } - - // Logged in but not admin - if (!userIsAdmin) { - return ( -
- } /> -
- - -
-
- -
-

Admin access required

-

This dashboard is restricted to platform administrators.

-
-
-
-
-
- ); - } + } = useEventDashboard({ enabled: true, territorialLevel }); // Error state if (error && kpis.totalPosts === 0) { @@ -120,12 +87,21 @@ export function EventDashboardPage() { ); - // Admin — show dashboard return (
}>
{statusBadge} + diff --git a/src/pages/ExternalContentPage.tsx b/src/pages/ExternalContentPage.tsx index 931591f4..c025d2bd 100644 --- a/src/pages/ExternalContentPage.tsx +++ b/src/pages/ExternalContentPage.tsx @@ -1,6 +1,6 @@ import { useCallback, useMemo, useState } from 'react'; import { useSeoMeta } from '@unhead/react'; -import { ArrowLeft, BarChart3, Globe, MessageCircle, MessageSquare, MoreHorizontal, Repeat2, Star, AlertTriangle, PanelLeft, Trash2 } from 'lucide-react'; +import { Activity, ArrowLeft, BarChart3, Globe, MessageCircle, MessageSquare, MoreHorizontal, Repeat2, Star, AlertTriangle, PanelLeft, Trash2 } from 'lucide-react'; import { Link, useLocation, useParams } from 'react-router-dom'; import { Skeleton } from '@/components/ui/skeleton'; import { Badge } from '@/components/ui/badge'; @@ -83,6 +83,7 @@ function ExternalActionBar({ content, onComment, commentCount }: ExternalActionB // the bottom of the bar so the dropdown can dismiss without unmounting it // mid-animation. const countryCode = content.type === 'iso3166' ? content.code : null; + const showDashboardLink = countryCode?.toUpperCase() === 'VE'; const [statsOpen, setStatsOpen] = useState(false); const handleAddToSidebar = useCallback(() => { @@ -148,6 +149,14 @@ function ExternalActionBar({ content, onComment, commentCount }: ExternalActionB + {showDashboardLink && ( + + + + View Dashboard + + + )} {countryCode && ( setStatsOpen(true)} className="gap-3">