2026-06-03 03:12:14 +07:00
|
|
|
import { motion } from "framer-motion";
|
2026-07-02 00:02:41 +07:00
|
|
|
import { Moon, Sun, Wifi, WifiOff } from "lucide-react";
|
2026-07-02 01:18:45 +07:00
|
|
|
import { fadeSlideUp } from "../hooks/useFramerStagger";
|
2026-07-02 00:02:41 +07:00
|
|
|
import type { ThemeMode } from "../hooks/useTheme";
|
2026-07-02 01:18:45 +07:00
|
|
|
import { cn } from "../lib/utils";
|
|
|
|
|
import type { DashboardTab } from "../types/ui-types.js";
|
|
|
|
|
import type { VoiceStatus } from "../types/voice.js";
|
|
|
|
|
import type { WsStatus } from "../ws/socket";
|
|
|
|
|
import { Badge } from "./badge";
|
2026-05-16 19:17:34 +07:00
|
|
|
|
|
|
|
|
const titles: Record<DashboardTab, string> = {
|
2026-05-30 16:13:09 +07:00
|
|
|
messages: "Messages & Moderation",
|
2026-06-13 12:50:13 +07:00
|
|
|
live: "Voice & Media",
|
2026-06-13 11:24:42 +07:00
|
|
|
dashboard: "Dashboard",
|
2026-07-02 00:02:41 +07:00
|
|
|
settings: "Admin Settings",
|
2026-05-16 19:17:34 +07:00
|
|
|
};
|
|
|
|
|
|
2026-05-30 16:13:09 +07:00
|
|
|
const subtitles: Record<DashboardTab, string> = {
|
|
|
|
|
messages: "Capture, analyse, and moderate Discord messages.",
|
2026-06-13 12:50:13 +07:00
|
|
|
live: "Join voice channels, play media, stream audio, and browse recordings.",
|
2026-06-13 11:24:42 +07:00
|
|
|
dashboard: "Server statistics, user profiles, and AI moderation overview.",
|
2026-07-02 01:18:45 +07:00
|
|
|
settings:
|
|
|
|
|
"Manage dashboard visibility, runtime configuration, and authentication.",
|
2026-05-30 16:13:09 +07:00
|
|
|
};
|
|
|
|
|
|
2026-05-16 19:17:34 +07:00
|
|
|
interface HeaderProps {
|
|
|
|
|
activeTab: DashboardTab;
|
2026-06-01 16:42:36 +07:00
|
|
|
wsStatus: WsStatus;
|
2026-05-16 19:17:34 +07:00
|
|
|
voiceStatus: VoiceStatus;
|
2026-07-02 00:02:41 +07:00
|
|
|
themeMode: ThemeMode;
|
|
|
|
|
isDark: boolean;
|
|
|
|
|
onThemeToggle: () => void;
|
2026-05-16 19:17:34 +07:00
|
|
|
}
|
|
|
|
|
|
2026-06-03 03:12:14 +07:00
|
|
|
/** Dot indicator colour for WS badge */
|
|
|
|
|
function wsDotColor(status: WsStatus): string {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case "connected":
|
|
|
|
|
return "bg-emerald-400";
|
|
|
|
|
case "error":
|
|
|
|
|
return "bg-red-400";
|
|
|
|
|
case "connecting":
|
|
|
|
|
case "disconnected":
|
|
|
|
|
return "bg-gray-400";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function WsIndicator({ status }: { status: WsStatus }) {
|
|
|
|
|
const dot = wsDotColor(status);
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
|
<span className={cn("inline-block h-2 w-2 rounded-full", dot)} />
|
|
|
|
|
<span className="text-xs font-medium capitalize">{status}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Voice status indicator dot */
|
|
|
|
|
function VoiceIndicator({ voiceStatus }: { voiceStatus: VoiceStatus }) {
|
|
|
|
|
const isConnected = voiceStatus.connected;
|
2026-06-12 23:00:52 +07:00
|
|
|
const dot = isConnected ? "bg-primary" : "bg-gray-300";
|
2026-06-03 03:12:14 +07:00
|
|
|
const label = isConnected
|
|
|
|
|
? voiceStatus.activeChannelName || "connected"
|
|
|
|
|
: "idle";
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
|
<span className={cn("inline-block h-2 w-2 rounded-full", dot)} />
|
|
|
|
|
<span className="text-xs font-medium">{label}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-02 01:18:45 +07:00
|
|
|
export function Header({
|
|
|
|
|
activeTab,
|
|
|
|
|
wsStatus,
|
|
|
|
|
voiceStatus,
|
|
|
|
|
themeMode,
|
|
|
|
|
isDark,
|
|
|
|
|
onThemeToggle,
|
|
|
|
|
}: HeaderProps) {
|
2026-05-16 19:17:34 +07:00
|
|
|
return (
|
2026-06-12 23:00:52 +07:00
|
|
|
<header className="sticky top-0 z-10 border-b border-border/50 bg-background/70 px-4 py-4 backdrop-blur-sm md:px-8">
|
2026-05-16 19:17:34 +07:00
|
|
|
<div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
2026-06-12 23:00:52 +07:00
|
|
|
{/* Left: IMPHNEN brand + tab title */}
|
2026-06-03 03:12:14 +07:00
|
|
|
<motion.div
|
|
|
|
|
key={activeTab}
|
|
|
|
|
variants={fadeSlideUp}
|
|
|
|
|
initial="initial"
|
|
|
|
|
animate="animate"
|
|
|
|
|
className="flex items-center gap-3"
|
|
|
|
|
>
|
2026-06-12 23:00:52 +07:00
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<img
|
|
|
|
|
src="https://raw.githubusercontent.com/IMPHNEN/imphnen-frontend-service/develop/docs/logo.svg"
|
|
|
|
|
alt="IMPHNEN"
|
|
|
|
|
className="h-7 w-7"
|
|
|
|
|
/>
|
2026-05-30 16:34:18 +07:00
|
|
|
<h1 className="text-xl font-bold tracking-tight">
|
2026-06-12 23:00:52 +07:00
|
|
|
<span className="gradient-text">IMPHNEN</span>
|
2026-05-30 16:34:18 +07:00
|
|
|
<span className="mx-2 text-muted-foreground">·</span>
|
|
|
|
|
{titles[activeTab]}
|
|
|
|
|
</h1>
|
2026-05-30 16:13:09 +07:00
|
|
|
</div>
|
2026-06-12 23:00:52 +07:00
|
|
|
<p className="text-sm text-muted-foreground hidden md:block">
|
|
|
|
|
{subtitles[activeTab]}
|
|
|
|
|
</p>
|
2026-06-03 03:12:14 +07:00
|
|
|
</motion.div>
|
|
|
|
|
|
2026-07-02 00:02:41 +07:00
|
|
|
{/* Right: status badges + theme toggle */}
|
2026-06-03 03:12:14 +07:00
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
2026-07-02 00:02:41 +07:00
|
|
|
{/* Theme toggle */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={onThemeToggle}
|
|
|
|
|
className="flex items-center gap-1.5 rounded-lg border border-border bg-card/50 px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors"
|
|
|
|
|
title={`Switch to ${isDark ? "light" : "dark"} mode`}
|
|
|
|
|
>
|
|
|
|
|
{isDark ? (
|
|
|
|
|
<Sun className="h-3.5 w-3.5 text-amber-400" />
|
|
|
|
|
) : (
|
|
|
|
|
<Moon className="h-3.5 w-3.5 text-indigo-400" />
|
|
|
|
|
)}
|
2026-07-02 01:18:45 +07:00
|
|
|
<span className="hidden sm:inline">
|
|
|
|
|
{isDark ? "Light" : "Dark"}
|
|
|
|
|
</span>
|
2026-07-02 00:02:41 +07:00
|
|
|
</button>
|
|
|
|
|
|
2026-06-03 03:12:14 +07:00
|
|
|
{/* WS Badge */}
|
2026-06-01 21:44:29 +07:00
|
|
|
<Badge
|
2026-06-03 03:12:14 +07:00
|
|
|
variant="outline"
|
2026-06-12 23:00:52 +07:00
|
|
|
className="border-border bg-card/50 px-3 py-1.5 text-xs text-muted-foreground"
|
2026-06-01 21:44:29 +07:00
|
|
|
>
|
|
|
|
|
{wsStatus === "connected" ? (
|
2026-06-03 03:12:14 +07:00
|
|
|
<Wifi className="mr-1.5 h-3 w-3 text-emerald-400" />
|
2026-06-01 21:44:29 +07:00
|
|
|
) : (
|
2026-06-03 03:12:14 +07:00
|
|
|
<WifiOff className="mr-1.5 h-3 w-3 text-red-400" />
|
2026-06-01 21:44:29 +07:00
|
|
|
)}
|
2026-06-03 03:12:14 +07:00
|
|
|
<WsIndicator status={wsStatus} />
|
2026-05-16 19:17:34 +07:00
|
|
|
</Badge>
|
2026-06-03 03:12:14 +07:00
|
|
|
|
|
|
|
|
{/* Voice Badge */}
|
|
|
|
|
<Badge
|
|
|
|
|
variant="outline"
|
|
|
|
|
className={cn(
|
2026-06-12 23:00:52 +07:00
|
|
|
"border-border bg-card/50 px-3 py-1.5 text-xs",
|
|
|
|
|
voiceStatus.connected ? "text-primary" : "text-muted-foreground",
|
2026-06-03 03:12:14 +07:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<VoiceIndicator voiceStatus={voiceStatus} />
|
2026-05-16 19:17:34 +07:00
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|