import { useState } from "react";
import {
faArrowRightFromBracket,
faBullhorn,
faChartMixed,
faChevronLeft,
faChevronRight,
faClockRotateLeft,
faCommentDots,
faGear,
faGrid2,
faHospitalUser,
faPhone,
faPlug,
faUsers,
} from "@fortawesome/pro-duotone-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useAtom } from "jotai";
import { Link, useNavigate } from "react-router";
import { MobileNavigationHeader } from "@/components/application/app-navigation/base-components/mobile-header";
import { NavAccountCard } from "@/components/application/app-navigation/base-components/nav-account-card";
import { NavItemBase } from "@/components/application/app-navigation/base-components/nav-item";
import type { NavItemType } from "@/components/application/app-navigation/config";
import { Dialog, Modal, ModalOverlay } from "@/components/application/modals/modal";
import { Avatar } from "@/components/base/avatar/avatar";
import { Button } from "@/components/base/buttons/button";
import { apiClient } from "@/lib/api-client";
import { faIcon } from "@/lib/icon-wrapper";
import { notify } from "@/lib/toast";
import { useAuth } from "@/providers/auth-provider";
import { sidebarCollapsedAtom } from "@/state/sidebar-state";
import { cx } from "@/utils/cx";
const EXPANDED_WIDTH = 292;
const COLLAPSED_WIDTH = 64;
const IconGrid2 = faIcon(faGrid2);
const IconBullhorn = faIcon(faBullhorn);
const IconCommentDots = faIcon(faCommentDots);
const IconChartMixed = faIcon(faChartMixed);
const IconPlug = faIcon(faPlug);
const IconGear = faIcon(faGear);
const IconPhone = faIcon(faPhone);
const IconClockRewind = faIcon(faClockRotateLeft);
const IconUsers = faIcon(faUsers);
const IconHospitalUser = faIcon(faHospitalUser);
type NavSection = {
label: string;
items: NavItemType[];
};
const getNavSections = (role: string): NavSection[] => {
if (role === "admin") {
return [
{ label: "Overview", items: [{ label: "Team Dashboard", href: "/", icon: IconGrid2 }] },
{
label: "Management",
items: [
{ label: "Campaigns", href: "/campaigns", icon: IconBullhorn },
{ label: "Analytics", href: "/reports", icon: IconChartMixed },
],
},
{
label: "Admin",
items: [
{ label: "Integrations", href: "/integrations", icon: IconPlug },
{ label: "Settings", href: "/settings", icon: IconGear },
],
},
];
}
if (role === "cc-agent") {
return [
{
label: "Call Center",
items: [
{ label: "Call Desk", href: "/", icon: IconPhone },
{ label: "Call History", href: "/call-history", icon: IconClockRewind },
{ label: "Patients", href: "/patients", icon: IconHospitalUser },
{ label: "My Performance", href: "/my-performance", icon: IconChartMixed },
],
},
];
}
return [
{
label: "Main",
items: [
{ label: "Lead Workspace", href: "/", icon: IconGrid2 },
{ label: "All Leads", href: "/leads", icon: IconUsers },
{ label: "Patients", href: "/patients", icon: IconHospitalUser },
{ label: "Campaigns", href: "/campaigns", icon: IconBullhorn },
{ label: "Outreach", href: "/outreach", icon: IconCommentDots },
],
},
{ label: "Insights", items: [{ label: "Analytics", href: "/reports", icon: IconChartMixed }] },
];
};
const getRoleSubtitle = (role: string): string => {
switch (role) {
case "admin":
return "Marketing Admin";
case "cc-agent":
return "Call Center Agent";
default:
return "Marketing Executive";
}
};
interface SidebarProps {
activeUrl?: string;
}
export const Sidebar = ({ activeUrl = "/" }: SidebarProps) => {
const { logout, user } = useAuth();
const navigate = useNavigate();
const [collapsed, setCollapsed] = useAtom(sidebarCollapsedAtom);
const width = collapsed ? COLLAPSED_WIDTH : EXPANDED_WIDTH;
const [logoutOpen, setLogoutOpen] = useState(false);
const handleSignOut = () => {
setLogoutOpen(true);
};
const confirmSignOut = () => {
setLogoutOpen(false);
logout();
navigate("/login");
};
const handleForceReady = async () => {
try {
await apiClient.post("/api/ozonetel/agent-ready", {});
notify.success("Agent Ready", "Agent state has been reset to Ready");
} catch {
notify.error("Force Ready Failed", "Could not reset agent state");
}
};
const navSections = getNavSections(user.role);
const content = (
);
return (
<>