2026-07-02 05:58:36 +07:00
|
|
|
/* ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
|
* IMPHNEN Sidebar — Navigation command center
|
|
|
|
|
* Minimal, collapsed by default, dengan Mascot yang playful.
|
|
|
|
|
* Fokus: Guild Moderation Watcher untuk komunitas IMPHNEN.
|
|
|
|
|
* ═══════════════════════════════════════════════════════════════════════════ */
|
|
|
|
|
|
2026-06-03 03:12:14 +07:00
|
|
|
import { motion } from "framer-motion";
|
2026-07-02 05:58:36 +07:00
|
|
|
import {
|
|
|
|
|
LayoutDashboard,
|
|
|
|
|
MessageSquare,
|
|
|
|
|
Radio,
|
|
|
|
|
} from "lucide-react";
|
2026-07-02 03:54:44 +07:00
|
|
|
import type { MessageRecord } from "../entities/message/types.js";
|
|
|
|
|
import type { DashboardTab } from "../entities/ui/types.js";
|
|
|
|
|
import { useMascotChat } from "../shared/hooks/useMascotChat";
|
|
|
|
|
import { cn } from "../shared/lib/utils";
|
2026-06-03 15:01:34 +07:00
|
|
|
import { MascotChatbot } from "./mascot/MascotChatbot";
|
2026-06-03 13:56:11 +07:00
|
|
|
import { MascotImage } from "./mascot/MascotImage";
|
2026-06-01 16:42:36 +07:00
|
|
|
|
2026-07-02 05:58:36 +07:00
|
|
|
const navItems: Array<{
|
|
|
|
|
id: DashboardTab;
|
|
|
|
|
label: string;
|
|
|
|
|
icon: typeof Radio;
|
|
|
|
|
badge?: string;
|
|
|
|
|
}> = [
|
|
|
|
|
{
|
|
|
|
|
id: "messages",
|
|
|
|
|
label: "Pesan & Moderasi",
|
|
|
|
|
icon: MessageSquare,
|
|
|
|
|
badge: "Live",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "live",
|
|
|
|
|
label: "Voice & Media",
|
|
|
|
|
icon: Radio,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "dashboard",
|
|
|
|
|
label: "Dashboard Guild",
|
|
|
|
|
icon: LayoutDashboard,
|
|
|
|
|
},
|
|
|
|
|
];
|
2026-06-01 16:42:36 +07:00
|
|
|
|
|
|
|
|
interface SidebarProps {
|
|
|
|
|
activeTab: DashboardTab;
|
|
|
|
|
onTabChange: (tab: DashboardTab) => void;
|
|
|
|
|
collapsed?: boolean;
|
2026-06-03 15:01:34 +07:00
|
|
|
recentMessages?: MessageRecord[];
|
|
|
|
|
guildId?: string;
|
|
|
|
|
channelId?: string;
|
2026-07-02 05:58:36 +07:00
|
|
|
flaggedCount?: number;
|
2026-06-01 16:42:36 +07:00
|
|
|
}
|
|
|
|
|
|
2026-06-03 03:12:14 +07:00
|
|
|
export function Sidebar({
|
|
|
|
|
activeTab,
|
|
|
|
|
onTabChange,
|
2026-07-02 05:58:36 +07:00
|
|
|
collapsed = false,
|
2026-06-03 15:01:34 +07:00
|
|
|
recentMessages = [],
|
|
|
|
|
guildId,
|
|
|
|
|
channelId,
|
2026-07-02 05:58:36 +07:00
|
|
|
flaggedCount = 0,
|
2026-06-03 03:12:14 +07:00
|
|
|
}: SidebarProps) {
|
2026-06-03 15:01:34 +07:00
|
|
|
const mascotChat = useMascotChat({
|
|
|
|
|
messageCount: recentMessages.length,
|
2026-06-03 18:29:54 +07:00
|
|
|
activeParticipants: new Set(
|
|
|
|
|
recentMessages.map((message) => message.user_id),
|
|
|
|
|
).size,
|
2026-07-02 05:58:36 +07:00
|
|
|
lastActivity: recentMessages.length > 0 ? "Aktif" : "Idle",
|
|
|
|
|
topicsDiscussed: ["Pesan", "Moderasi"],
|
2026-06-03 15:01:34 +07:00
|
|
|
guildId,
|
|
|
|
|
channelId,
|
|
|
|
|
});
|
2026-07-02 05:58:36 +07:00
|
|
|
|
2026-06-01 16:42:36 +07:00
|
|
|
return (
|
2026-06-03 17:50:11 +07:00
|
|
|
<>
|
2026-06-03 18:29:54 +07:00
|
|
|
<motion.nav
|
2026-06-01 21:44:29 +07:00
|
|
|
className={cn(
|
2026-07-02 05:58:36 +07:00
|
|
|
"relative hidden shrink-0 flex-col overflow-visible",
|
|
|
|
|
"border-r border-[#e0e0e0]/50",
|
|
|
|
|
"bg-white/70 backdrop-blur-sm",
|
|
|
|
|
"transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]",
|
|
|
|
|
"md:flex",
|
2026-07-02 03:54:44 +07:00
|
|
|
collapsed ? "w-16" : "w-64",
|
2026-06-01 21:44:29 +07:00
|
|
|
)}
|
2026-06-03 18:29:54 +07:00
|
|
|
layout
|
|
|
|
|
transition={{ type: "spring", stiffness: 300, damping: 30 }}
|
2026-06-01 21:44:29 +07:00
|
|
|
>
|
2026-07-02 05:58:36 +07:00
|
|
|
{/* ── Brand Icon ────────────────────────────────────────────── */}
|
2026-06-03 18:29:54 +07:00
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex items-center py-5",
|
|
|
|
|
collapsed ? "justify-center" : "flex-col px-4",
|
|
|
|
|
)}
|
2026-06-03 15:01:34 +07:00
|
|
|
>
|
2026-07-02 05:58:36 +07:00
|
|
|
{/* Logo */}
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<img
|
|
|
|
|
src="https://raw.githubusercontent.com/IMPHNEN/imphnen-frontend-service/develop/docs/logo.svg"
|
|
|
|
|
alt="IMPHNEN"
|
|
|
|
|
className="h-8 w-8 rounded-xl"
|
|
|
|
|
/>
|
|
|
|
|
{/* Live indicator dot */}
|
|
|
|
|
<span className="absolute -top-0.5 -right-0.5 h-2.5 w-2.5 rounded-full bg-[#22c55e] ring-2 ring-white animate-pulse" />
|
|
|
|
|
</div>
|
2026-06-03 18:29:54 +07:00
|
|
|
|
2026-07-02 05:58:36 +07:00
|
|
|
{/* Brand text when expanded */}
|
|
|
|
|
{!collapsed && (
|
|
|
|
|
<div className="mt-4 text-center">
|
|
|
|
|
<h2 className="font-sans text-sm font-bold text-[#1a1a1a]">
|
|
|
|
|
<span className="bg-clip-text text-transparent bg-gradient-to-r from-[#23a1eb] to-[#5865f2]">
|
|
|
|
|
IMPHNEN
|
|
|
|
|
</span>
|
|
|
|
|
</h2>
|
|
|
|
|
<p className="font-sans text-[10px] font-medium text-[#666666] mt-0.5 tracking-wider uppercase">
|
|
|
|
|
Guild Watcher
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Mascot — only when expanded */}
|
2026-06-03 18:29:54 +07:00
|
|
|
{!collapsed && (
|
|
|
|
|
<img
|
|
|
|
|
src="https://raw.githubusercontent.com/IMPHNEN/imphnen-frontend-service/develop/apps/dimentorin/public/image/mascot-1.png"
|
2026-07-02 05:58:36 +07:00
|
|
|
alt="Mascot IMPHNEN"
|
|
|
|
|
className="mt-4 h-auto w-[120px] object-contain drop-shadow-md hover:animate-mascot-wiggle cursor-pointer"
|
|
|
|
|
onClick={() => mascotChat.setIsOpen(!mascotChat.isOpen)}
|
2026-06-03 18:29:54 +07:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-02 05:58:36 +07:00
|
|
|
{/* ── Navigation Items ──────────────────────────────────────── */}
|
2026-06-13 19:47:06 +07:00
|
|
|
<div className="flex flex-1 flex-col justify-center">
|
|
|
|
|
<div className="flex flex-col gap-1 px-2">
|
|
|
|
|
{navItems.map((item) => {
|
|
|
|
|
const Icon = item.icon;
|
|
|
|
|
const isActive = activeTab === item.id;
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={item.id}
|
|
|
|
|
onClick={() => onTabChange(item.id)}
|
|
|
|
|
title={collapsed ? item.label : undefined}
|
|
|
|
|
className={cn(
|
2026-07-02 05:58:36 +07:00
|
|
|
"group relative flex items-center rounded-xl p-2.5",
|
|
|
|
|
"font-sans text-sm font-medium",
|
|
|
|
|
"transition-all duration-200 ease-[cubic-bezier(0.4,0,0.2,1)]",
|
2026-06-13 19:47:06 +07:00
|
|
|
collapsed ? "justify-center" : "gap-3",
|
|
|
|
|
isActive
|
2026-07-02 05:58:36 +07:00
|
|
|
? "bg-[#e1f0fd] text-[#23a1eb] ring-1 ring-[#23a1eb]/20"
|
|
|
|
|
: "text-[#666666] hover:bg-[#e1f0fd]/50 hover:text-[#23a1eb]/70",
|
2026-06-13 19:47:06 +07:00
|
|
|
)}
|
|
|
|
|
>
|
2026-07-02 05:58:36 +07:00
|
|
|
<div className="relative">
|
|
|
|
|
<Icon className="h-4 w-4 shrink-0" />
|
|
|
|
|
{/* Flagged dot indicator */}
|
|
|
|
|
{item.id === "messages" && flaggedCount > 0 && (
|
|
|
|
|
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-[#e4405f] ring-1 ring-white" />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{!collapsed && (
|
|
|
|
|
<div className="flex items-center justify-between flex-1 min-w-0">
|
|
|
|
|
<span>{item.label}</span>
|
|
|
|
|
{item.badge && (
|
|
|
|
|
<span className="font-sans text-[10px] font-semibold text-[#23a1eb] bg-[#e1f0fd] px-1.5 py-0.5 rounded-full">
|
|
|
|
|
{item.badge}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-06-13 19:47:06 +07:00
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
2026-06-03 18:29:54 +07:00
|
|
|
</div>
|
|
|
|
|
|
2026-07-02 05:58:36 +07:00
|
|
|
{/* ── Bottom: Mascot Chat Button ────────────────────────────── */}
|
2026-06-03 20:09:45 +07:00
|
|
|
<div className="flex justify-center pb-4">
|
2026-06-03 18:29:54 +07:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => mascotChat.setIsOpen(!mascotChat.isOpen)}
|
2026-07-02 05:58:36 +07:00
|
|
|
className={cn(
|
|
|
|
|
"relative z-50 rounded-xl p-1.5",
|
|
|
|
|
"transition-all duration-200 hover:scale-105",
|
|
|
|
|
"focus:outline-none focus:ring-2 focus:ring-[#23a1eb]/40",
|
|
|
|
|
mascotChat.isOpen && "bg-[#e1f0fd] ring-1 ring-[#23a1eb]/30",
|
|
|
|
|
)}
|
|
|
|
|
title="Chat dengan Mascot"
|
2026-06-03 18:29:54 +07:00
|
|
|
>
|
2026-07-02 05:58:36 +07:00
|
|
|
<div className="relative">
|
|
|
|
|
<MascotImage size="sm" />
|
|
|
|
|
{mascotChat.isOpen && (
|
|
|
|
|
<span className="absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-[#23a1eb] ring-1 ring-white" />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-06-03 18:29:54 +07:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</motion.nav>
|
2026-07-02 05:58:36 +07:00
|
|
|
|
|
|
|
|
{/* ── Mascot Chatbot Panel ────────────────────────────────────── */}
|
2026-06-03 18:29:54 +07:00
|
|
|
<MascotChatbot
|
|
|
|
|
isOpen={mascotChat.isOpen}
|
|
|
|
|
onClose={() => mascotChat.setIsOpen(false)}
|
|
|
|
|
onSendMessage={mascotChat.handleSendMessage}
|
2026-07-02 05:58:36 +07:00
|
|
|
mascotName="Mascot IMPHNEN"
|
2026-07-02 03:54:44 +07:00
|
|
|
className="fixed bottom-[170px] left-[80px] z-[9999]"
|
2026-06-03 18:29:54 +07:00
|
|
|
/>
|
2026-06-03 17:50:11 +07:00
|
|
|
</>
|
2026-06-01 16:42:36 +07:00
|
|
|
);
|
|
|
|
|
}
|