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
import { hasVisibleSettingsEntries, i18n, nav, Subject } from '@spree/dashboard-core'
import {
BanknoteIcon,
ClipboardCheckIcon,
HandCoinsIcon,
HomeIcon,
PackageIcon,
SettingsIcon,
StoreIcon,
TagIcon,
} from '@spree/dashboard-ui/icons'
import { OnboardingNavBadge } from '../components/onboarding-nav-badge'
// The panel's built-in sidebar. Registered into the same registry a plugin
// writes to, so a marketplace can remove, reorder or add beside these with
// `defineDashboardPlugin({ nav: ... })` instead of forking the chrome.
//
// Positions leave room on either side (100/200/…) exactly as the operator's
// dashboard does, so a plugin slots between built-ins without renumbering.
//
// Subjects are the seller-branch CanCanCan subjects the API's `/me`
// serializes; an entry a member cannot act on is hidden by the same
// permission filter the operator's sidebar uses.
nav.add({
key: 'home',
label: i18n.t('nav.home'),
path: '/',
icon: HomeIcon,
position: 50,
subject: 'seller_profile',
})
// High in the rail while a seller is still being admitted: until they are
// approved it is the only thing that matters. A marketplace that admits
// sellers some other way removes it like any other entry.
nav.add({
key: 'onboarding',
label: i18n.t('nav.onboarding'),
path: '/onboarding',
icon: ClipboardCheckIcon,
position: 100,
subject: 'seller_profile',
badge: OnboardingNavBadge,
})
nav.add({
key: 'products',
label: i18n.t('nav.products'),
path: '/products',
icon: TagIcon,
position: 110,
subject: Subject.Product,
})
nav.add({
key: 'orders',
label: i18n.t('nav.orders'),
path: '/orders',
icon: PackageIcon,
position: 120,
subject: Subject.Order,
})
// The seller's own books. Two entries rather than one because they answer
// different questions: what an order earned, and whether last week's
// settlement went out. Both gated on the ledger key, so a teammate given
// orders but not money sees neither.
nav.add({
key: 'earnings',
label: i18n.t('nav.earnings'),
path: '/earnings',
icon: BanknoteIcon,
position: 130,
subject: 'seller_earnings',
})
nav.add({
key: 'payouts',
label: i18n.t('nav.payouts'),
path: '/payouts',
icon: HandCoinsIcon,
position: 140,
subject: 'seller_earnings',
})
nav.add({
key: 'profile',
label: i18n.t('nav.profile'),
path: '/profile',
icon: StoreIcon,
position: 150,
subject: 'seller_profile',
})
// Settings opens the landing page (and the secondary rail on wide viewports).
// The entries inside it live in `nav/settings.ts`. Bottom section and gated
// on there being something to see, exactly as the operator's dashboard does
// it — a member with no settings authority never opens an empty shell.
nav.add({
key: 'settings',
label: i18n.t('nav.settings'),
path: '/settings',
icon: SettingsIcon,
if: ({ permissions }) => hasVisibleSettingsEntries(permissions),
section: 'bottom',
position: 100,
})