Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
// Entries use `labelKey` rather than a resolved `label` so the sidebar
// re-renders on language change — see app-sidebar.tsx for resolution.
import { hasVisibleSettingsEntries, nav, Subject } from '@spree/dashboard-core'
import {
AnalyticsIcon,
Building2Icon,
GiftIcon,
HomeIcon,
InboxIcon,
PackageIcon,
SettingsIcon,
StoreIcon,
TagIcon,
UsersIcon,
WarehouseIcon,
} from '@spree/dashboard-ui/icons'
import { navCounterBadge } from '../components/spree/nav-counter-badge'
nav.add({
key: 'home',
labelKey: 'admin.nav.home',
path: '/',
icon: HomeIcon,
position: 100,
})
nav.add({
key: 'orders',
labelKey: 'admin.nav.orders',
path: '/orders',
icon: InboxIcon,
subject: Subject.Order,
position: 200,
// The section's own work plus its children's, so the total survives the
// submenu being collapsed on every page outside Orders.
badge: navCounterBadge('orders', 'returns', 'exchanges', 'claims'),
children: [
{
key: 'orders.drafts',
labelKey: 'admin.nav.draft_orders',
path: '/orders/drafts',
subject: Subject.Order,
position: 100,
},
// Post-sale. These live under Orders because they are always about one,
// and gating them on Order keeps a role that can see orders able to see
// what came back from them.
{
key: 'returns',
labelKey: 'admin.nav.returns',
path: '/returns',
subject: Subject.Order,
position: 200,
badge: navCounterBadge('returns'),
},
{
key: 'exchanges',
labelKey: 'admin.nav.exchanges',
path: '/exchanges',
subject: Subject.Order,
position: 300,
badge: navCounterBadge('exchanges'),
},
{
key: 'claims',
labelKey: 'admin.nav.claims',
path: '/claims',
subject: Subject.Order,
position: 400,
badge: navCounterBadge('claims'),
},
],
})
nav.add({
key: 'products',
labelKey: 'admin.nav.products',
path: '/products',
icon: PackageIcon,
subject: Subject.Product,
position: 300,
children: [
// Catalogs first: the catalog is the agreement a merchant sets up, and
// a price list is one thing a catalog can own.
{
key: 'products.catalogs',
labelKey: 'admin.nav.catalogs',
path: '/products/catalogs',
subject: Subject.Catalog,
position: 100,
},
{
key: 'products.price-lists',
labelKey: 'admin.nav.price_lists',
path: '/products/price-lists',
subject: Subject.PriceList,
position: 200,
},
{
key: 'products.categories',
labelKey: 'admin.nav.categories',
path: '/products/categories',
subject: Subject.Category,
position: 300,
},
{
key: 'products.collections',
labelKey: 'admin.nav.collections',
path: '/products/collections',
subject: Subject.Collection,
position: 350,
},
{
key: 'products.options',
labelKey: 'admin.nav.options',
path: '/products/options',
subject: Subject.OptionType,
position: 400,
},
{
key: 'products.media',
labelKey: 'admin.nav.media',
path: '/products/media',
subject: Subject.Media,
position: 450,
},
{
key: 'products.translations',
labelKey: 'admin.nav.translations',
path: '/products/translations',
subject: Subject.Product,
position: 475,
},
],
})
// Moving stock in and around is its own job, done by different people than the
// ones who write the catalog — so it gets its own section rather than crowding
// the end of Products.
nav.add({
key: 'inventory',
labelKey: 'admin.nav.inventory',
path: '/inventory',
icon: WarehouseIcon,
subject: Subject.StockLevel,
position: 350,
children: [
{
key: 'inventory.transfers',
labelKey: 'admin.nav.transfers',
path: '/transfers',
subject: Subject.StockTransfer,
position: 100,
},
{
key: 'inventory.purchase-orders',
labelKey: 'admin.nav.purchase_orders',
path: '/purchase-orders',
subject: Subject.PurchaseOrder,
position: 200,
},
{
key: 'inventory.suppliers',
labelKey: 'admin.nav.suppliers',
path: '/suppliers',
subject: Subject.Supplier,
position: 300,
},
],
})
nav.add({
key: 'customers',
labelKey: 'admin.nav.customers',
path: '/customers',
icon: UsersIcon,
subject: Subject.Customer,
position: 400,
children: [
{
key: 'customers.groups',
labelKey: 'admin.nav.customer_groups',
path: '/customers/groups',
subject: Subject.CustomerGroup,
position: 100,
},
],
})
// Business buyers get their own section rather than sitting under Customers:
// a company is an organisation tree with its own catalogs, members and
// onboarding, not a kind of customer.
nav.add({
key: 'companies',
labelKey: 'admin.nav.companies',
path: '/companies',
icon: Building2Icon,
subject: Subject.Company,
position: 425,
})
// Only a marketplace has sellers, so the entry hides itself on a store whose
// staff hold no seller permission at all.
nav.add({
key: 'sellers',
labelKey: 'admin.nav.sellers',
path: '/sellers',
icon: StoreIcon,
subject: Subject.Seller,
position: 450,
children: [
// What the marketplace charges on each sale. A rules engine merchants tune
// the way they tune promotions and price lists, and the input to the
// ledger below — so it lives here rather than in Settings.
{
key: 'sellers.commission-rates',
labelKey: 'admin.nav.commission_rates',
path: '/sellers/commission-rates',
subject: Subject.CommissionRate,
position: 50,
},
// The fund ledger. Under Sellers because that is what it is about, the
// way returns sit under Orders — and gated on the ledger subjects, so a
// staff member who manages sellers without seeing the money gets neither.
{
key: 'sellers.transfers',
labelKey: 'admin.nav.seller_transfers',
path: '/sellers/transfers',
subject: Subject.SellerTransfer,
position: 100,
},
{
key: 'sellers.payouts',
labelKey: 'admin.nav.seller_payouts',
path: '/sellers/payouts',
subject: Subject.SellerPayout,
position: 200,
},
],
})
// Stored value, not marketing: a gift card or a store credit is prepaid money
// the store owes, with a balance and a ledger and no rules or actions. Its own
// group, and the home for a rewards programme later.
nav.add({
key: 'loyalty',
labelKey: 'admin.nav.loyalty',
path: '/loyalty/gift-cards',
icon: GiftIcon,
// No subject of its own: the group has no landing page, so gating it on
// gift cards would hide Store Credits from a role that may read credits but
// not cards. The children declare their own subjects and the sidebar drops
// the ones a role cannot open.
position: 475,
children: [
{
key: 'loyalty.gift-cards',
labelKey: 'admin.nav.gift_cards',
path: '/loyalty/gift-cards',
subject: Subject.GiftCard,
position: 100,
},
{
key: 'loyalty.store-credits',
labelKey: 'admin.nav.store_credits',
path: '/loyalty/store-credits',
subject: Subject.StoreCredit,
position: 200,
},
],
})
nav.add({
key: 'promotions',
labelKey: 'admin.nav.promotions',
path: '/promotions',
icon: TagIcon,
subject: Subject.Promotion,
position: 500,
})
nav.add({
key: 'reports',
labelKey: 'admin.nav.reports',
path: '/reports',
icon: AnalyticsIcon,
position: 600,
subject: Subject.SavedReport,
})
nav.add({
key: 'settings',
labelKey: 'admin.nav.settings',
path: '/settings',
icon: SettingsIcon,
// No `subject`: every staff member can read the store record (shell data),
// so a Store check would show Settings to roles with nothing inside it.
// Visible only when at least one settings page is reachable.
if: ({ permissions }) => hasVisibleSettingsEntries(permissions),
section: 'bottom',
position: 100,
})