2026-06-03 03:12:14 +07:00
|
|
|
import { motion } from "framer-motion";
|
2026-06-13 11:24:42 +07:00
|
|
|
import { LayoutDashboard, MessageSquare, Radio } from "lucide-react";
|
2026-06-13 11:46:15 +07:00
|
|
|
import type { DashboardTab } from "../shared/api/client";
|
2026-06-03 15:01:34 +07:00
|
|
|
import type { MessageRecord } from "../shared/api/client";
|
|
|
|
|
import { useMascotChat } from "../shared/hooks/useMascotChat";
|
2026-06-01 16:42:36 +07:00
|
|
|
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-06-01 21:44:29 +07:00
|
|
|
const navItems: Array<{ id: DashboardTab; label: string; icon: typeof Radio }> =
|
|
|
|
|
[
|
2026-06-13 12:50:13 +07:00
|
|
|
{ id: "messages", label: "Messages & Moderation", icon: MessageSquare },
|
|
|
|
|
{ id: "live", label: "Voice & Media", icon: Radio },
|
2026-06-13 11:24:42 +07:00
|
|
|
{ id: "dashboard", label: "Dashboard", icon: LayoutDashboard },
|
2026-06-01 21:44:29 +07:00
|
|
|
];
|
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-06-01 16:42:36 +07:00
|
|
|
}
|
|
|
|
|
|
2026-06-03 03:12:14 +07:00
|
|
|
export function Sidebar({
|
|
|
|
|
activeTab,
|
|
|
|
|
onTabChange,
|
|
|
|
|
collapsed = true,
|
2026-06-03 15:01:34 +07:00
|
|
|
recentMessages = [],
|
|
|
|
|
guildId,
|
|
|
|
|
channelId,
|
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-06-03 15:01:34 +07:00
|
|
|
lastActivity: recentMessages.length > 0 ? "Active" : "Idle",
|
2026-06-09 10:16:04 +07:00
|
|
|
topicsDiscussed: ["Messages", "Moderation"],
|
2026-06-03 15:01:34 +07:00
|
|
|
guildId,
|
|
|
|
|
channelId,
|
|
|
|
|
});
|
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-06-12 23:00:52 +07:00
|
|
|
"relative hidden shrink-0 flex-col overflow-visible border-r border-border/50 bg-background/70 backdrop-blur-sm transition-all duration-300 md:flex",
|
2026-06-03 18:29:54 +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-06-03 18:29:54 +07:00
|
|
|
{/* App icon only — no branding text */}
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex items-center py-5",
|
|
|
|
|
collapsed ? "justify-center" : "flex-col px-4",
|
|
|
|
|
)}
|
2026-06-03 15:01:34 +07:00
|
|
|
>
|
2026-06-03 18:29:54 +07:00
|
|
|
<img
|
|
|
|
|
src="https://raw.githubusercontent.com/IMPHNEN/imphnen-frontend-service/develop/docs/logo.svg"
|
2026-06-12 23:00:52 +07:00
|
|
|
alt="IMPHNEN"
|
2026-06-03 18:29:54 +07:00
|
|
|
className="h-8 w-8 rounded-xl"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Mascot image — only when expanded */}
|
|
|
|
|
{!collapsed && (
|
|
|
|
|
<img
|
|
|
|
|
src="https://raw.githubusercontent.com/IMPHNEN/imphnen-frontend-service/develop/apps/dimentorin/public/image/mascot-1.png"
|
|
|
|
|
alt="Mascot"
|
|
|
|
|
className="mt-4 h-auto w-[140px] object-contain drop-shadow-md"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Navigation items */}
|
|
|
|
|
<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(
|
|
|
|
|
"group relative flex items-center rounded-xl p-2.5 text-sm font-medium transition-all duration-200 ease-out",
|
|
|
|
|
collapsed ? "justify-center" : "gap-3",
|
|
|
|
|
isActive
|
2026-06-12 23:00:52 +07:00
|
|
|
? "bg-primary/10 text-primary ring-1 ring-primary/20"
|
|
|
|
|
: "text-muted-foreground hover:bg-primary/5 hover:text-primary/70",
|
2026-06-03 18:29:54 +07:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<Icon className="h-4 w-4 shrink-0" />
|
|
|
|
|
{!collapsed && <span>{item.label}</span>}
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Spacer pushes mascot to bottom */}
|
|
|
|
|
<div className="flex-1" />
|
|
|
|
|
|
2026-06-03 20:09:45 +07:00
|
|
|
{/* Mascot button */}
|
|
|
|
|
<div className="flex justify-center pb-4">
|
2026-06-03 18:29:54 +07:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => mascotChat.setIsOpen(!mascotChat.isOpen)}
|
2026-06-12 23:00:52 +07:00
|
|
|
className="relative z-50 rounded-xl p-1 transition-transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-primary/40"
|
2026-06-03 18:29:54 +07:00
|
|
|
title="Chat dengan mascot"
|
|
|
|
|
>
|
|
|
|
|
<MascotImage size="sm" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</motion.nav>
|
|
|
|
|
<MascotChatbot
|
|
|
|
|
isOpen={mascotChat.isOpen}
|
|
|
|
|
onClose={() => mascotChat.setIsOpen(false)}
|
|
|
|
|
onSendMessage={mascotChat.handleSendMessage}
|
2026-06-12 23:00:52 +07:00
|
|
|
mascotName="IMPHNEN Mascot"
|
2026-06-03 18:29:54 +07:00
|
|
|
className="fixed bottom-[170px] left-[80px] z-[9999]"
|
|
|
|
|
/>
|
2026-06-03 17:50:11 +07:00
|
|
|
</>
|
2026-06-01 16:42:36 +07:00
|
|
|
);
|
|
|
|
|
}
|