import { ArrowRightOnRectangle, BookOpen, BuildingStorefront, Calendar, ChevronDownMini, CircleHalfSolid, CogSixTooth, CurrencyDollar, EllipsisHorizontal, MinusMini, ReceiptPercent, ShoppingCart, Sidebar, SquaresPlus, Tag, Users, } from "@medusajs/icons" import { Avatar, DropdownMenu, IconButton, Text } from "@medusajs/ui" import * as Collapsible from "@radix-ui/react-collapsible" import * as Dialog from "@radix-ui/react-dialog" import { useAdminDeleteSession, useAdminStore } from "medusa-react" import { Link, useLocation, useNavigate } from "react-router-dom" import { useAuth } from "../../../providers/auth-provider" import { useTheme } from "../../../providers/theme-provider" import { Fragment, useEffect, useState } from "react" import { Breadcrumbs } from "./breadcrumbs" import { NavItem, NavItemProps } from "./nav-item" import { Notifications } from "./notifications" import { SearchToggle } from "./search-toggle" import { Spacer } from "./spacer" import extensions from "medusa-admin:routes/links" import { useTranslation } from "react-i18next" export const MainNav = () => { return ( ) } const MobileNav = () => { const [open, setOpen] = useState(false) const location = useLocation() // If the user navigates to a new route, we want to close the menu useEffect(() => { setOpen(false) }, [location.pathname]) return (
) } const DesktopNav = () => { return ( ) } const Header = () => { const { store } = useAdminStore() const { setTheme, theme } = useTheme() const { mutateAsync: logoutMutation } = useAdminDeleteSession() const navigate = useNavigate() const logout = async () => { await logoutMutation(undefined, { onSuccess: () => { navigate("/login") }, }) } if (!store) { return null } return (
{store.name[0].toUpperCase()}
{store.name}
Store Settings Documentation Changelog Theme { e.preventDefault() setTheme("light") }} > Light { e.preventDefault() setTheme("dark") }} > Dark Logout ⌥⇧Q
) } const useCoreRoutes = (): Omit[] => { const { t } = useTranslation() return [ { icon: , label: t("orders.domain"), to: "/orders", items: [ { label: t("draftOrders.domain"), to: "/draft-orders", }, ], }, { icon: , label: t("products.domain"), to: "/products", items: [ { label: t("collections.domain"), to: "/collections", }, { label: t("categories.domain"), to: "/categories", }, { label: t("giftCards.domain"), to: "/gift-cards", }, { label: t("inventory.domain"), to: "/inventory", }, ], }, { icon: , label: t("customers.domain"), to: "/customers", items: [ { label: t("customerGroups.domain"), to: "/customer-groups", }, ], }, { icon: , label: t("discounts.domain"), to: "/discounts", }, { icon: , label: t("pricing.domain"), to: "/pricing", }, ] } const CoreRouteSection = () => { const coreRoutes = useCoreRoutes() return ( ) } const ExtensionRouteSection = () => { if (!extensions.links || extensions.links.length === 0) { return null } return (
{extensions.links.map((link) => { return ( : } type="extension" /> ) })}
) } const SettingsSection = () => { return (
} label="Settings" to="/settings" />
) } const UserSection = () => { const { user } = useAuth() if (!user) { return null } const fallback = user.first_name && user.last_name ? `${user.first_name[0]}${user.last_name[0]}` : user.first_name ? user.first_name[0] : user.email[0] return (
{(user.first_name || user.last_name) && ( {`${user.first_name && `${user.first_name} `}${ user.last_name }`} )} {user.email}
) }