Spaces:
Running

axeronis commited on
Commit
d7933ab
·
1 Parent(s): fc8cecc

Feat: Add Admin navigation and fix mobile logo

Browse files
frontend/components/MobileNav.tsx CHANGED
@@ -5,27 +5,39 @@ import { Menu, X } from 'lucide-react'
5
  import { usePathname } from 'next/navigation'
6
  import { useEffect } from 'react'
7
 
8
- export function MobileHeader({ onOpen }: { onOpen?: () => void }) {
9
- // We use a global state or simple event dispatch if not using Context
10
- // For simplicity in this edit, we will rely on checking if the logic is split or combined.
11
- // Actually, let's make this component just toggle a class or state passed from parent?
12
- // But Layout is parent.
13
 
14
- // To avoid complex Prop drilling in Layout, let's use a simple local event pattern or just accept it's a visual header
15
- // that triggers the sidebar via a tailored approach.
16
 
17
  return (
18
  <div className="md:hidden flex items-center justify-between p-4 bg-[#0F172A] text-white border-b border-slate-800 sticky top-0 z-40">
19
- <div className="flex items-center gap-3">
20
- <img src="/logo-new.png" alt="Logo" className="w-8 h-8 object-contain" />
21
  <span className="font-bold">MicroFunnel</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </div>
23
- <button
24
- onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
25
- className="p-2 hover:bg-white/10 rounded-lg"
26
- >
27
- <Menu className="w-6 h-6" />
28
- </button>
29
  </div>
30
  )
31
  }
 
5
  import { usePathname } from 'next/navigation'
6
  import { useEffect } from 'react'
7
 
8
+ import { Shield } from 'lucide-react'
9
+ import Link from 'next/link'
10
+ import { useAuth } from '@/contexts/AuthContext'
 
 
11
 
12
+ export function MobileHeader({ onOpen }: { onOpen?: () => void }) {
13
+ const { user } = useAuth()
14
 
15
  return (
16
  <div className="md:hidden flex items-center justify-between p-4 bg-[#0F172A] text-white border-b border-slate-800 sticky top-0 z-40">
17
+ <Link href="/dashboard" className="flex items-center gap-3">
18
+ <img src="/logo-v2.png" alt="Logo" className="w-8 h-8 object-contain" />
19
  <span className="font-bold">MicroFunnel</span>
20
+ </Link>
21
+
22
+ <div className="flex items-center gap-2">
23
+ {/* Admin Button for Mobile */}
24
+ {(user?.is_superuser || user?.role === 'admin') && (
25
+ <Link
26
+ href="/admin"
27
+ className="p-2 text-red-400 hover:text-white hover:bg-red-500/20 rounded-lg transition-colors relative"
28
+ >
29
+ <Shield className="w-6 h-6" />
30
+ <span className="absolute top-1.5 right-2 w-2 h-2 bg-red-500 rounded-full border-2 border-[#0F172A]"></span>
31
+ </Link>
32
+ )}
33
+
34
+ <button
35
+ onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
36
+ className="p-2 hover:bg-white/10 rounded-lg"
37
+ >
38
+ <Menu className="w-6 h-6" />
39
+ </button>
40
  </div>
 
 
 
 
 
 
41
  </div>
42
  )
43
  }
frontend/components/Sidebar.tsx CHANGED
@@ -2,7 +2,7 @@
2
 
3
  import Link from 'next/link'
4
  import { usePathname } from 'next/navigation'
5
- import { LayoutDashboard, MessageSquare, Database, DollarSign, Send, LogOut, Brain, Target, Plug, Zap, Users, ChevronRight, Sparkles, Command, User, Building, Bell, Calendar } from 'lucide-react'
6
  import { useAuth } from '@/contexts/AuthContext'
7
  import { motion, AnimatePresence } from 'framer-motion'
8
  import { cn } from '@/lib/utils'
@@ -128,6 +128,27 @@ export function Sidebar() {
128
  Платформа
129
  </p>
130
  <div className="space-y-1">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  <Link href="/dashboard" className={cn(
132
  "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative overflow-hidden",
133
  isActive('/dashboard')
 
2
 
3
  import Link from 'next/link'
4
  import { usePathname } from 'next/navigation'
5
+ import { LayoutDashboard, MessageSquare, Database, DollarSign, Send, LogOut, Brain, Target, Plug, Zap, Users, ChevronRight, Sparkles, Command, User, Building, Bell, Calendar, Shield } from 'lucide-react'
6
  import { useAuth } from '@/contexts/AuthContext'
7
  import { motion, AnimatePresence } from 'framer-motion'
8
  import { cn } from '@/lib/utils'
 
128
  Платформа
129
  </p>
130
  <div className="space-y-1">
131
+ {/* Admin Link - Only for Superusers */}
132
+ {(user?.is_superuser || user?.role === 'admin') && (
133
+ <Link href="/admin" className={cn(
134
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-bold transition-all duration-200 group relative mb-2",
135
+ isActive('/admin')
136
+ ? "text-white bg-gradient-to-r from-red-600 to-red-500 shadow-lg shadow-red-900/20"
137
+ : "text-red-100/90 hover:text-white hover:bg-red-500/20"
138
+ )}>
139
+ {isActive('/admin') && (
140
+ <motion.div
141
+ layoutId="activeTab"
142
+ className="absolute inset-0 bg-gradient-to-r from-red-600 to-red-500 rounded-xl -z-10"
143
+ transition={{ type: "spring", stiffness: 300, damping: 30 }}
144
+ />
145
+ )}
146
+ <Shield className={cn("w-5 h-5 transition-colors", isActive('/admin') ? "text-white" : "text-red-400 group-hover:text-red-200")} />
147
+ <span>Admin Panel</span>
148
+ {isActive('/admin') && <div className="ml-auto w-1.5 h-1.5 rounded-full bg-white animate-pulse" />}
149
+ </Link>
150
+ )}
151
+
152
  <Link href="/dashboard" className={cn(
153
  "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative overflow-hidden",
154
  isActive('/dashboard')