Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Give the seller panel the dashboard's chrome and profile layout

Damian Legawiec292d2f7e7c0f
diff --git a/packages/dashboard-core/src/components/top-bar.tsx b/packages/dashboard-core/src/components/top-bar.tsx
index 4d6b2ecb02..df538b3052 100644
--- a/packages/dashboard-core/src/components/top-bar.tsx
+++ b/packages/dashboard-core/src/components/top-bar.tsx
@@ -164,11 +164,19 @@ function ViewStoreLink() {
// User menu
// ---------------------------------------------------------------------------
-function TopBarUser({
- uiLocales,
+/**
+ * The account menu: who is signed in, theme and language, and sign out.
+ *
+ * Exported because it is the one piece of the top bar that needs nothing but
+ * `useAuth` — no store, no command palette — so a panel with different chrome
+ * (the seller panel) mounts this rather than forking a second user menu that
+ * would then drift.
+ */
+export function TopBarUser({
+ uiLocales = [],
onEditProfile,
}: {
- uiLocales: ReadonlyArray<{ code: string; name: string }>
+ uiLocales?: ReadonlyArray<{ code: string; name: string }>
onEditProfile?: () => void
}) {
const { t } = useTranslation()
diff --git a/packages/seller-dashboard/src/components/seller-switcher.tsx b/packages/seller-dashboard/src/components/seller-switcher.tsx
new file mode 100644
index 0000000000..4f5e075aef
--- /dev/null
+++ b/packages/seller-dashboard/src/components/seller-switcher.tsx
@@ -0,0 +1,124 @@
+import {
+ Avatar,
+ AvatarFallback,
+ AvatarImage,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ SidebarMenu,
+ SidebarMenuItem,
+ Skeleton,
+ useSidebar,
+} from '@spree/dashboard-ui'
+import { useQuery } from '@tanstack/react-query'
+import { Link, useParams } from '@tanstack/react-router'
+import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
+import { sellerClient } from '../api-client'
+
+/**
+ * Sidebar seller header, mirroring the operator's store switcher.
+ *
+ * A plain, non-interactive block when the signed-in person runs one seller —
+ * which is most of them — and a dropdown listing every seller they hold a
+ * role on once there are two or more. Switching is a link to the other
+ * seller's route, so the URL stays the source of truth for who is being
+ * acted as, exactly as the store switcher navigates by store id.
+ *
+ * Replaces the fixed "Seller panel" label, which told a seller something
+ * they already knew and left their own name off the one piece of chrome
+ * that is always on screen.
+ */
+export function SellerSwitcher() {
+ const { t } = useTranslation()
+ const { isMobile, state } = useSidebar()
+ const isCollapsed = state === 'collapsed'
+ const { sellerId } = useParams({ strict: false }) as { sellerId?: string }
+
+ // `/me` for the list, the profile for the current seller's own logo — the
+ // summary in `/me` carries no image, and the profile query is already
+ // loaded by the page behind this.
+ const { data: me, isLoading } = useQuery({
+ queryKey: ['seller', 'me'],
+ queryFn: () => sellerClient().me(),
+ })
+
+ const { data: profile } = useQuery({
+ queryKey: ['seller', sellerId, 'profile'],
+ queryFn: () => sellerClient().profile.get(),
+ enabled: Boolean(sellerId),
+ })
+
+ if (isLoading) return <Skeleton className="h-header-height w-full rounded-xl" />
+
+ const sellers = me?.sellers ?? []
+ const current = sellers.find((seller) => seller.id === sellerId) ?? sellers[0]
+
+ const initials = current?.name
+ .split(' ')
+ .map((word) => word[0])
+ .join('')
+
+ const header = (
+ <>
+ <Avatar>
+ {profile?.square_logo_url || profile?.logo_url ? (
+ <AvatarImage src={profile.square_logo_url ?? profile.logo_url ?? undefined} />
+ ) : null}
+ <AvatarFallback>{initials}</AvatarFallback>
+ </Avatar>
+ {!isCollapsed && (
+ <div className="grid flex-1 text-left text-sm leading-tight">
+ <span className="truncate font-medium text-foreground">{current?.name}</span>
+ </div>
+ )}
+ </>
+ )
+
+ if (sellers.length < 2) {
+ return (
+ <SidebarMenu>
+ <SidebarMenuItem className="flex h-header-height items-center">
+ <div className="flex w-full items-center gap-2 p-1.5">{header}</div>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ )
+ }
+
+ return (
+ <SidebarMenu>
+ <SidebarMenuItem className="flex h-header-height items-center">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="flex w-full items-center">
+ <button
+ type="button"
+ aria-label={t('seller_switcher.label')}
+ className="gap-2 rounded-xl p-1.5 outline-hidden transition-colors duration-100 hover:bg-sidebar-accent data-[state=open]:bg-sidebar-accent"
+ >
+ {header}
+ {!isCollapsed && (
+ <ChevronsUpDownIcon className="ml-auto size-4 text-muted-foreground" />
+ )}
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ className="min-w-48"
+ side={isMobile ? 'bottom' : 'right'}
+ align="start"
+ sideOffset={8}
+ >
+ {sellers.map((seller) => (
+ <DropdownMenuItem key={seller.id} asChild>
+ <Link to="/$sellerId" params={{ sellerId: seller.id }} className="no-underline">
+ <span className="flex-1 truncate">{seller.name}</span>
+ {seller.id === current?.id && <CheckIcon className="size-4" />}
+ </Link>
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ )
+}
diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.json
index 355f5e9958..67b8059468 100644
--- a/packages/seller-dashboard/src/locales/en.json
+++ b/packages/seller-dashboard/src/locales/en.json
@@ -30,6 +30,9 @@
"subtitle": "You run more than one. Pick which to manage.",
"status": "Status"
},
+ "seller_switcher": {
+ "label": "Switch seller"
+ },
"nav": {
"profile": "Profile",
"team": "Team",
@@ -64,9 +67,7 @@
}
},
"profile": {
- "title": "Your profile",
"subtitle": "How your storefront presents you, and how the marketplace reaches you.",
- "section_presentation": "Presentation",
"section_contact": "Contact",
"section_standing": "Standing",
"section_settlement": "Payouts and tax",
@@ -74,10 +75,6 @@
"about": "About",
"contact_email": "Contact email",
"billing_email": "Billing email",
- "handle": "Storefront address",
- "status": "Status",
- "sellable": "Currently selling",
- "not_sellable": "Not currently selling",
"products_count": "Products",
"tax_remittance": "Tax remitted by",
"payout_schedule": "Payout schedule",
@@ -86,7 +83,24 @@
"save": "Save changes",
"saving": "Saving…",
"saved": "Profile saved",
- "not_provided": "Not provided"
+ "not_provided": "Not provided",
+ "edit": "Edit",
+ "edit_title": "Edit your profile",
+ "no_about": "You have not written a description yet.",
+ "at_a_glance": "At a glance",
+ "team_count": "Team members",
+ "joined": "Joined",
+ "on_holiday_notice": "Holiday mode is on, so your products are visible but cannot be bought.",
+ "status_help": {
+ "pending": "The marketplace has not started your application yet.",
+ "invited": "You have been invited. Finish getting set up to apply.",
+ "onboarding": "Work through your checklist, then submit for review.",
+ "ready_for_review": "The marketplace is reviewing your application.",
+ "approved": "You are approved and can sell on this marketplace.",
+ "suspended": "Selling is paused. Contact the marketplace to find out more.",
+ "rejected": "Your application was not accepted. Contact the marketplace to find out more.",
+ "canceled": "This seller account is closed."
+ }
},
"team": {
"title": "Your team",
diff --git a/packages/seller-dashboard/src/pages/onboarding.tsx b/packages/seller-dashboard/src/pages/onboarding.tsx
index 47d6112600..7d96f74b6f 100644
--- a/packages/seller-dashboard/src/pages/onboarding.tsx
+++ b/packages/seller-dashboard/src/pages/onboarding.tsx
@@ -66,7 +66,7 @@ export function OnboardingPage() {
const submitted = status === 'ready_for_review'
return (
- <div className="mx-auto flex max-w-3xl flex-col gap-6">
+ <div className="flex flex-col gap-6">
<div>
<h1 className="font-medium text-2xl">{t('onboarding.title')}</h1>
<p className="text-muted-foreground text-sm">{t('onboarding.subtitle')}</p>
diff --git a/packages/seller-dashboard/src/pages/profile.tsx b/packages/seller-dashboard/src/pages/profile.tsx
index 641e944e73..376c58f75d 100644
--- a/packages/seller-dashboard/src/pages/profile.tsx
+++ b/packages/seller-dashboard/src/pages/profile.tsx
@@ -1,6 +1,7 @@
import {
Button,
Card,
+ CardAction,
CardContent,
CardHeader,
CardTitle,
@@ -9,12 +10,22 @@ import {
FieldGroup,
FieldLabel,
Input,
+ RelativeTime,
+ ResourceLayout,
+ Sheet,
+ SheetContent,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
StatusBadge,
Textarea,
} from '@spree/dashboard-ui'
+import type { Profile } from '@spree/seller-sdk'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useParams } from '@tanstack/react-router'
-import { useEffect } from 'react'
+import { PackageIcon, PencilIcon, StoreIcon, UsersIcon } from 'lucide-react'
+import type { ReactNode } from 'react'
+import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
@@ -29,17 +40,20 @@ interface ProfileValues {
}
/**
- * The seller's own record.
+ * The seller's own record, laid out as the operator sees it on their seller
+ * page — brand hero, standing, contact — so the two views of one seller
+ * describe the same thing in the same shape.
*
- * Split by who owns each fact: what the seller maintains is a form, what the
- * marketplace decides is shown read-only. Hiding the latter would leave a
- * seller unable to see they had been suspended, or on what terms they are
- * paid; making it editable would let them approve themselves.
+ * What the operator's page has that this deliberately does not: the lifecycle
+ * actions (approve, suspend, reject, delete), the settlement *editor*, and the
+ * invite sheet. Those are the marketplace's decisions about this seller, not
+ * the seller's own. Settlement terms are still shown, read-only: a seller who
+ * cannot see how they are paid cannot query it.
*/
export function ProfilePage() {
const { t } = useTranslation()
- const queryClient = useQueryClient()
const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const [editing, setEditing] = useState(false)
const {
data: profile,
@@ -50,12 +64,236 @@ export function ProfilePage() {
queryFn: () => sellerClient().profile.get(),
})
+ // Only for the team count in "at a glance" — the profile payload does not
+ // carry one, and a second small read beats widening the serializer for a
+ // number the team page already fetches.
+ const { data: team } = useQuery({
+ queryKey: ['seller', sellerId, 'team'],
+ queryFn: () => sellerClient().team.list(),
+ })
+
+ if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>
+ if (error || !profile) return <CenteredMessage>{t('common.error')}</CenteredMessage>
+
+ return (
+ <>
+ <ResourceLayout
+ header={
+ <div>
+ <h1 className="font-medium text-2xl">{profile.name}</h1>
+ <p className="text-muted-foreground text-sm">{t('profile.subtitle')}</p>
+ </div>
+ }
+ main={<BrandCard profile={profile} onEdit={() => setEditing(true)} />}
+ sidebar={
+ <>
+ <StandingCard profile={profile} />
+ <AtAGlanceCard profile={profile} teamCount={team?.data?.length} />
+ <ContactCard profile={profile} onEdit={() => setEditing(true)} />
+ <SettlementCard profile={profile} />
+ </>
+ }
+ />
+
+ <EditProfileSheet profile={profile} open={editing} onOpenChange={setEditing} />
+ </>
+ )
+}
+
+/**
+ * The storefront face of the seller: cover, logo, handle and description.
+ *
+ * Copied from the operator's card, including why the empty states look as
+ * they do — a seller with no cover gets a slim band rather than a tall empty
+ * block, and the logo tile straddles it with its own z-index so the band's
+ * edge does not cut across it.
+ */
+function BrandCard({ profile, onEdit }: { profile: Profile; onEdit: () => void }) {
+ const { t } = useTranslation()
+
+ return (
+ <Card className="overflow-hidden">
+ <div className="relative">
+ {profile.cover_photo_url ? (
+ <img
+ src={profile.cover_photo_url}
+ alt=""
+ className="h-40 w-full bg-accent object-cover"
+ />
+ ) : (
+ <div className="h-20 w-full border-border border-b bg-muted" />
+ )}
+ <Button size="sm" variant="outline" className="absolute top-3 right-3" onClick={onEdit}>
+ <PencilIcon className="size-4" />
+ {t('profile.edit')}
+ </Button>
+ </div>
+
+ <CardContent className="flex flex-col gap-4 px-5 pb-5">
+ <div className="-mt-10 relative z-10 flex size-20 items-center justify-center overflow-hidden rounded-xl border border-border bg-card shadow-sm">
+ {/* The square logo is the one cropped for a tile like this; the main
+ logo is the fallback, since a seller may have set only one. */}
+ {profile.square_logo_url || profile.logo_url ? (
+ <img
+ src={profile.square_logo_url ?? profile.logo_url ?? undefined}
+ alt=""
+ className="size-full object-cover"
+ />
+ ) : (
+ <StoreIcon className="size-7 text-muted-foreground" />
+ )}
+ </div>
+
+ {/* The name is already the page title; the handle is what it lacks. */}
+ <p className="text-muted-foreground text-sm">/{profile.slug}</p>
+
+ {profile.about_html ? (
+ // Server-sanitized on every write path (Spree::RichTextSanitizer),
+ // which is what makes rendering it here safe.
+ <div
+ className="prose prose-sm dark:prose-invert max-w-none"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: sanitized server-side
+ dangerouslySetInnerHTML={{ __html: profile.about_html }}
+ />
+ ) : (
+ <p className="text-muted-foreground text-sm">{t('profile.no_about')}</p>
+ )}
+ </CardContent>
+ </Card>
+ )
+}
+
+/** Where the seller stands with the marketplace, and what that means. */
+function StandingCard({ profile }: { profile: Profile }) {
+ const { t } = useTranslation()
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('profile.section_standing')}</CardTitle>
+ <CardAction>
+ <StatusBadge status={profile.status} />
+ </CardAction>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-2">
+ <p className="text-muted-foreground text-sm">
+ {t(`profile.status_help.${profile.status}`, {
+ defaultValue: t('profile.status_help.pending'),
+ })}
+ </p>
+ {profile.on_holiday && (
+ <p className="text-muted-foreground text-sm">{t('profile.on_holiday_notice')}</p>
+ )}
+ </CardContent>
+ </Card>
+ )
+}
+
+function AtAGlanceCard({ profile, teamCount }: { profile: Profile; teamCount?: number }) {
+ const { t } = useTranslation()
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('profile.at_a_glance')}</CardTitle>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ <div className="flex items-center justify-between text-sm">
+ <span className="flex items-center gap-2 text-muted-foreground">
+ <PackageIcon className="size-4" />
+ {t('profile.products_count')}
+ </span>
+ <span>{profile.products_count}</span>
+ </div>
+ <div className="flex items-center justify-between text-sm">
+ <span className="flex items-center gap-2 text-muted-foreground">
+ <UsersIcon className="size-4" />
+ {t('profile.team_count')}
+ </span>
+ <span>{teamCount ?? '—'}</span>
+ </div>
+ <ReadRow label={t('profile.joined')}>
+ <RelativeTime iso={profile.created_at} />
+ </ReadRow>
+ </CardContent>
+ </Card>
+ )
+}
+
+function ContactCard({ profile, onEdit }: { profile: Profile; onEdit: () => void }) {
+ const { t } = useTranslation()
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('profile.section_contact')}</CardTitle>
+ <CardAction>
+ <Button variant="outline" size="sm" onClick={onEdit}>
+ <PencilIcon className="size-4" />
+ {t('profile.edit')}
+ </Button>
+ </CardAction>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ <ReadRow label={t('profile.contact_email')}>
+ {profile.contact_email ? (
+ <a href={`mailto:${profile.contact_email}`}>{profile.contact_email}</a>
+ ) : null}
+ </ReadRow>
+ <ReadRow label={t('profile.billing_email')}>
+ {profile.billing_email ? (
+ <a href={`mailto:${profile.billing_email}`}>{profile.billing_email}</a>
+ ) : null}
+ </ReadRow>
+ </CardContent>
+ </Card>
+ )
+}
+
+/**
+ * How and when this seller gets paid. Read-only on purpose: these are the
+ * marketplace's terms, and the seller API refuses to write them — showing an
+ * editor here would offer a control the server would reject.
+ */
+function SettlementCard({ profile }: { profile: Profile }) {
+ const { t } = useTranslation()
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('profile.section_settlement')}</CardTitle>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ <p className="text-muted-foreground text-xs">{t('profile.operator_managed')}</p>
+ <ReadRow label={t('profile.tax_remittance')}>{profile.tax_remittance}</ReadRow>
+ <ReadRow label={t('profile.payout_schedule')}>{profile.payouts_schedule_interval}</ReadRow>
+ <ReadRow label={t('profile.minimum_payout')}>{profile.minimum_payout_amount}</ReadRow>
+ </CardContent>
+ </Card>
+ )
+}
+
+function EditProfileSheet({
+ profile,
+ open,
+ onOpenChange,
+}: {
+ profile: Profile
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const queryClient = useQueryClient()
+
const form = useForm<ProfileValues>({
defaultValues: { name: '', contact_email: '', billing_email: '', about: '' },
})
+ // The sheet stays mounted across opens, so re-seed from the latest record
+ // each time it opens rather than only on first mount.
useEffect(() => {
- if (!profile) return
+ if (!open) return
form.reset({
name: profile.name,
@@ -63,7 +301,7 @@ export function ProfilePage() {
billing_email: profile.billing_email ?? '',
about: profile.about_html ?? '',
})
- }, [profile, form])
+ }, [open, profile, form])
const save = useMutation({
mutationFn: (values: ProfileValues) =>
@@ -75,103 +313,74 @@ export function ProfilePage() {
}),
onSuccess: (updated) => {
queryClient.setQueryData(['seller', sellerId, 'profile'], updated)
+ onOpenChange(false)
toast.success(t('profile.saved'))
},
- onError: () => toast.error(t('common.error')),
+ onError: (err) => toast.error(err instanceof Error ? err.message : t('common.error')),
})
- if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>
- if (error || !profile) return <CenteredMessage>{t('common.error')}</CenteredMessage>
-
- const { errors, isDirty } = form.formState
+ const { errors } = form.formState
return (
- <div className="mx-auto flex max-w-3xl flex-col gap-6">
- <div>
- <h1 className="font-medium text-2xl">{t('profile.title')}</h1>
- <p className="text-muted-foreground text-sm">{t('profile.subtitle')}</p>
- </div>
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('profile.edit_title')}</SheetTitle>
+ </SheetHeader>
- <Card>
- <CardHeader>
- <CardTitle>{t('profile.section_presentation')}</CardTitle>
- </CardHeader>
- <CardContent>
- <FieldGroup>
- <Field>
- <FieldLabel htmlFor="name">{t('profile.name')}</FieldLabel>
- <Input
- id="name"
- aria-invalid={!!errors.name || undefined}
- {...form.register('name', { required: true })}
- />
- <FieldError errors={[errors.name]} />
- </Field>
-
- <Field>
- <FieldLabel htmlFor="about">{t('profile.about')}</FieldLabel>
- <Textarea id="about" rows={5} {...form.register('about')} />
- </Field>
-
- <Field>
- <FieldLabel htmlFor="contact_email">{t('profile.contact_email')}</FieldLabel>
- <Input id="contact_email" type="email" {...form.register('contact_email')} />
- </Field>
-
- <Field>
- <FieldLabel htmlFor="billing_email">{t('profile.billing_email')}</FieldLabel>
- <Input id="billing_email" type="email" {...form.register('billing_email')} />
- </Field>
-
- <div className="flex justify-end">
- <Button
- type="button"
- disabled={!isDirty || save.isPending}
- onClick={form.handleSubmit((values) => save.mutate(values))}
- >
- {save.isPending ? t('profile.saving') : t('profile.save')}
- </Button>
- </div>
- </FieldGroup>
- </CardContent>
- </Card>
-
- {/* Read-only: the marketplace decides these, and a seller who cannot see
- them cannot tell why their products stopped selling. */}
- <Card>
- <CardHeader>
- <CardTitle>{t('profile.section_standing')}</CardTitle>
- </CardHeader>
- <CardContent className="flex flex-col gap-3">
- <ReadRow label={t('profile.status')}>
- <StatusBadge status={profile.status} />
- </ReadRow>
- <ReadRow label={t('profile.handle')}>/{profile.slug}</ReadRow>
- <ReadRow label={t('profile.products_count')}>{profile.products_count}</ReadRow>
- <ReadRow label={t('profile.sellable')}>
- {profile.sellable ? t('profile.sellable') : t('profile.not_sellable')}
- </ReadRow>
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader>
- <CardTitle>{t('profile.section_settlement')}</CardTitle>
- </CardHeader>
- <CardContent className="flex flex-col gap-3">
- <p className="text-muted-foreground text-xs">{t('profile.operator_managed')}</p>
- <ReadRow label={t('profile.tax_remittance')}>{profile.tax_remittance}</ReadRow>
- <ReadRow label={t('profile.payout_schedule')}>
- {profile.payouts_schedule_interval}
- </ReadRow>
- <ReadRow label={t('profile.minimum_payout')}>{profile.minimum_payout_amount}</ReadRow>
- </CardContent>
- </Card>
- </div>
+ {/* `stopPropagation` after handleSubmit: this form is portalled and
+ a parent form would otherwise see the bubbling submit. */}
+ <form
+ onSubmit={(event) => {
+ form.handleSubmit((values) => save.mutate(values))(event)
+ event.stopPropagation()
+ }}
+ className="flex min-h-0 flex-1 flex-col"
+ >
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <FieldGroup>
+ <Field>
+ <FieldLabel htmlFor="name">{t('profile.name')}</FieldLabel>
+ <Input
+ id="name"
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name', { required: true })}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="about">{t('profile.about')}</FieldLabel>
+ <Textarea id="about" rows={6} {...form.register('about')} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="contact_email">{t('profile.contact_email')}</FieldLabel>
+ <Input id="contact_email" type="email" {...form.register('contact_email')} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="billing_email">{t('profile.billing_email')}</FieldLabel>
+ <Input id="billing_email" type="email" {...form.register('billing_email')} />
+ </Field>
+ </FieldGroup>
+ </div>
+
+ <SheetFooter>
+ <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
+ {t('common.cancel')}
+ </Button>
+ <Button type="submit" disabled={save.isPending}>
+ {save.isPending ? t('profile.saving') : t('profile.save')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
)
}
-function ReadRow({ label, children }: { label: string; children: React.ReactNode }) {
+function ReadRow({ label, children }: { label: string; children: ReactNode }) {
const { t } = useTranslation()
return (
diff --git a/packages/seller-dashboard/src/pages/team.tsx b/packages/seller-dashboard/src/pages/team.tsx
index 4be904da00..227d550065 100644
--- a/packages/seller-dashboard/src/pages/team.tsx
+++ b/packages/seller-dashboard/src/pages/team.tsx
@@ -85,7 +85,7 @@ export function TeamPage() {
const pending = invitations.data?.data ?? []
return (
- <div className="mx-auto flex max-w-3xl flex-col gap-6">
+ <div className="flex flex-col gap-6">
<div className="flex items-start justify-between gap-4">
<div>
<h1 className="font-medium text-2xl">{t('team.title')}</h1>
diff --git a/packages/seller-dashboard/src/panel-chrome.tsx b/packages/seller-dashboard/src/panel-chrome.tsx
index b960c606ed..ffe183c3be 100644
--- a/packages/seller-dashboard/src/panel-chrome.tsx
+++ b/packages/seller-dashboard/src/panel-chrome.tsx
@@ -1,59 +1,58 @@
-import { NavMain, useAuth, useNavItems } from '@spree/dashboard-core'
+import { NavMain, StickyHeaderProvider, TopBarUser, useNavItems } from '@spree/dashboard-core'
import {
- Button,
Sidebar,
SidebarContent,
- SidebarFooter,
SidebarHeader,
SidebarInset,
SidebarProvider,
+ SidebarTrigger,
} from '@spree/dashboard-ui'
-import { Link, useParams } from '@tanstack/react-router'
+import { useParams } from '@tanstack/react-router'
import type { ReactNode } from 'react'
-import { useTranslation } from 'react-i18next'
+import { SellerSwitcher } from './components/seller-switcher'
/**
- * The panel's frame: the sidebar and a content column.
+ * The panel's frame: the sidebar and a content column under a top bar.
*
- * Built on the same sidebar primitives and the same nav registry as the
- * operator's dashboard, so a marketplace customises this panel the way it
- * customises that one — `defineDashboardPlugin({ nav, slots, ... })` — rather
- * than forking the chrome. `useNavItems` resolves the registry against the
- * seller id: entries are prefixed with it, `if` gates evaluated, and items the
- * member cannot act on hidden by the same permission filter.
+ * Built on the same primitives, the same nav registry and the same account
+ * menu as the operator's dashboard, so a seller who has used one recognises
+ * the other and a fix to the shared pieces reaches both.
*
- * Deliberately without the operator's store switcher, settings sidebar and
- * command palette. A seller has one tenant at a time (switching is a link
- * back to the picker) and nothing here yet earns a palette.
+ * The store switcher's counterpart is the seller switcher in the header.
+ * What the operator's chrome has that this does not: a settings sub-shell,
+ * and the command palette — the latter needs a search surface this panel does
+ * not have yet, and mounting the provider for an empty palette would be
+ * chrome that does nothing.
*/
export function PanelChrome({ children }: { children: ReactNode }) {
- const { t } = useTranslation()
- const { logout } = useAuth()
const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
const { navItems, bottomItems } = useNavItems(sellerId)
return (
- <SidebarProvider>
- <Sidebar collapsible="icon">
- <SidebarHeader className="px-4 py-3">
- <p className="truncate font-medium text-sm">{t('app.name')}</p>
- </SidebarHeader>
- <SidebarContent>
- <NavMain items={navItems} bottomItems={bottomItems} />
- </SidebarContent>
- <SidebarFooter className="flex flex-col gap-1 p-2">
- <Button variant="ghost" size="sm" className="justify-start" asChild>
- <Link to="/">{t('seller_picker.title')}</Link>
- </Button>
- <Button variant="ghost" size="sm" className="justify-start" onClick={() => logout()}>
- {t('nav.sign_out')}
- </Button>
- </SidebarFooter>
- </Sidebar>
+ <StickyHeaderProvider>
+ <SidebarProvider>
+ <Sidebar collapsible="icon">
+ <SidebarHeader>
+ <SellerSwitcher />
+ </SidebarHeader>
+ <SidebarContent>
+ <NavMain items={navItems} bottomItems={bottomItems} />
+ </SidebarContent>
+ </Sidebar>
- <SidebarInset>
- <div className="container mx-auto flex flex-1 flex-col gap-4 p-4 lg:p-6">{children}</div>
- </SidebarInset>
- </SidebarProvider>
+ <SidebarInset>
+ {/* The account menu carries sign-out, so the sidebar footer no
+ longer does. */}
+ <header className="flex h-14 shrink-0 items-center gap-2 border-border-subtle border-b px-4">
+ <SidebarTrigger />
+ <div className="ml-auto flex items-center gap-2">
+ <TopBarUser />
+ </div>
+ </header>
+
+ <div className="flex flex-1 flex-col gap-4 p-4 lg:p-6">{children}</div>
+ </SidebarInset>
+ </SidebarProvider>
+ </StickyHeaderProvider>
)
}
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId.tsx
index a4452d1f3e..9e0f5b06c3 100644
--- a/packages/seller-dashboard/src/routes/_authenticated/$sellerId.tsx
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId.tsx
@@ -1,3 +1,4 @@
+import { usePermissions } from '@spree/dashboard-core'
import { createFileRoute, Outlet, useParams } from '@tanstack/react-router'
import { useEffect } from 'react'
import { rememberSeller, setActiveSeller } from '../../api-client'
@@ -16,6 +17,7 @@ export const Route = createFileRoute('/_authenticated/$sellerId')({
*/
function SellerLayout() {
const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const { refresh: refreshPermissions } = usePermissions()
// Synchronously, not in an effect: children render (and fetch) before
// effects run, and a request sent under the previous seller's header would
@@ -26,6 +28,19 @@ function SellerLayout() {
rememberSeller(sellerId)
}, [sellerId])
+ // Capability is per seller, so the permission provider's own fetch — which
+ // runs the moment authentication succeeds, before any seller is chosen —
+ // comes back with nothing and every `<Can>` and permission-gated nav entry
+ // reads as denied. That is why the sidebar was empty until a refresh.
+ //
+ // Unlike the operator's dashboard, this does NOT skip its first run: there
+ // the initial fetch is already correct for the initial store, here it never
+ // is. Re-runs on `sellerId` so switching sellers reloads capability too.
+ // biome-ignore lint/correctness/useExhaustiveDependencies: sellerId drives the seller-switch re-run
+ useEffect(() => {
+ void refreshPermissions()
+ }, [sellerId, refreshPermissions])
+
return (
<PanelChrome>
<Outlet />
diff --git a/spree/core/lib/tasks/seller_sample_data.rake b/spree/core/lib/tasks/seller_sample_data.rake
index 5795d45f72..7deeccee60 100644
--- a/spree/core/lib/tasks/seller_sample_data.rake
+++ b/spree/core/lib/tasks/seller_sample_data.rake
@@ -42,7 +42,27 @@ namespace :spree do
seller.invitations.create!(email: invitee, role: seller.default_user_role, inviter: owner)
end
+ # A checklist to work through, so the panel's onboarding page and its
+ # nav counter have something to show. Skipped when the marketplace
+ # already defines its own.
+ if store.seller_requirements.none?
+ Spree::SellerRequirements::AcceptTerms.create!(store: store, position: 1, active: true, required: true)
+ Spree::SellerRequirements::BillingAddress.create!(store: store, position: 2, active: true, required: true)
+ Spree::SellerRequirements::ReturnsAddress.create!(store: store, position: 3, active: true, required: true)
+ Spree::SellerRequirements::Attestation.create!(
+ store: store, position: 4, active: true, required: true,
+ name: 'Confirm you can ship within two working days'
+ )
+ Spree::SellerRequirements::OperatorReview.create!(
+ store: store, position: 5, active: true, required: false,
+ name: 'Marketplace background check'
+ )
+ end
+
+ progress = Spree::Sellers::Requirements.new(seller.reload).progress
+
puts "Seller: #{seller.name} (#{seller.prefixed_id}, #{seller.status})"
+ puts "Checklist: #{progress[:done]}/#{progress[:total]} done"
puts "Sign in: #{email}"
puts "Pending: #{seller.invitations.pending.pluck(:email).join(', ')}"
end