diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index 94e0a83..ad9aacd 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -46,6 +46,7 @@ import ContactMessagesPage from './pages/ContactMessagesPage' import ProductAttributesPage from './pages/ProductAttributesPage' import TiktokPriceSimulatorPage from './pages/TiktokPriceSimulatorPage' import TiktokShopCasePage from './pages/TiktokShopCasePage' +import ShopeeShopCasePage from './pages/ShopeeShopCasePage' function App() { return ( @@ -92,6 +93,7 @@ function App() { } /> } /> } /> + } /> } /> } /> } /> diff --git a/apps/admin/src/components/AdminLayout.tsx b/apps/admin/src/components/AdminLayout.tsx index c4301a4..036eef3 100644 --- a/apps/admin/src/components/AdminLayout.tsx +++ b/apps/admin/src/components/AdminLayout.tsx @@ -1,11 +1,14 @@ +import { useState } from 'react' import { Outlet } from 'react-router-dom' import Sidebar from './Sidebar' export default function AdminLayout() { + const [isCollapsed, setIsCollapsed] = useState(false) + return (
- -
+ setIsCollapsed(!isCollapsed)} /> +
diff --git a/apps/admin/src/components/Sidebar.tsx b/apps/admin/src/components/Sidebar.tsx index 8068b85..7d60d14 100644 --- a/apps/admin/src/components/Sidebar.tsx +++ b/apps/admin/src/components/Sidebar.tsx @@ -29,36 +29,62 @@ import { Sparkles, Calculator, Info, + ChevronLeft, } from 'lucide-react' const MAIN_MENU = [ { icon: LayoutDashboard, label: 'Dashboard', to: '/' }, +] + +const PRODUCT_MENU = [ { icon: Tags, label: 'Categories', to: '/categories' }, { icon: Package, label: 'Products', to: '/products' }, { icon: Ruler, label: 'Product Attributes', to: '/product-attributes' }, { icon: PackageOpen, label: 'Raw Materials', to: '/raw-materials' }, - { icon: Users, label: 'LINE Customers', to: '/customers' }, +] + +const SALES_MENU = [ { icon: ShoppingCart, label: 'Orders', to: '/orders' }, { icon: Ticket, label: 'Promotions', to: '/promotions' }, { icon: Ticket, label: 'Coupons', to: '/coupons' }, - { icon: Layers, label: 'Page Builder (CMS)', to: '/page-builder' }, - { icon: Sparkles, label: 'CMS Block Showcase', to: '/cms-mockup' }, - { icon: ImageIcon, label: 'Media Library', to: '/media' }, - { icon: BookOpen, label: 'Scent Guide', to: '/articles' }, - { icon: TrendingUp, label: 'TikTok Data', to: '/tiktok' }, - { icon: TrendingUp, label: 'TikTok Analysis', to: '/tiktok-analysis' }, - { icon: ShoppingBag, label: 'Shopee (Hom Aroma)', to: '/shopee' }, - { icon: BarChart3, label: 'Shopee Analytics', to: '/shopee-analytics' }, - { icon: Layers, label: 'Shopee ทุกร้าน', to: '/shopee-overview' }, + { icon: Globe2, label: 'All Analytics', to: '/global-analytics' }, +] + +const TIKTOK_MENU = [ { icon: ShoppingCart, label: 'TikTok Orders', to: '/tiktok-order' }, { icon: BarChart3, label: 'TikTok Analytics', to: '/tiktok-analytics' }, { icon: Layers, label: 'TikTok ทุกร้าน', to: '/tiktok-overview' }, { icon: Calculator, label: 'TikTok Price Simulator', to: '/tiktok-price-simulator' }, { icon: Info, label: 'TikTok Shop Case', to: '/tiktok-shop-case' }, +] + +const TIKTOK_LEGACY_MENU = [ + { icon: TrendingUp, label: 'TikTok Report Import', to: '/tiktok' }, + { icon: TrendingUp, label: 'Product SKU Analysis', to: '/tiktok-analysis' }, +] + +const SHOPEE_MENU = [ + { icon: ShoppingBag, label: 'Shopee (Hom Aroma)', to: '/shopee' }, + { icon: BarChart3, label: 'Shopee Analytics', to: '/shopee-analytics' }, + { icon: Layers, label: 'Shopee ทุกร้าน', to: '/shopee-overview' }, + { icon: Info, label: 'Shopee Shop Case', to: '/shopee-shop-case' }, +] + +const LAZADA_MENU = [ { icon: ShoppingCart, label: 'Lazada Orders', to: '/lazada-order' }, { icon: BarChart3, label: 'Lazada Analytics', to: '/lazada-analytics' }, { icon: Layers, label: 'Lazada ทุกร้าน', to: '/lazada-overview' }, - { icon: Globe2, label: 'All Analytics', to: '/global-analytics' }, +] + +const CMS_MENU = [ + { icon: Layers, label: 'Page Builder (CMS)', to: '/page-builder' }, + { icon: Sparkles, label: 'CMS Block Showcase', to: '/cms-mockup' }, + { icon: ImageIcon, label: 'Media Library', to: '/media' }, + { icon: BookOpen, label: 'Scent Guide', to: '/articles' }, +] + +const CUSTOMER_MENU = [ + { icon: Users, label: 'LINE Customers', to: '/customers' }, { icon: Users, label: 'Subscribers', to: '/subscribers' }, { icon: MessageSquare, label: 'Contact Messages', to: '/contacts' }, ] @@ -78,11 +104,33 @@ const SETTINGS_MENU = [ { icon: Wrench, label: 'System', to: '/settings/system' }, ] -export default function Sidebar() { +interface SidebarProps { + isCollapsed: boolean + onToggle: () => void +} + +export default function Sidebar({ isCollapsed, onToggle }: SidebarProps) { const navigate = useNavigate() const location = useLocation() + const isInProduct = ['/categories', '/products', '/product-attributes', '/raw-materials'].some(p => location.pathname.startsWith(p)) + const isInSales = ['/orders', '/promotions', '/coupons', '/global-analytics'].some(p => location.pathname.startsWith(p)) + const isInTiktokLegacy = location.pathname === '/tiktok' || location.pathname.startsWith('/tiktok-analysis') + const isInTiktok = location.pathname.startsWith('/tiktok') && !isInTiktokLegacy + const isInShopee = location.pathname.startsWith('/shopee') + const isInLazada = location.pathname.startsWith('/lazada') + const isInCms = ['/page-builder', '/cms-mockup', '/media', '/articles'].some(p => location.pathname.startsWith(p)) + const isInCustomer = ['/customers', '/subscribers', '/contacts'].some(p => location.pathname.startsWith(p)) const isInMenuManager = location.pathname.startsWith('/menu-manager') const isInSettings = location.pathname.startsWith('/settings') + + const [productOpen, setProductOpen] = useState(isInProduct) + const [salesOpen, setSalesOpen] = useState(isInSales) + const [tiktokOpen, setTiktokOpen] = useState(isInTiktok) + const [tiktokLegacyOpen, setTiktokLegacyOpen] = useState(isInTiktokLegacy) + const [shopeeOpen, setShopeeOpen] = useState(isInShopee) + const [lazadaOpen, setLazadaOpen] = useState(isInLazada) + const [cmsOpen, setCmsOpen] = useState(isInCms) + const [customerOpen, setCustomerOpen] = useState(isInCustomer) const [menuManagerOpen, setMenuManagerOpen] = useState(isInMenuManager) const [settingsOpen, setSettingsOpen] = useState(isInSettings) @@ -92,13 +140,31 @@ export default function Sidebar() { navigate('/login') } + const handleGroupClick = (setOpen: React.Dispatch>) => { + if (isCollapsed) { + onToggle() + setOpen(true) + } else { + setOpen(v => !v) + } + } + return ( -