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 its orders and products

Damian Legawiec2d7039f35080
diff --git a/packages/seller-dashboard-starter/src/routeTree.gen.ts b/packages/seller-dashboard-starter/src/routeTree.gen.ts
index 0d5d10ed92..2b8475e6fe 100644
--- a/packages/seller-dashboard-starter/src/routeTree.gen.ts
+++ b/packages/seller-dashboard-starter/src/routeTree.gen.ts
@@ -19,8 +19,13 @@ import { Route as SettingsRouteImport } from './../../seller-dashboard/src/route
import { Route as ProfileRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/profile'
import { Route as OnboardingRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/onboarding'
import { Route as SettingsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/index'
+import { Route as ProductsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/index'
+import { Route as OrdersIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/orders/index'
import { Route as SettingsTeamRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/team'
import { Route as SettingsStockLocationsRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/stock-locations'
+import { Route as ProductsNewRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/new'
+import { Route as ProductsProductIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/$productId'
+import { Route as OrdersOrderIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/orders/$orderId'
const loginRoute = loginRouteImport.update({
id: '/login',
@@ -72,6 +77,16 @@ const SettingsIndexRoute = SettingsIndexRouteImport.update({
path: '/',
getParentRoute: () => SettingsRoute,
} as any)
+const ProductsIndexRoute = ProductsIndexRouteImport.update({
+ id: '/products/',
+ path: '/products/',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const OrdersIndexRoute = OrdersIndexRouteImport.update({
+ id: '/orders/',
+ path: '/orders/',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
const SettingsTeamRoute = SettingsTeamRouteImport.update({
id: '/team',
path: '/team',
@@ -82,6 +97,21 @@ const SettingsStockLocationsRoute = SettingsStockLocationsRouteImport.update({
path: '/stock-locations',
getParentRoute: () => SettingsRoute,
} as any)
+const ProductsNewRoute = ProductsNewRouteImport.update({
+ id: '/products/new',
+ path: '/products/new',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const ProductsProductIdRoute = ProductsProductIdRouteImport.update({
+ id: '/products/$productId',
+ path: '/products/$productId',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({
+ id: '/orders/$orderId',
+ path: '/orders/$orderId',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
export interface FileRoutesByFullPath {
'/': typeof authenticatedIndexRoute
@@ -92,8 +122,13 @@ export interface FileRoutesByFullPath {
'/$sellerId/profile': typeof ProfileRoute
'/$sellerId/settings': typeof SettingsRouteWithChildren
'/$sellerId/': typeof IndexRoute
+ '/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/$sellerId/products/new': typeof ProductsNewRoute
'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/$sellerId/orders/': typeof OrdersIndexRoute
+ '/$sellerId/products/': typeof ProductsIndexRoute
'/$sellerId/settings/': typeof SettingsIndexRoute
}
export interface FileRoutesByTo {
@@ -103,8 +138,13 @@ export interface FileRoutesByTo {
'/$sellerId/onboarding': typeof OnboardingRoute
'/$sellerId/profile': typeof ProfileRoute
'/$sellerId': typeof IndexRoute
+ '/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/$sellerId/products/new': typeof ProductsNewRoute
'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/$sellerId/orders': typeof OrdersIndexRoute
+ '/$sellerId/products': typeof ProductsIndexRoute
'/$sellerId/settings': typeof SettingsIndexRoute
}
export interface FileRoutesById {
@@ -118,8 +158,13 @@ export interface FileRoutesById {
'/_authenticated/$sellerId/profile': typeof ProfileRoute
'/_authenticated/$sellerId/settings': typeof SettingsRouteWithChildren
'/_authenticated/$sellerId/': typeof IndexRoute
+ '/_authenticated/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/_authenticated/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/_authenticated/$sellerId/products/new': typeof ProductsNewRoute
'/_authenticated/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/_authenticated/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/_authenticated/$sellerId/orders/': typeof OrdersIndexRoute
+ '/_authenticated/$sellerId/products/': typeof ProductsIndexRoute
'/_authenticated/$sellerId/settings/': typeof SettingsIndexRoute
}
export interface FileRouteTypes {
@@ -133,8 +178,13 @@ export interface FileRouteTypes {
| '/$sellerId/profile'
| '/$sellerId/settings'
| '/$sellerId/'
+ | '/$sellerId/orders/$orderId'
+ | '/$sellerId/products/$productId'
+ | '/$sellerId/products/new'
| '/$sellerId/settings/stock-locations'
| '/$sellerId/settings/team'
+ | '/$sellerId/orders/'
+ | '/$sellerId/products/'
| '/$sellerId/settings/'
fileRoutesByTo: FileRoutesByTo
to:
@@ -144,8 +194,13 @@ export interface FileRouteTypes {
| '/$sellerId/onboarding'
| '/$sellerId/profile'
| '/$sellerId'
+ | '/$sellerId/orders/$orderId'
+ | '/$sellerId/products/$productId'
+ | '/$sellerId/products/new'
| '/$sellerId/settings/stock-locations'
| '/$sellerId/settings/team'
+ | '/$sellerId/orders'
+ | '/$sellerId/products'
| '/$sellerId/settings'
id:
| '__root__'
@@ -158,8 +213,13 @@ export interface FileRouteTypes {
| '/_authenticated/$sellerId/profile'
| '/_authenticated/$sellerId/settings'
| '/_authenticated/$sellerId/'
+ | '/_authenticated/$sellerId/orders/$orderId'
+ | '/_authenticated/$sellerId/products/$productId'
+ | '/_authenticated/$sellerId/products/new'
| '/_authenticated/$sellerId/settings/stock-locations'
| '/_authenticated/$sellerId/settings/team'
+ | '/_authenticated/$sellerId/orders/'
+ | '/_authenticated/$sellerId/products/'
| '/_authenticated/$sellerId/settings/'
fileRoutesById: FileRoutesById
}
@@ -241,6 +301,20 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsIndexRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$sellerId/products/': {
+ id: '/_authenticated/$sellerId/products/'
+ path: '/products'
+ fullPath: '/$sellerId/products/'
+ preLoaderRoute: typeof ProductsIndexRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/orders/': {
+ id: '/_authenticated/$sellerId/orders/'
+ path: '/orders'
+ fullPath: '/$sellerId/orders/'
+ preLoaderRoute: typeof OrdersIndexRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
'/_authenticated/$sellerId/settings/team': {
id: '/_authenticated/$sellerId/settings/team'
path: '/team'
@@ -255,6 +329,27 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsStockLocationsRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$sellerId/products/new': {
+ id: '/_authenticated/$sellerId/products/new'
+ path: '/products/new'
+ fullPath: '/$sellerId/products/new'
+ preLoaderRoute: typeof ProductsNewRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/products/$productId': {
+ id: '/_authenticated/$sellerId/products/$productId'
+ path: '/products/$productId'
+ fullPath: '/$sellerId/products/$productId'
+ preLoaderRoute: typeof ProductsProductIdRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/orders/$orderId': {
+ id: '/_authenticated/$sellerId/orders/$orderId'
+ path: '/orders/$orderId'
+ fullPath: '/$sellerId/orders/$orderId'
+ preLoaderRoute: typeof OrdersOrderIdRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
}
}
@@ -279,6 +374,11 @@ interface authenticatedSellerIdRouteChildren {
ProfileRoute: typeof ProfileRoute
SettingsRoute: typeof SettingsRouteWithChildren
IndexRoute: typeof IndexRoute
+ OrdersOrderIdRoute: typeof OrdersOrderIdRoute
+ ProductsProductIdRoute: typeof ProductsProductIdRoute
+ ProductsNewRoute: typeof ProductsNewRoute
+ OrdersIndexRoute: typeof OrdersIndexRoute
+ ProductsIndexRoute: typeof ProductsIndexRoute
}
const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {
@@ -286,6 +386,11 @@ const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {
ProfileRoute: ProfileRoute,
SettingsRoute: SettingsRouteWithChildren,
IndexRoute: IndexRoute,
+ OrdersOrderIdRoute: OrdersOrderIdRoute,
+ ProductsProductIdRoute: ProductsProductIdRoute,
+ ProductsNewRoute: ProductsNewRoute,
+ OrdersIndexRoute: OrdersIndexRoute,
+ ProductsIndexRoute: ProductsIndexRoute,
}
const authenticatedSellerIdRouteWithChildren =
diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.json
index 16f662c788..72826f7415 100644
--- a/packages/seller-dashboard/src/locales/en.json
+++ b/packages/seller-dashboard/src/locales/en.json
@@ -20,7 +20,8 @@
"error": "Something went wrong.",
"loading": "Loading…",
"retry": "Try again",
- "save": "Save"
+ "save": "Save",
+ "saving": "Saving…"
},
"home": {
"products": "Products",
@@ -48,6 +49,8 @@
"nav": {
"home": "Home",
"onboarding": "Setup",
+ "orders": "Orders",
+ "products": "Products",
"profile": "Profile",
"settings": "Settings",
"sign_out": "Sign out",
@@ -84,6 +87,61 @@
"title": "Setup",
"under_review": "The marketplace is reviewing your application. We will email you when there is news."
},
+ "orders": {
+ "cancel": "Cancel order",
+ "cancel_confirm": {
+ "message": "The customer is refunded and any stock goes back on the shelf. This cannot be undone.",
+ "title": "Cancel this order?"
+ },
+ "canceled": "Order canceled",
+ "columns": {
+ "fulfillment": "Fulfillment",
+ "number": "Order",
+ "payment": "Payment",
+ "placed": "Placed",
+ "total": "Total"
+ },
+ "empty": "No orders yet. They appear here as customers buy from you.",
+ "fulfill": "Mark as shipped",
+ "fulfilled": "Marked as shipped",
+ "fulfilling": "Marking…",
+ "items": "Items",
+ "not_found": "That order could not be found.",
+ "search_placeholder": "Search by order number…",
+ "shipping_address": "Ships to",
+ "ships_from": "Ships from {{name}}",
+ "title": "Orders",
+ "tracking": "Tracking {{number}}",
+ "tracking_label": "Tracking number",
+ "tracking_placeholder": "Optional"
+ },
+ "products": {
+ "add": "Add product",
+ "columns": {
+ "name": "Product",
+ "price": "Price",
+ "status": "Status"
+ },
+ "details": "Details",
+ "empty": "No products yet. Add one to start selling.",
+ "fields": {
+ "description": "Description",
+ "name": "Name",
+ "price": "Price",
+ "price_placeholder": "Leave blank to keep the current price",
+ "status": "Status"
+ },
+ "new_title": "New product",
+ "not_found": "That product could not be found.",
+ "saved": "Product saved",
+ "search_placeholder": "Search by name…",
+ "statuses": {
+ "active": "Active",
+ "archived": "Archived",
+ "draft": "Draft"
+ },
+ "title": "Products"
+ },
"profile": {
"about": "About",
"add_address": "Add address",
diff --git a/packages/seller-dashboard/src/nav/default.ts b/packages/seller-dashboard/src/nav/default.ts
index 68fe36bf31..da19cea261 100644
--- a/packages/seller-dashboard/src/nav/default.ts
+++ b/packages/seller-dashboard/src/nav/default.ts
@@ -1,5 +1,12 @@
import { hasVisibleSettingsEntries, i18n, nav } from '@spree/dashboard-core'
-import { ClipboardCheckIcon, HomeIcon, SettingsIcon, StoreIcon } from 'lucide-react'
+import {
+ ClipboardCheckIcon,
+ HomeIcon,
+ PackageIcon,
+ SettingsIcon,
+ StoreIcon,
+ TagIcon,
+} from 'lucide-react'
import { OnboardingNavBadge } from '../components/onboarding-nav-badge'
// The panel's built-in sidebar. Registered into the same registry a plugin
@@ -35,6 +42,24 @@ nav.add({
badge: OnboardingNavBadge,
})
+nav.add({
+ key: 'products',
+ label: i18n.t('nav.products'),
+ path: '/products',
+ icon: TagIcon,
+ position: 110,
+ subject: 'Spree::Product',
+})
+
+nav.add({
+ key: 'orders',
+ label: i18n.t('nav.orders'),
+ path: '/orders',
+ icon: PackageIcon,
+ position: 120,
+ subject: 'Spree::Order',
+})
+
nav.add({
key: 'profile',
label: i18n.t('nav.profile'),
diff --git a/packages/seller-dashboard/src/pages/order.tsx b/packages/seller-dashboard/src/pages/order.tsx
new file mode 100644
index 0000000000..07f4bc4c66
--- /dev/null
+++ b/packages/seller-dashboard/src/pages/order.tsx
@@ -0,0 +1,204 @@
+import {
+ AddressBlock,
+ Badge,
+ Button,
+ Card,
+ CardAction,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Field,
+ FieldLabel,
+ Input,
+ StatusBadge,
+ toastManager,
+ useConfirm,
+} from '@spree/dashboard-ui'
+import type { Fulfillment } from '@spree/seller-sdk'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
+import { useParams } from '@tanstack/react-router'
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { sellerClient } from '../api-client'
+import { CenteredMessage } from '../components/centered-message'
+
+/** One order, as the seller needs it to pack and post the parcel. */
+export function OrderPage() {
+ const { t } = useTranslation()
+ const { sellerId, orderId } = useParams({ from: '/_authenticated/$sellerId/orders/$orderId' })
+ const queryClient = useQueryClient()
+ const confirm = useConfirm()
+
+ const orderKey = ['seller', sellerId, 'order', orderId]
+ const { data: order, isLoading } = useQuery({
+ queryKey: orderKey,
+ queryFn: () => sellerClient().orders.get(orderId),
+ })
+
+ const cancel = useMutation({
+ mutationFn: () => sellerClient().orders.cancel(orderId),
+ onSuccess: (updated) => {
+ queryClient.setQueryData(orderKey, updated)
+ void queryClient.invalidateQueries({ queryKey: ['seller-orders'] })
+ toastManager.add({ type: 'success', title: t('orders.canceled') })
+ },
+ onError: (err) =>
+ toastManager.add({
+ type: 'error',
+ title: err instanceof Error ? err.message : t('common.error'),
+ }),
+ })
+
+ if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>
+ if (!order) return <CenteredMessage>{t('orders.not_found')}</CenteredMessage>
+
+ async function handleCancel() {
+ const ok = await confirm({
+ title: t('orders.cancel_confirm.title'),
+ message: t('orders.cancel_confirm.message'),
+ variant: 'destructive',
+ confirmLabel: t('orders.cancel'),
+ })
+ if (!ok) return
+ await cancel.mutateAsync().catch(() => undefined)
+ }
+
+ const cancelable = order.status !== 'canceled'
+
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="flex items-start justify-between gap-4">
+ <div>
+ <h1 className="font-medium text-2xl">{order.number}</h1>
+ <p className="text-muted-foreground text-sm">
+ {order.completed_at ? new Date(order.completed_at).toLocaleString() : null}
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {order.fulfillment_status && <StatusBadge status={order.fulfillment_status} />}
+ {cancelable && (
+ <Button variant="outline" disabled={cancel.isPending} onClick={handleCancel}>
+ {t('orders.cancel')}
+ </Button>
+ )}
+ </div>
+ </div>
+
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('orders.items')}</CardTitle>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ {order.items.map((item) => (
+ <div key={item.id} className="flex items-center justify-between gap-3">
+ <div className="min-w-0">
+ <div className="truncate text-sm font-medium">{item.name}</div>
+ <div className="truncate text-muted-foreground text-xs">
+ {[item.sku, item.options_text].filter(Boolean).join(' · ')}
+ </div>
+ </div>
+ <div className="flex shrink-0 items-center gap-4 text-sm">
+ <span className="text-muted-foreground">× {item.quantity}</span>
+ <span>{item.display_total as string}</span>
+ </div>
+ </div>
+ ))}
+ </CardContent>
+ </Card>
+
+ {order.fulfillments.map((fulfillment) => (
+ <FulfillmentCard key={fulfillment.id} orderId={orderId} fulfillment={fulfillment} />
+ ))}
+
+ {order.shipping_address && (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('orders.shipping_address')}</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <AddressBlock address={order.shipping_address} />
+ </CardContent>
+ </Card>
+ )}
+ </div>
+ )
+}
+
+/**
+ * One parcel. Shipping it is the seller's own action, so the tracking number
+ * is entered here rather than on a separate screen — it is the thing they
+ * have in hand when they come to mark it sent.
+ */
+function FulfillmentCard({ orderId, fulfillment }: { orderId: string; fulfillment: Fulfillment }) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const queryClient = useQueryClient()
+ const [tracking, setTracking] = useState('')
+
+ const fulfill = useMutation({
+ mutationFn: () =>
+ sellerClient().orders.fulfillments.fulfill(orderId, fulfillment.id, {
+ tracking: tracking.trim() || undefined,
+ }),
+ onSuccess: () => {
+ void queryClient.invalidateQueries({ queryKey: ['seller', sellerId, 'order', orderId] })
+ void queryClient.invalidateQueries({ queryKey: ['seller-orders'] })
+ toastManager.add({ type: 'success', title: t('orders.fulfilled') })
+ },
+ onError: (err) =>
+ toastManager.add({
+ type: 'error',
+ title: err instanceof Error ? err.message : t('common.error'),
+ }),
+ })
+
+ const shipped = fulfillment.status !== 'unfulfilled'
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{fulfillment.number}</CardTitle>
+ <CardAction>
+ <Badge variant={shipped ? 'success' : 'secondary'}>{fulfillment.status}</Badge>
+ </CardAction>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ {fulfillment.stock_location_name && (
+ <p className="text-muted-foreground text-sm">
+ {t('orders.ships_from', { name: fulfillment.stock_location_name })}
+ </p>
+ )}
+
+ {fulfillment.items?.map((item) => (
+ <div key={item.id} className="flex items-center justify-between gap-3 text-sm">
+ <span className="truncate">{item.name}</span>
+ <span className="text-muted-foreground">× {item.quantity}</span>
+ </div>
+ ))}
+
+ {shipped ? (
+ fulfillment.tracking && (
+ <p className="text-sm">{t('orders.tracking', { number: fulfillment.tracking })}</p>
+ )
+ ) : (
+ <div className="flex items-end gap-2">
+ <Field className="flex-1">
+ <FieldLabel htmlFor={`tracking-${fulfillment.id}`}>
+ {t('orders.tracking_label')}
+ </FieldLabel>
+ <Input
+ id={`tracking-${fulfillment.id}`}
+ value={tracking}
+ placeholder={t('orders.tracking_placeholder')}
+ onChange={(event) => setTracking(event.target.value)}
+ />
+ </Field>
+ <Button disabled={fulfill.isPending} onClick={() => fulfill.mutate()}>
+ {fulfill.isPending ? t('orders.fulfilling') : t('orders.fulfill')}
+ </Button>
+ </div>
+ )}
+ </CardContent>
+ </Card>
+ )
+}
diff --git a/packages/seller-dashboard/src/pages/orders.tsx b/packages/seller-dashboard/src/pages/orders.tsx
new file mode 100644
index 0000000000..0fcd5e48f4
--- /dev/null
+++ b/packages/seller-dashboard/src/pages/orders.tsx
@@ -0,0 +1,31 @@
+import { type ResourceSearch, ResourceTable } from '@spree/dashboard-core'
+import { useRowClickBridge } from '@spree/dashboard-ui'
+import type { Order } from '@spree/seller-sdk'
+import { useNavigate, useParams } from '@tanstack/react-router'
+import { useTranslation } from 'react-i18next'
+import { sellerClient } from '../api-client'
+import '../tables/orders'
+
+/** What this seller has sold, newest first. */
+export function OrdersPage({ search }: { search: ResourceSearch }) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const navigate = useNavigate()
+
+ useRowClickBridge('data-order-id', (orderId: string) =>
+ navigate({ to: '/$sellerId/orders/$orderId', params: { sellerId, orderId } }),
+ )
+
+ return (
+ <div className="flex flex-col gap-4">
+ <h1 className="font-medium text-2xl">{t('orders.title')}</h1>
+
+ <ResourceTable<Order>
+ tableKey="seller-orders"
+ queryKey="seller-orders"
+ queryFn={(params) => sellerClient().orders.list(params)}
+ searchParams={search}
+ />
+ </div>
+ )
+}
diff --git a/packages/seller-dashboard/src/pages/product.tsx b/packages/seller-dashboard/src/pages/product.tsx
new file mode 100644
index 0000000000..9196192f61
--- /dev/null
+++ b/packages/seller-dashboard/src/pages/product.tsx
@@ -0,0 +1,200 @@
+import { mapSpreeErrorsToForm } from '@spree/dashboard-core'
+import {
+ Button,
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Textarea,
+ toastManager,
+} from '@spree/dashboard-ui'
+import type { ProductParams } from '@spree/seller-sdk'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
+import { useNavigate, useParams } from '@tanstack/react-router'
+import { useEffect } from 'react'
+import { useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import { sellerClient } from '../api-client'
+import { CenteredMessage } from '../components/centered-message'
+
+const STATUSES = ['draft', 'active', 'archived'] as const
+
+interface ProductFormValues {
+ name: string
+ description: string
+ status: string
+ amount: string
+}
+
+/**
+ * One product, created or edited.
+ *
+ * The same form either way: a seller filling in a new listing and a seller
+ * correcting an old one are doing the same thing, and two screens would drift.
+ */
+export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const params = useParams({ strict: false }) as { productId?: string }
+ const productId = mode === 'edit' ? params.productId : undefined
+ const navigate = useNavigate()
+ const queryClient = useQueryClient()
+
+ const { data: product, isLoading } = useQuery({
+ queryKey: ['seller', sellerId, 'product', productId],
+ queryFn: () => sellerClient().products.get(productId as string),
+ enabled: !!productId,
+ })
+
+ const form = useForm<ProductFormValues>({
+ defaultValues: { name: '', description: '', status: 'draft', amount: '' },
+ })
+
+ // Reset once the record arrives, so the inputs show what was last saved
+ // rather than the blank defaults the form mounted with.
+ useEffect(() => {
+ if (!product) return
+
+ form.reset({
+ name: product.name ?? '',
+ description: product.description ?? '',
+ status: product.status ?? 'draft',
+ amount: product.price?.amount ?? '',
+ })
+ }, [product, form])
+
+ const save = useMutation({
+ mutationFn: (values: ProductFormValues) => {
+ const payload: ProductParams = {
+ name: values.name,
+ description: values.description,
+ status: values.status,
+ }
+ // Only sent when the seller typed one: an empty box means "leave the
+ // price alone", not "price this at nothing".
+ if (values.amount.trim()) {
+ payload.prices = [
+ { amount: values.amount.trim(), currency: product?.price?.currency ?? 'USD' },
+ ]
+ }
+
+ return productId
+ ? sellerClient().products.update(productId, payload)
+ : sellerClient().products.create(payload)
+ },
+ onSuccess: (saved) => {
+ void queryClient.invalidateQueries({ queryKey: ['seller-products'] })
+ queryClient.setQueryData(['seller', sellerId, 'product', saved.id], saved)
+ toastManager.add({ type: 'success', title: t('products.saved') })
+ if (!productId) {
+ navigate({
+ to: '/$sellerId/products/$productId',
+ params: { sellerId, productId: saved.id },
+ })
+ }
+ },
+ })
+
+ async function onSubmit(values: ProductFormValues) {
+ try {
+ await save.mutateAsync(values)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) {
+ toastManager.add({
+ type: 'error',
+ title: err instanceof Error ? err.message : t('common.error'),
+ })
+ }
+ }
+ }
+
+ if (mode === 'edit' && isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>
+ if (mode === 'edit' && !product)
+ return <CenteredMessage>{t('products.not_found')}</CenteredMessage>
+
+ const { errors, isSubmitting } = form.formState
+
+ return (
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-4">
+ <div className="flex items-center justify-between gap-4">
+ <h1 className="font-medium text-2xl">
+ {productId ? product?.name : t('products.new_title')}
+ </h1>
+ <Button type="submit" disabled={isSubmitting}>
+ {isSubmitting ? t('common.saving') : t('common.save')}
+ </Button>
+ </div>
+
+ {errors.root?.message && (
+ <p className="text-destructive text-sm" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('products.details')}</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <FieldGroup>
+ <Field>
+ <FieldLabel htmlFor="name">{t('products.fields.name')}</FieldLabel>
+ <Input
+ id="name"
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name', { required: true })}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="description">{t('products.fields.description')}</FieldLabel>
+ <Textarea id="description" rows={5} {...form.register('description')} />
+ <FieldError errors={[errors.description]} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="amount">{t('products.fields.price')}</FieldLabel>
+ <Input
+ id="amount"
+ inputMode="decimal"
+ placeholder={t('products.fields.price_placeholder')}
+ {...form.register('amount')}
+ />
+ <FieldError errors={[errors.amount]} />
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="status">{t('products.fields.status')}</FieldLabel>
+ <Select
+ value={form.watch('status')}
+ onValueChange={(value) => form.setValue('status', value, { shouldDirty: true })}
+ >
+ <SelectTrigger id="status">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {STATUSES.map((status) => (
+ <SelectItem key={status} value={status}>
+ {t(`products.statuses.${status}`)}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Field>
+ </FieldGroup>
+ </CardContent>
+ </Card>
+ </form>
+ )
+}
diff --git a/packages/seller-dashboard/src/pages/products.tsx b/packages/seller-dashboard/src/pages/products.tsx
new file mode 100644
index 0000000000..9f29c6b707
--- /dev/null
+++ b/packages/seller-dashboard/src/pages/products.tsx
@@ -0,0 +1,39 @@
+import { type ResourceSearch, ResourceTable } from '@spree/dashboard-core'
+import { Button, useRowClickBridge } from '@spree/dashboard-ui'
+import type { Product } from '@spree/seller-sdk'
+import { useNavigate, useParams } from '@tanstack/react-router'
+import { PlusIcon } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
+import { sellerClient } from '../api-client'
+import '../tables/products'
+
+/** This seller's own catalog. */
+export function ProductsPage({ search }: { search: ResourceSearch }) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const navigate = useNavigate()
+
+ const open = (productId: string) =>
+ navigate({ to: '/$sellerId/products/$productId', params: { sellerId, productId } })
+
+ useRowClickBridge('data-product-id', open)
+
+ return (
+ <div className="flex flex-col gap-4">
+ <h1 className="font-medium text-2xl">{t('products.title')}</h1>
+
+ <ResourceTable<Product>
+ tableKey="seller-products"
+ queryKey="seller-products"
+ queryFn={(params) => sellerClient().products.list(params)}
+ searchParams={search}
+ actions={
+ <Button onClick={() => navigate({ to: '/$sellerId/products/new', params: { sellerId } })}>
+ <PlusIcon className="size-4" />
+ {t('products.add')}
+ </Button>
+ }
+ />
+ </div>
+ )
+}
diff --git a/packages/seller-dashboard/src/routeTree.gen.ts b/packages/seller-dashboard/src/routeTree.gen.ts
index 511fc8b23c..b1efa9f77f 100644
--- a/packages/seller-dashboard/src/routeTree.gen.ts
+++ b/packages/seller-dashboard/src/routeTree.gen.ts
@@ -19,8 +19,13 @@ import { Route as SettingsRouteImport } from './routes/_authenticated/$sellerId/
import { Route as ProfileRouteImport } from './routes/_authenticated/$sellerId/profile'
import { Route as OnboardingRouteImport } from './routes/_authenticated/$sellerId/onboarding'
import { Route as SettingsIndexRouteImport } from './routes/_authenticated/$sellerId/settings/index'
+import { Route as ProductsIndexRouteImport } from './routes/_authenticated/$sellerId/products/index'
+import { Route as OrdersIndexRouteImport } from './routes/_authenticated/$sellerId/orders/index'
import { Route as SettingsTeamRouteImport } from './routes/_authenticated/$sellerId/settings/team'
import { Route as SettingsStockLocationsRouteImport } from './routes/_authenticated/$sellerId/settings/stock-locations'
+import { Route as ProductsNewRouteImport } from './routes/_authenticated/$sellerId/products/new'
+import { Route as ProductsProductIdRouteImport } from './routes/_authenticated/$sellerId/products/$productId'
+import { Route as OrdersOrderIdRouteImport } from './routes/_authenticated/$sellerId/orders/$orderId'
const loginRoute = loginRouteImport.update({
id: '/login',
@@ -72,6 +77,16 @@ const SettingsIndexRoute = SettingsIndexRouteImport.update({
path: '/',
getParentRoute: () => SettingsRoute,
} as any)
+const ProductsIndexRoute = ProductsIndexRouteImport.update({
+ id: '/products/',
+ path: '/products/',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const OrdersIndexRoute = OrdersIndexRouteImport.update({
+ id: '/orders/',
+ path: '/orders/',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
const SettingsTeamRoute = SettingsTeamRouteImport.update({
id: '/team',
path: '/team',
@@ -82,6 +97,21 @@ const SettingsStockLocationsRoute = SettingsStockLocationsRouteImport.update({
path: '/stock-locations',
getParentRoute: () => SettingsRoute,
} as any)
+const ProductsNewRoute = ProductsNewRouteImport.update({
+ id: '/products/new',
+ path: '/products/new',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const ProductsProductIdRoute = ProductsProductIdRouteImport.update({
+ id: '/products/$productId',
+ path: '/products/$productId',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
+const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({
+ id: '/orders/$orderId',
+ path: '/orders/$orderId',
+ getParentRoute: () => authenticatedSellerIdRoute,
+} as any)
export interface FileRoutesByFullPath {
'/': typeof authenticatedIndexRoute
@@ -92,8 +122,13 @@ export interface FileRoutesByFullPath {
'/$sellerId/profile': typeof ProfileRoute
'/$sellerId/settings': typeof SettingsRouteWithChildren
'/$sellerId/': typeof IndexRoute
+ '/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/$sellerId/products/new': typeof ProductsNewRoute
'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/$sellerId/orders/': typeof OrdersIndexRoute
+ '/$sellerId/products/': typeof ProductsIndexRoute
'/$sellerId/settings/': typeof SettingsIndexRoute
}
export interface FileRoutesByTo {
@@ -103,8 +138,13 @@ export interface FileRoutesByTo {
'/$sellerId/onboarding': typeof OnboardingRoute
'/$sellerId/profile': typeof ProfileRoute
'/$sellerId': typeof IndexRoute
+ '/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/$sellerId/products/new': typeof ProductsNewRoute
'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/$sellerId/orders': typeof OrdersIndexRoute
+ '/$sellerId/products': typeof ProductsIndexRoute
'/$sellerId/settings': typeof SettingsIndexRoute
}
export interface FileRoutesById {
@@ -118,8 +158,13 @@ export interface FileRoutesById {
'/_authenticated/$sellerId/profile': typeof ProfileRoute
'/_authenticated/$sellerId/settings': typeof SettingsRouteWithChildren
'/_authenticated/$sellerId/': typeof IndexRoute
+ '/_authenticated/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute
+ '/_authenticated/$sellerId/products/$productId': typeof ProductsProductIdRoute
+ '/_authenticated/$sellerId/products/new': typeof ProductsNewRoute
'/_authenticated/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/_authenticated/$sellerId/settings/team': typeof SettingsTeamRoute
+ '/_authenticated/$sellerId/orders/': typeof OrdersIndexRoute
+ '/_authenticated/$sellerId/products/': typeof ProductsIndexRoute
'/_authenticated/$sellerId/settings/': typeof SettingsIndexRoute
}
export interface FileRouteTypes {
@@ -133,8 +178,13 @@ export interface FileRouteTypes {
| '/$sellerId/profile'
| '/$sellerId/settings'
| '/$sellerId/'
+ | '/$sellerId/orders/$orderId'
+ | '/$sellerId/products/$productId'
+ | '/$sellerId/products/new'
| '/$sellerId/settings/stock-locations'
| '/$sellerId/settings/team'
+ | '/$sellerId/orders/'
+ | '/$sellerId/products/'
| '/$sellerId/settings/'
fileRoutesByTo: FileRoutesByTo
to:
@@ -144,8 +194,13 @@ export interface FileRouteTypes {
| '/$sellerId/onboarding'
| '/$sellerId/profile'
| '/$sellerId'
+ | '/$sellerId/orders/$orderId'
+ | '/$sellerId/products/$productId'
+ | '/$sellerId/products/new'
| '/$sellerId/settings/stock-locations'
| '/$sellerId/settings/team'
+ | '/$sellerId/orders'
+ | '/$sellerId/products'
| '/$sellerId/settings'
id:
| '__root__'
@@ -158,8 +213,13 @@ export interface FileRouteTypes {
| '/_authenticated/$sellerId/profile'
| '/_authenticated/$sellerId/settings'
| '/_authenticated/$sellerId/'
+ | '/_authenticated/$sellerId/orders/$orderId'
+ | '/_authenticated/$sellerId/products/$productId'
+ | '/_authenticated/$sellerId/products/new'
| '/_authenticated/$sellerId/settings/stock-locations'
| '/_authenticated/$sellerId/settings/team'
+ | '/_authenticated/$sellerId/orders/'
+ | '/_authenticated/$sellerId/products/'
| '/_authenticated/$sellerId/settings/'
fileRoutesById: FileRoutesById
}
@@ -241,6 +301,20 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsIndexRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$sellerId/products/': {
+ id: '/_authenticated/$sellerId/products/'
+ path: '/products'
+ fullPath: '/$sellerId/products/'
+ preLoaderRoute: typeof ProductsIndexRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/orders/': {
+ id: '/_authenticated/$sellerId/orders/'
+ path: '/orders'
+ fullPath: '/$sellerId/orders/'
+ preLoaderRoute: typeof OrdersIndexRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
'/_authenticated/$sellerId/settings/team': {
id: '/_authenticated/$sellerId/settings/team'
path: '/team'
@@ -255,6 +329,27 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsStockLocationsRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$sellerId/products/new': {
+ id: '/_authenticated/$sellerId/products/new'
+ path: '/products/new'
+ fullPath: '/$sellerId/products/new'
+ preLoaderRoute: typeof ProductsNewRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/products/$productId': {
+ id: '/_authenticated/$sellerId/products/$productId'
+ path: '/products/$productId'
+ fullPath: '/$sellerId/products/$productId'
+ preLoaderRoute: typeof ProductsProductIdRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
+ '/_authenticated/$sellerId/orders/$orderId': {
+ id: '/_authenticated/$sellerId/orders/$orderId'
+ path: '/orders/$orderId'
+ fullPath: '/$sellerId/orders/$orderId'
+ preLoaderRoute: typeof OrdersOrderIdRouteImport
+ parentRoute: typeof authenticatedSellerIdRoute
+ }
}
}
@@ -279,6 +374,11 @@ interface authenticatedSellerIdRouteChildren {
ProfileRoute: typeof ProfileRoute
SettingsRoute: typeof SettingsRouteWithChildren
IndexRoute: typeof IndexRoute
+ OrdersOrderIdRoute: typeof OrdersOrderIdRoute
+ ProductsProductIdRoute: typeof ProductsProductIdRoute
+ ProductsNewRoute: typeof ProductsNewRoute
+ OrdersIndexRoute: typeof OrdersIndexRoute
+ ProductsIndexRoute: typeof ProductsIndexRoute
}
const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {
@@ -286,6 +386,11 @@ const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {
ProfileRoute: ProfileRoute,
SettingsRoute: SettingsRouteWithChildren,
IndexRoute: IndexRoute,
+ OrdersOrderIdRoute: OrdersOrderIdRoute,
+ ProductsProductIdRoute: ProductsProductIdRoute,
+ ProductsNewRoute: ProductsNewRoute,
+ OrdersIndexRoute: OrdersIndexRoute,
+ ProductsIndexRoute: ProductsIndexRoute,
}
const authenticatedSellerIdRouteWithChildren =
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/$orderId.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/$orderId.tsx
new file mode 100644
index 0000000000..573f027f8a
--- /dev/null
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/$orderId.tsx
@@ -0,0 +1,6 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { OrderPage } from '../../../../pages/order'
+
+export const Route = createFileRoute('/_authenticated/$sellerId/orders/$orderId')({
+ component: OrderPage,
+})
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/index.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/index.tsx
new file mode 100644
index 0000000000..f2f25d73be
--- /dev/null
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/orders/index.tsx
@@ -0,0 +1,15 @@
+import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core'
+import { createFileRoute } from '@tanstack/react-router'
+import { OrdersPage } from '../../../../pages/orders'
+
+export const Route = createFileRoute('/_authenticated/$sellerId/orders/')({
+ validateSearch: resourceSearchSchema,
+ component: OrdersRoute,
+})
+
+function OrdersRoute() {
+ // Cast: the inferred type unions with the parent layout's shape.
+ const search = Route.useSearch() as ResourceSearch
+
+ return <OrdersPage search={search} />
+}
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/$productId.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/$productId.tsx
new file mode 100644
index 0000000000..4a85ab84e8
--- /dev/null
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/$productId.tsx
@@ -0,0 +1,6 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { ProductPage } from '../../../../pages/product'
+
+export const Route = createFileRoute('/_authenticated/$sellerId/products/$productId')({
+ component: () => <ProductPage mode="edit" />,
+})
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/index.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/index.tsx
new file mode 100644
index 0000000000..df84f9f902
--- /dev/null
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/index.tsx
@@ -0,0 +1,15 @@
+import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core'
+import { createFileRoute } from '@tanstack/react-router'
+import { ProductsPage } from '../../../../pages/products'
+
+export const Route = createFileRoute('/_authenticated/$sellerId/products/')({
+ validateSearch: resourceSearchSchema,
+ component: ProductsRoute,
+})
+
+function ProductsRoute() {
+ // Cast: the inferred type unions with the parent layout's shape.
+ const search = Route.useSearch() as ResourceSearch
+
+ return <ProductsPage search={search} />
+}
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/new.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/new.tsx
new file mode 100644
index 0000000000..c923267f71
--- /dev/null
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/products/new.tsx
@@ -0,0 +1,6 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { ProductPage } from '../../../../pages/product'
+
+export const Route = createFileRoute('/_authenticated/$sellerId/products/new')({
+ component: () => <ProductPage mode="new" />,
+})
diff --git a/packages/seller-dashboard/src/tables/orders.tsx b/packages/seller-dashboard/src/tables/orders.tsx
new file mode 100644
index 0000000000..404c50fd11
--- /dev/null
+++ b/packages/seller-dashboard/src/tables/orders.tsx
@@ -0,0 +1,53 @@
+import { defineTable } from '@spree/dashboard-core'
+import { ResourceNameCell, StatusBadge } from '@spree/dashboard-ui'
+import type { Order } from '@spree/seller-sdk'
+import i18n from 'i18next'
+import { PackageIcon } from 'lucide-react'
+
+defineTable<Order>('seller-orders', {
+ title: i18n.t('orders.title'),
+ searchParam: 'number_cont',
+ searchPlaceholder: i18n.t('orders.search_placeholder'),
+ defaultSort: { field: 'completed_at', direction: 'desc' },
+ emptyIcon: <PackageIcon className="size-8 text-muted-foreground" />,
+ emptyMessage: i18n.t('orders.empty'),
+ columns: [
+ {
+ key: 'number',
+ label: i18n.t('orders.columns.number'),
+ sortable: true,
+ default: true,
+ render: (order) => (
+ <ResourceNameCell id={order.id} dataAttr="data-order-id" name={order.number} />
+ ),
+ },
+ {
+ key: 'completed_at',
+ label: i18n.t('orders.columns.placed'),
+ sortable: true,
+ default: true,
+ render: (order) =>
+ order.completed_at ? new Date(order.completed_at).toLocaleDateString() : '—',
+ },
+ {
+ key: 'fulfillment_status',
+ label: i18n.t('orders.columns.fulfillment'),
+ default: true,
+ render: (order) =>
+ order.fulfillment_status ? <StatusBadge status={order.fulfillment_status} /> : '—',
+ },
+ {
+ key: 'payment_status',
+ label: i18n.t('orders.columns.payment'),
+ default: true,
+ render: (order) =>
+ order.payment_status ? <StatusBadge status={order.payment_status} /> : '—',
+ },
+ {
+ key: 'total',
+ label: i18n.t('orders.columns.total'),
+ default: true,
+ render: (order) => order.display_total as string,
+ },
+ ],
+})
diff --git a/packages/seller-dashboard/src/tables/products.tsx b/packages/seller-dashboard/src/tables/products.tsx
new file mode 100644
index 0000000000..3c56c7706c
--- /dev/null
+++ b/packages/seller-dashboard/src/tables/products.tsx
@@ -0,0 +1,42 @@
+import { defineTable } from '@spree/dashboard-core'
+import { ResourceNameCell, StatusBadge, Thumbnail } from '@spree/dashboard-ui'
+import type { Product } from '@spree/seller-sdk'
+import i18n from 'i18next'
+import { PackageIcon } from 'lucide-react'
+
+defineTable<Product>('seller-products', {
+ title: i18n.t('products.title'),
+ searchParam: 'name_cont',
+ searchPlaceholder: i18n.t('products.search_placeholder'),
+ defaultSort: { field: 'created_at', direction: 'desc' },
+ emptyIcon: <PackageIcon className="size-8 text-muted-foreground" />,
+ emptyMessage: i18n.t('products.empty'),
+ columns: [
+ {
+ key: 'name',
+ label: i18n.t('products.columns.name'),
+ sortable: true,
+ filterable: true,
+ default: true,
+ render: (product) => (
+ <div className="flex items-center gap-3">
+ <Thumbnail src={product.thumbnail_url} alt={product.name} />
+ <ResourceNameCell id={product.id} dataAttr="data-product-id" name={product.name} />
+ </div>
+ ),
+ },
+ {
+ key: 'status',
+ label: i18n.t('products.columns.status'),
+ sortable: true,
+ default: true,
+ render: (product) => <StatusBadge status={product.status} />,
+ },
+ {
+ key: 'price',
+ label: i18n.t('products.columns.price'),
+ default: true,
+ render: (product) => product.price?.display_amount ?? '—',
+ },
+ ],
+})
diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.ts
index 5a9cd0d1db..39d82ecf25 100644
--- a/packages/seller-sdk/src/seller-client.ts
+++ b/packages/seller-sdk/src/seller-client.ts
@@ -1,4 +1,4 @@
-import type { ListParams, ListResponse, RequestFn, RequestOptions } from '@spree/sdk-core'
+import type { ListParams, PaginatedResponse, RequestFn, RequestOptions } from '@spree/sdk-core'
import { transformListParams } from '@spree/sdk-core'
import type {
AuthTokens,
@@ -202,8 +202,8 @@ export class SellerClient {
list: (
params?: ListParams & Record<string, unknown>,
options?: RequestOptions,
- ): Promise<ListResponse<Product>> =>
- this.request<ListResponse<Product>>('GET', '/products', {
+ ): Promise<PaginatedResponse<Product>> =>
+ this.request<PaginatedResponse<Product>>('GET', '/products', {
...options,
params: params ? transformListParams(params) : undefined,
}),
@@ -230,8 +230,8 @@ export class SellerClient {
list: (
params?: ListParams & Record<string, unknown>,
options?: RequestOptions,
- ): Promise<ListResponse<Order>> =>
- this.request<ListResponse<Order>>('GET', '/orders', {
+ ): Promise<PaginatedResponse<Order>> =>
+ this.request<PaginatedResponse<Order>>('GET', '/orders', {
...options,
params: params ? transformListParams(params) : undefined,
}),
@@ -304,8 +304,8 @@ export class SellerClient {
list: (
params?: ListParams & Record<string, unknown>,
options?: RequestOptions,
- ): Promise<ListResponse<StockLocation>> =>
- this.request<ListResponse<StockLocation>>('GET', '/stock_locations', {
+ ): Promise<PaginatedResponse<StockLocation>> =>
+ this.request<PaginatedResponse<StockLocation>>('GET', '/stock_locations', {
...options,
params: params ? transformListParams(params) : undefined,
}),