import { BuildingStorefront, Buildings, ChevronDownMini, CogSixTooth, CurrencyDollar, EllipsisHorizontal, MagnifyingGlass, MinusMini, OpenRectArrowOut, ReceiptPercent, ShoppingCart, SquaresPlus, Tag, Users, } from "@medusajs/icons" import { Avatar, DropdownMenu, Text, clx } from "@medusajs/ui" import * as Collapsible from "@radix-ui/react-collapsible" import { useTranslation } from "react-i18next" import { useStore } from "../../../hooks/api/store" import { settingsRouteRegex } from "../../../lib/extension-helpers" import { Divider } from "../../common/divider" import { Skeleton } from "../../common/skeleton" import { NavItem, NavItemProps } from "../../layout/nav-item" import { Shell } from "../../layout/shell" import { Link, useLocation, useNavigate } from "react-router-dom" import routes from "virtual:medusa/routes/links" import { useLogout } from "../../../hooks/api" import { queryClient } from "../../../lib/query-client" import { useSearch } from "../../../providers/search-provider" import { UserMenu } from "../user-menu" export const MainLayout = () => { return ( ) } const MainSidebar = () => { return ( ) } const Logout = () => { const { t } = useTranslation() const navigate = useNavigate() const { mutateAsync: logoutMutation } = useLogout() const handleLogout = async () => { await logoutMutation(undefined, { onSuccess: () => { /** * When the user logs out, we want to clear the query cache */ queryClient.clear() navigate("/login") }, }) } return (
{t("app.menus.actions.logout")}
) } const Header = () => { const { t } = useTranslation() const { store, isPending, isError, error } = useStore() const name = store?.name const fallback = store?.name?.slice(0, 1).toUpperCase() const isLoaded = !isPending && !!store && !!name && !!fallback if (isError) { throw error } return (
{fallback ? ( ) : ( )}
{name ? ( {store.name} ) : ( )}
{isLoaded && (
{name} {t("app.nav.main.store")}
{t("app.nav.main.storeSettings")}
)}
) } const useCoreRoutes = (): Omit[] => { const { t } = useTranslation() return [ { icon: , label: t("orders.domain"), to: "/orders", items: [ // TODO: Enable when domin is introduced // { // 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", }, // TODO: Enable when domin is introduced // { // label: t("giftCards.domain"), // to: "/gift-cards", // }, ], }, { icon: , label: t("inventory.domain"), to: "/inventory", items: [ { label: t("reservations.domain"), to: "/reservations", }, ], }, { icon: , label: t("customers.domain"), to: "/customers", items: [ { label: t("customerGroups.domain"), to: "/customer-groups", }, ], }, { icon: , label: t("promotions.domain"), to: "/promotions", items: [ { label: t("campaigns.domain"), to: "/campaigns", }, ], }, { icon: , label: t("priceLists.domain"), to: "/price-lists", }, ] } const Searchbar = () => { const { t } = useTranslation() const { toggleSearch } = useSearch() return (
) } const CoreRouteSection = () => { const coreRoutes = useCoreRoutes() return ( ) } const ExtensionRouteSection = () => { const { t } = useTranslation() const links = routes.links const extensionLinks = links .filter((link) => !settingsRouteRegex.test(link.path)) .sort((a, b) => a.label.localeCompare(b.label)) if (!extensionLinks.length) { return null } return (
) } const UtilitySection = () => { const location = useLocation() const { t } = useTranslation() return (
} />
) } const UserSection = () => { return (
) }