Spaces:
Sleeping

axeronis commited on
Commit
5b82704
·
1 Parent(s): 36a8ee1

feat: add language/profile to mobile header

Browse files
Files changed (1) hide show
  1. frontend/components/MobileNav.tsx +47 -9
frontend/components/MobileNav.tsx CHANGED
@@ -8,34 +8,72 @@ import { useEffect } from 'react'
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>
 
8
  import { Shield } from 'lucide-react'
9
  import Link from 'next/link'
10
  import { useAuth } from '@/contexts/AuthContext'
11
+ import { LanguageSwitcher } from './LanguageSwitcher'
12
+ import { cn } from '@/lib/utils'
13
 
14
  export function MobileHeader({ onOpen }: { onOpen?: () => void }) {
15
  const { user } = useAuth()
16
 
17
+ // Get user initials for avatar
18
+ const getInitials = (name?: string | null, email?: string) => {
19
+ if (name) {
20
+ return name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2)
21
+ }
22
+ if (email) {
23
+ return email.slice(0, 2).toUpperCase()
24
+ }
25
+ return 'U'
26
+ }
27
+
28
+ // Generate random avatar color based on user email
29
+ const getAvatarColor = (email?: string) => {
30
+ if (!email) return 'bg-indigo-600'
31
+ const colors = ['bg-indigo-600', 'bg-purple-600', 'bg-pink-600', 'bg-blue-600']
32
+ const index = email.charCodeAt(0) % colors.length
33
+ return colors[index]
34
+ }
35
+
36
  return (
37
+ <div className="md:hidden flex items-center justify-between p-3 bg-[#0F172A] text-white border-b border-slate-800 sticky top-0 z-40">
38
+ {/* Logo */}
39
+ <Link href="/dashboard" className="flex items-center gap-2">
40
+ <img src="/logo-v2.png" alt="Logo" className="w-7 h-7 object-contain" />
41
+ <span className="font-bold text-sm">MicroFunnel</span>
42
  </Link>
43
 
44
+ {/* Right side: Language, Profile, Admin, Menu */}
45
+ <div className="flex items-center gap-1">
46
+ {/* Language Switcher */}
47
+ <LanguageSwitcher />
48
+
49
+ {/* Profile Avatar */}
50
+ <Link
51
+ href="/settings/billing"
52
+ className={cn(
53
+ "w-8 h-8 rounded-lg flex items-center justify-center text-white font-bold text-xs shadow-lg border border-white/10",
54
+ getAvatarColor(user?.email)
55
+ )}
56
+ >
57
+ {getInitials(user?.full_name, user?.email)}
58
+ </Link>
59
+
60
+ {/* Admin Button */}
61
  {(user?.is_superuser || user?.role === 'admin') && (
62
  <Link
63
  href="/admin"
64
  className="p-2 text-red-400 hover:text-white hover:bg-red-500/20 rounded-lg transition-colors relative"
65
  >
66
+ <Shield className="w-5 h-5" />
67
+ <span className="absolute top-1 right-1 w-1.5 h-1.5 bg-red-500 rounded-full"></span>
68
  </Link>
69
  )}
70
 
71
+ {/* Hamburger Menu */}
72
  <button
73
  onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
74
  className="p-2 hover:bg-white/10 rounded-lg"
75
  >
76
+ <Menu className="w-5 h-5" />
77
  </button>
78
  </div>
79
  </div>