import React, { useEffect } from "react"; import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarHeader, SidebarFooter, } from "@/components/ui/sidebar"; import { LayoutDashboard, Users, DollarSign, LogOut } from "lucide-react"; import { Link, useLocation } from "react-router-dom"; import { useUserStore } from "@/stores/userStore"; import { useAuthStore } from "@/stores/authStore"; const AppSidebar: React.FC = () => { const { pathname } = useLocation(); const { user, fetchUser } = useUserStore(); const { logout } = useAuthStore(); useEffect(() => { // Get user ID from localStorage const userStr = localStorage.getItem("aff-user"); if (userStr) { const userData = JSON.parse(userStr); if (userData.id) { fetchUser(userData.id); } } }, [fetchUser]); const links = [ { name: "Overview", path: "/dashboard/overview", icon: LayoutDashboard }, { name: "Referrals", path: "/dashboard/referrals", icon: Users }, { name: "Earnings", path: "/dashboard/earnings", icon: DollarSign }, ]; return (
Logo

Affiliate Panel

Manage your earnings

{links.map(({ name, path, icon: Icon }) => ( {name} ))}

Total Earnings

$3,200

+15% this month

{user?.first_name ? user.first_name.charAt(0) : "U"}

{user?.first_name || "John Doe"} {user?.last_name || ""}

{user?.email}

); }; export default AppSidebar;