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
Implement channels and product publications in dashboard
Damian Legawiececfaa858d8fa
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.tsindex 04c91714e5..6e2322a8c4 100644--- a/packages/dashboard-core/src/lib/permissions.ts+++ b/packages/dashboard-core/src/lib/permissions.ts@@ -15,6 +15,7 @@ export const Subject = {ApiKey: 'Spree::ApiKey',AllowedOrigin: 'Spree::AllowedOrigin',Store: 'Spree::Store',+ Channel: 'Spree::Channel',Taxon: 'Spree::Taxon',Taxonomy: 'Spree::Taxonomy',OptionType: 'Spree::OptionType',diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.jsonindex cb14589e8c..0ce6fd74f5 100644--- a/packages/dashboard-core/src/locales/en.json+++ b/packages/dashboard-core/src/locales/en.json@@ -8,6 +8,7 @@"revoke": "Revoke","close": "Close","confirm": "Confirm",+ "done": "Done","create": "Create","creating": "Creating…","delete": "Delete",@@ -308,6 +309,9 @@"currency_select": {"placeholder": "Select a currency"},+ "channel_select": {+ "placeholder": "Select a sales channel"+ },"locale_select": {"placeholder": "Select a locale","multi_placeholder": "Add locales…",diff --git a/packages/dashboard-core/src/plugin.ts b/packages/dashboard-core/src/plugin.tsindex 571451db34..5c25d83912 100644--- a/packages/dashboard-core/src/plugin.ts+++ b/packages/dashboard-core/src/plugin.ts@@ -46,8 +46,7 @@ export interface TableMutations {/** Column keys to remove. No-op when the column is already gone. */remove?: string[]/** Column patches keyed by column key — `{ totals: { label: 'Net total' } }`. */- // biome-ignore lint/suspicious/noExplicitAny: ColumnDef is generic per-row-type and the plugin layer can't know which.- update?: Record<string, Partial<ColumnDef<any>>>+ update?: Record<string, Partial<ColumnDef>>}export interface DashboardPluginConfig {diff --git a/packages/dashboard/e2e/channels.spec.ts b/packages/dashboard/e2e/channels.spec.tsnew file mode 100644index 0000000000..44f3a67aae--- /dev/null+++ b/packages/dashboard/e2e/channels.spec.ts@@ -0,0 +1,81 @@+import { expect, type Page, test } from '@playwright/test'+import {+ clickBulkAction,+ FIXTURE_BULK_CHANNEL_NAME,+ FIXTURE_BULK_PRODUCT_K,+ FIXTURE_BULK_PRODUCT_L,+ FIXTURE_BULK_PRODUCT_M,+ FIXTURE_BULK_PRODUCT_N,+ gotoIndex,+ login,+} from './helpers'++const PRODUCTS_PATH = (storeId: string) => `/${storeId}/products`+const CTA = /add product/i++async function selectRow(page: Page, productName: string) {+ await page+ .locator('tr')+ .filter({ hasText: productName })+ .getByRole('checkbox', { name: /select row/i })+ .check()+}++test.describe('products channels bulk operations', () => {+ test('lists selected products on a channel via Add to sales channels…', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, PRODUCTS_PATH(creds.store_id), CTA)++ await selectRow(page, FIXTURE_BULK_PRODUCT_K)+ await selectRow(page, FIXTURE_BULK_PRODUCT_L)+ await expect(page.getByText(/^2 selected$/)).toBeVisible()++ await clickBulkAction(page, /add to sales channels/i)+ await expect(page.getByRole('heading', { name: /^add to sales channels$/i })).toBeVisible()++ await page+ .getByRole('dialog')+ .getByPlaceholder(/search sales channels/i)+ .fill(FIXTURE_BULK_CHANNEL_NAME)+ await page+ .getByRole('option', { name: new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i') })+ .first()+ .click()+ await page.getByRole('dialog').getByRole('button', { name: /^add$/i }).click()++ await expect(page.getByText(/listed 2 products on sales channels/i)).toBeVisible({+ timeout: 15_000,+ })+ })++ test('unlists selected products from a channel via Remove from sales channels…', async ({+ page,+ }) => {+ const creds = await login(page)+ await gotoIndex(page, PRODUCTS_PATH(creds.store_id), CTA)++ await selectRow(page, FIXTURE_BULK_PRODUCT_M)+ await selectRow(page, FIXTURE_BULK_PRODUCT_N)+ await expect(page.getByText(/^2 selected$/)).toBeVisible()++ await clickBulkAction(page, /remove from sales channels/i)+ await expect(page.getByRole('heading', { name: /^remove from sales channels$/i })).toBeVisible()++ await page+ .getByRole('dialog')+ .getByPlaceholder(/search sales channels/i)+ .fill(FIXTURE_BULK_CHANNEL_NAME)+ await page+ .getByRole('option', { name: new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i') })+ .first()+ .click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^remove$/i })+ .click()++ await expect(page.getByText(/unlisted 2 products from sales channels/i)).toBeVisible({+ timeout: 15_000,+ })+ })+})diff --git a/packages/dashboard/e2e/global-setup.ts b/packages/dashboard/e2e/global-setup.tsindex e17046a998..e49972d279 100644--- a/packages/dashboard/e2e/global-setup.ts+++ b/packages/dashboard/e2e/global-setup.ts@@ -3,6 +3,8 @@ import { unlinkSync, writeFileSync } from 'node:fs'import { resolve } from 'node:path'import {FIXTURE_BULK_CATEGORY,+ FIXTURE_BULK_CHANNEL_CODE,+ FIXTURE_BULK_CHANNEL_NAME,FIXTURE_BULK_PRODUCT_A,FIXTURE_BULK_PRODUCT_B,FIXTURE_BULK_PRODUCT_C,@@ -13,6 +15,10 @@ import {FIXTURE_BULK_PRODUCT_H,FIXTURE_BULK_PRODUCT_I,FIXTURE_BULK_PRODUCT_J,+ FIXTURE_BULK_PRODUCT_K,+ FIXTURE_BULK_PRODUCT_L,+ FIXTURE_BULK_PRODUCT_M,+ FIXTURE_BULK_PRODUCT_N,FIXTURE_PROMO_CUSTOMER_EMAIL,FIXTURE_PROMO_CUSTOMER_FIRST_NAME,FIXTURE_PROMO_CUSTOMER_FULL_NAME,@@ -66,6 +72,16 @@ const BOOTSTRAP_RUBY = [`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_H}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_I}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_J}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,+ `Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_K}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,+ `Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_L}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,+ `Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_M}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,+ `Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_N}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,+ // Second channel beyond the seeded default; the channels bulk-action+ // and filter specs need a non-default channel to add/remove against.+ `bulk_channel = s.channels.where(code: '${FIXTURE_BULK_CHANNEL_CODE}').first_or_create!(name: '${FIXTURE_BULK_CHANNEL_NAME}')`,+ // Pre-list M/N on the bulk channel so the remove-from-channels test+ // has something to undo.+ `bulk_channel.add_products([Spree::Product.find_by(name: '${FIXTURE_BULK_PRODUCT_M}').id, Spree::Product.find_by(name: '${FIXTURE_BULK_PRODUCT_N}').id])`,// Category used by the bulk-add-to-categories test. Sits in the same// `Categories` taxonomy as the promo taxon above.`taxonomy.taxons.where(name: '${FIXTURE_BULK_CATEGORY}').first_or_create!(parent: taxonomy.root)`,diff --git a/packages/dashboard/e2e/helpers.ts b/packages/dashboard/e2e/helpers.tsindex 6a400dd274..100658f81f 100644--- a/packages/dashboard/e2e/helpers.ts+++ b/packages/dashboard/e2e/helpers.ts@@ -23,9 +23,21 @@ export const FIXTURE_BULK_PRODUCT_G = 'E2E Bulk Product G'export const FIXTURE_BULK_PRODUCT_H = 'E2E Bulk Product H'export const FIXTURE_BULK_PRODUCT_I = 'E2E Bulk Product I'export const FIXTURE_BULK_PRODUCT_J = 'E2E Bulk Product J'+// Disjoint pair for the bulk-add-to-channels test (K/L) and the+// bulk-remove-from-channels test (M/N). M/N are pre-listed on+// FIXTURE_BULK_CHANNEL by the seed so the remove flow has something+// to undo.+export const FIXTURE_BULK_PRODUCT_K = 'E2E Bulk Product K'+export const FIXTURE_BULK_PRODUCT_L = 'E2E Bulk Product L'+export const FIXTURE_BULK_PRODUCT_M = 'E2E Bulk Product M'+export const FIXTURE_BULK_PRODUCT_N = 'E2E Bulk Product N'// Dedicated category seeded for the bulk-add-to-categories test; lives under// the `Categories` taxonomy alongside `FIXTURE_PROMO_TAXON`.export const FIXTURE_BULK_CATEGORY = 'E2E Bulk Category'+// Second channel beyond the seeded default `online`. Used by the+// channels bulk-action and filter specs.+export const FIXTURE_BULK_CHANNEL_CODE = 'e2e-bulk'+export const FIXTURE_BULK_CHANNEL_NAME = 'E2E Bulk Channel'export const FIXTURE_PROMO_CUSTOMER_EMAIL = '[email protected]'export const FIXTURE_PROMO_CUSTOMER_FIRST_NAME = 'Promo'export const FIXTURE_PROMO_CUSTOMER_FULL_NAME = 'Promo Customer'@@ -89,6 +101,24 @@ export async function openRowMenu(page: Page, rowText: string) {.click()}+/**+ * Click a bulk action by name. The `<BulkActionBar>` measures available width+ * and pushes overflowing actions into a "More actions" dropdown — at the+ * Playwright viewport (1280px) most rows show 4–5 inline actions and the rest+ * live in overflow. This helper tries the inline button first and falls back+ * to opening the dropdown and selecting the menu item.+ */+export async function clickBulkAction(page: Page, name: RegExp) {+ const inline = page.getByRole('button', { name }).first()+ const visible = await inline.isVisible().catch(() => false)+ if (visible) {+ await inline.click()+ return+ }+ await page.getByRole('button', { name: /more actions/i }).click()+ await page.getByRole('menuitem', { name }).click()+}+/*** Locator for the `<ResourceNameCell>` button on a resource index table.* The cell's accessible name is `"<name> <secondary?>"` and a sibling icondiff --git a/packages/dashboard/e2e/products-bulk.spec.ts b/packages/dashboard/e2e/products-bulk.spec.tsindex 78df612474..502f201060 100644--- a/packages/dashboard/e2e/products-bulk.spec.ts+++ b/packages/dashboard/e2e/products-bulk.spec.ts@@ -1,5 +1,6 @@import { expect, type Page, test } from '@playwright/test'import {+ clickBulkAction,FIXTURE_BULK_CATEGORY,FIXTURE_BULK_PRODUCT_A,FIXTURE_BULK_PRODUCT_B,@@ -59,7 +60,7 @@ test.describe('products bulk operations', () => {await selectRow(page, FIXTURE_BULK_PRODUCT_B)await expect(page.getByText(/^2 selected$/)).toBeVisible()- await page.getByRole('button', { name: /set status/i }).click()+ await clickBulkAction(page, /set status/i)await expect(page.getByRole('heading', { name: /set product status/i })).toBeVisible()await page.getByRole('combobox').click()@@ -88,7 +89,7 @@ test.describe('products bulk operations', () => {await selectRow(page, FIXTURE_BULK_PRODUCT_D)await expect(page.getByText(/^2 selected$/)).toBeVisible()- await page.getByRole('button', { name: /add to categories/i }).click()+ await clickBulkAction(page, /add to categories/i)await expect(page.getByRole('heading', { name: /^add to categories$/i })).toBeVisible()// The category combobox is a chips-with-search picker. Type the seed@@ -127,7 +128,7 @@ test.describe('products bulk operations', () => {await selectRow(page, FIXTURE_BULK_PRODUCT_F)await expect(page.getByText(/^2 selected$/)).toBeVisible()- await page.getByRole('button', { name: /^add tags…$/i }).click()+ await clickBulkAction(page, /^add tags…$/i)await expect(page.getByRole('heading', { name: /^add tags$/i })).toBeVisible()// TagCombobox: type the new tag, press Enter to confirm it as a chip.@@ -155,7 +156,7 @@ test.describe('products bulk operations', () => {// The Delete bulk action confirms via the shared confirm dialog (NOT the// form-based BulkDialog) — the confirm dialog uses role="alertdialog" or// role="dialog" with the heading "Delete {n} products?".- await page.getByRole('button', { name: /^delete$/i }).click()+ await clickBulkAction(page, /^delete$/i)await expect(page.getByRole('heading', { name: /delete 2 products\?/i })).toBeVisible()await page.getByRole('dialog')diff --git a/packages/dashboard/e2e/products-edit.spec.ts b/packages/dashboard/e2e/products-edit.spec.tsnew file mode 100644index 0000000000..40c1d9e949--- /dev/null+++ b/packages/dashboard/e2e/products-edit.spec.ts@@ -0,0 +1,105 @@+import { expect, type Locator, type Page, test } from '@playwright/test'+import { FIXTURE_BULK_CHANNEL_NAME, gotoIndex, login } from './helpers'++const PRODUCTS_PATH = (storeId: string) => `/${storeId}/products`+const ADD_CTA = /add product/i++/**+ * Drive the New Product form to create a fresh record and wait until the+ * router lands on the edit page.+ */+async function createProduct(page: Page, storeId: string, name: string, description?: string) {+ await gotoIndex(page, PRODUCTS_PATH(storeId), ADD_CTA)+ await page.getByRole('button', { name: ADD_CTA }).click()++ await expect(page.getByRole('heading', { name: /^new product$/i })).toBeVisible()+ await page.getByLabel(/^name$/i).fill(name)+ if (description) {+ await page.getByLabel(/^description$/i).fill(description)+ }+ await page.getByRole('button', { name: /^create product$/i }).click()++ // Lands on `/$storeId/products/$productId` (not `/new`).+ await expect(page).toHaveURL(new RegExp(`/${storeId}/products/prod_[^/]+$`), { timeout: 15_000 })+}++/**+ * Locator for the Publishing card on the edit page. `<CardTitle>` is a+ * `<div>` (not a heading), so we anchor on the `data-slot` shadcn emits.+ */+function publishingCard(page: Page): Locator {+ return page+ .locator('[data-slot="card"]')+ .filter({ has: page.locator('[data-slot="card-title"]', { hasText: /^Publishing$/ }) })+}++test.describe('product edit', () => {+ test('creates a product and lands on the edit page', async ({ page }) => {+ const creds = await login(page)+ const name = `E2E Product Create ${Date.now()}`++ await createProduct(page, creds.store_id, name, 'Initial description')++ // The Name input on the edit page mirrors the saved name.+ await expect(page.getByLabel(/^name$/i)).toHaveValue(name)+ })++ test('updates name on an existing product', async ({ page }) => {+ const creds = await login(page)+ const original = `E2E Product Update ${Date.now()}`+ const updated = `${original} (updated)`++ await createProduct(page, creds.store_id, original)++ await page.getByLabel(/^name$/i).fill(updated)+ await page.getByRole('button', { name: /save product/i }).click()++ // After a successful save the button disables again (RHF `isDirty`+ // resets via `reset(updatedValues)`). Asserting on disabled state avoids+ // coupling to toast strings, which aren't stable across i18n updates.+ await expect(page.getByRole('button', { name: /save product/i })).toBeDisabled({+ timeout: 15_000,+ })++ await page.reload()+ await expect(page.getByLabel(/^name$/i)).toHaveValue(updated)+ })++ test('lists a product on an additional channel via the publishing card', async ({ page }) => {+ const creds = await login(page)+ const name = `E2E Product Publish ${Date.now()}`++ await createProduct(page, creds.store_id, name)++ // New products auto-publish on the store's default channel ("Online+ // Store"), so the card is non-empty from the start. Assert the bulk+ // channel isn't there yet, then add it via Manage.+ const card = publishingCard(page)+ await expect(card.getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i'))).not.toBeVisible()++ await card.getByRole('button', { name: /^manage$/i }).click()+ await expect(page.getByRole('heading', { name: /^manage sales channels$/i })).toBeVisible()++ await page+ .getByRole('dialog')+ .getByRole('button', { name: new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i') })+ .click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^done$/i })+ .click()++ await expect(card.getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i'))).toBeVisible()++ await page.getByRole('button', { name: /save product/i }).click()+ await expect(page.getByRole('button', { name: /save product/i })).toBeDisabled({+ timeout: 15_000,+ })++ // After reload the publication is still attached.+ await page.reload()+ await expect(+ publishingCard(page).getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i')),+ ).toBeVisible()+ })+})diff --git a/packages/dashboard/src/components/spree/channel-select.tsx b/packages/dashboard/src/components/spree/channel-select.tsxnew file mode 100644index 0000000000..040772301b--- /dev/null+++ b/packages/dashboard/src/components/spree/channel-select.tsx@@ -0,0 +1,67 @@+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@spree/dashboard-ui'+import { useTranslation } from 'react-i18next'+import { useChannels } from '@/hooks/use-channels'++interface ChannelSelectProps {+ /** ID for the trigger — paired with the parent `<FieldLabel htmlFor>`. */+ id?: string+ /** Submit name — a hidden input mirrors the value so plain `FormData` works. */+ name?: string+ /** Controlled value. Pair with `onChange` to lift state out. */+ value?: string+ /** Fires on every selection change. */+ onChange?: (channelId: string) => void+ /** Placeholder shown when no channel is selected. */+ placeholder?: string+ disabled?: boolean+}++/**+ * Picker for one of the current store's channels. Mirrors `<CurrencySelect>`:+ * cached at the hook layer (5-min stale time via `useChannels`), shared across+ * forms, with the same `CODE — Name` rendering pattern in the trigger so the+ * selected value reads identically whether the dropdown is open or closed.+ * Use anywhere the merchant attributes an admin-side action to a sales+ * channel (manual orders, exports, scoped reports).+ */+export function ChannelSelect({+ id,+ name,+ value,+ onChange,+ placeholder,+ disabled,+}: ChannelSelectProps) {+ const { t } = useTranslation()+ const { data } = useChannels()+ const channels = data?.data ?? []++ return (+ <>+ {name && <input type="hidden" name={name} value={value ?? ''} />}+ <Select value={value ?? ''} onValueChange={(v) => onChange?.(v)} disabled={disabled}>+ <SelectTrigger id={id}>+ {/* Base UI's `<SelectValue>` defaults to rendering the raw `value`+ (the prefixed ID). Use the children render-prop to look up the+ name from our cached list so the trigger matches the items. */}+ <SelectValue+ placeholder={placeholder ?? t('admin.components.channel_select.placeholder')}+ >+ {(v) =>+ channels.find((c) => c.id === v)?.name ??+ placeholder ??+ t('admin.components.channel_select.placeholder')+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {channels.map((c) => (+ <SelectItem key={c.id} value={c.id}>+ {c.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </>+ )+}diff --git a/packages/dashboard/src/components/spree/products/publishing-card.tsx b/packages/dashboard/src/components/spree/products/publishing-card.tsxnew file mode 100644index 0000000000..398e27a6aa--- /dev/null+++ b/packages/dashboard/src/components/spree/products/publishing-card.tsx@@ -0,0 +1,338 @@+import type { Channel } from '@spree/admin-sdk'+import { formatStoreDateTime, StoreDatePicker, useStore } from '@spree/dashboard-core'+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ Checkbox,+ Field,+ FieldLabel,+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+ Skeleton,+} from '@spree/dashboard-ui'+import { parseISO } from 'date-fns'+import { PencilIcon, SettingsIcon } from 'lucide-react'+import { useMemo, useState } from 'react'+import { Controller, type UseFormReturn, useFieldArray } from 'react-hook-form'+import { useTranslation } from 'react-i18next'+import { useChannels } from '@/hooks/use-channels'+import type { ProductFormValues } from '@/schemas/product'++type ProductForm = UseFormReturn<ProductFormValues>++// `not_available` short-circuits when the product status (Draft/Archived) blocks+// customer visibility, even if the per-channel publication window is open. Matches+// Shopify's behavior: the product status is the outer gate; per-channel scheduling+// only matters once status is Active.+type ScheduleStatus = 'live' | 'scheduled' | 'hidden' | 'not_available'++function scheduleStatus(+ productStatus: ProductFormValues['status'] | undefined,+ publishedAt?: string | null,+ unpublishedAt?: string | null,+): ScheduleStatus {+ if (productStatus !== 'active') return 'not_available'+ const now = Date.now()+ if (unpublishedAt && parseISO(unpublishedAt).getTime() <= now) return 'hidden'+ if (publishedAt && parseISO(publishedAt).getTime() > now) return 'scheduled'+ return 'live'+}++export function PublishingCard({ form }: { form: ProductForm }) {+ const { t } = useTranslation()+ const [manageOpen, setManageOpen] = useState(false)+ const [editingIndex, setEditingIndex] = useState<number | null>(null)+ const { data: channelsResponse } = useChannels()+ const channelsById = useMemo(+ () => new Map((channelsResponse?.data ?? []).map((c) => [c.id, c])),+ [channelsResponse?.data],+ )+ const publicationsArray = useFieldArray({+ control: form.control,+ name: 'product_publications',+ keyName: '_key',+ })++ const channelName = (id: string) => channelsById.get(id)?.name ?? channelsById.get(id)?.code ?? id++ return (+ <Card>+ <CardHeader className="flex flex-row items-center justify-between gap-2">+ <CardTitle>{t('admin.pages.products.publishing.title')}</CardTitle>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => setManageOpen(true)}+ aria-label={t('admin.pages.products.publishing.manage_cta')}+ >+ <SettingsIcon className="size-4" />+ {t('admin.pages.products.publishing.manage_cta')}+ </Button>+ </CardHeader>+ <CardContent className="flex flex-col gap-1">+ {publicationsArray.fields.length === 0 && (+ <p className="text-sm text-muted-foreground">+ {t('admin.pages.products.publishing.empty')}+ </p>+ )}+ {publicationsArray.fields.map((row, index) =>+ editingIndex === index ? (+ <PublicationEditor+ key={row._key}+ form={form}+ index={index}+ channelName={channelName(row.channel_id)}+ onDone={() => setEditingIndex(null)}+ />+ ) : (+ <PublicationRow+ key={row._key}+ form={form}+ index={index}+ channelName={channelName(row.channel_id)}+ onEdit={() => setEditingIndex(index)}+ />+ ),+ )}+ </CardContent>+ <ManageChannelsSheet+ open={manageOpen}+ onOpenChange={setManageOpen}+ publicationsArray={publicationsArray}+ />+ </Card>+ )+}++function StatusDot({ status }: { status: ScheduleStatus }) {+ const cls =+ status === 'live'+ ? 'bg-emerald-500'+ : status === 'scheduled'+ ? 'bg-amber-500'+ : 'bg-muted-foreground'+ return <span className={`inline-block size-2 rounded-full ${cls}`} aria-hidden />+}++function PublicationRow({+ form,+ index,+ channelName,+ onEdit,+}: {+ form: ProductForm+ index: number+ channelName: string+ onEdit: () => void+}) {+ const { t } = useTranslation()+ const { timezone } = useStore()+ const [productStatus, publishedAt, unpublishedAt] = form.watch([+ 'status',+ `product_publications.${index}.published_at`,+ `product_publications.${index}.unpublished_at`,+ ])+ const status = scheduleStatus(productStatus, publishedAt, unpublishedAt)++ const caption = (() => {+ const start = publishedAt ? formatStoreDateTime(publishedAt, timezone) : null+ const end = unpublishedAt ? formatStoreDateTime(unpublishedAt, timezone) : null+ if (status === 'not_available') {+ const productStatusLabel = t(+ `admin.pages.products.status_options.${productStatus ?? 'draft'}`,+ )+ return t('admin.pages.products.publishing.caption_not_available', {+ product_status: productStatusLabel,+ })+ }+ if (status === 'hidden') {+ return t('admin.pages.products.publishing.caption_unpublished', { date: end })+ }+ if (status === 'scheduled') {+ return end+ ? t('admin.pages.products.publishing.caption_window', { start, end })+ : t('admin.pages.products.publishing.caption_scheduled', { date: start })+ }+ // live+ if (end) return t('admin.pages.products.publishing.caption_hidden_after', { date: end })+ return t('admin.pages.products.publishing.caption_live')+ })()++ return (+ <button+ type="button"+ onClick={onEdit}+ className="group flex w-full items-start justify-between gap-3 rounded-md px-2 py-2 text-left hover:bg-muted/40"+ >+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <div className="flex items-center gap-2">+ <span className="truncate text-sm font-medium">{channelName}</span>+ <span className="flex items-center gap-1 text-xs text-muted-foreground">+ <StatusDot status={status} />+ {t(`admin.pages.products.publishing.status_${status}`)}+ </span>+ </div>+ <span className="text-xs text-muted-foreground">{caption}</span>+ </div>+ <PencilIcon className="mt-0.5 size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />+ </button>+ )+}++function PublicationEditor({+ form,+ index,+ channelName,+ onDone,+}: {+ form: ProductForm+ index: number+ channelName: string+ onDone: () => void+}) {+ const { t } = useTranslation()+ const publishedAtPath = `product_publications.${index}.published_at` as const+ const unpublishedAtPath = `product_publications.${index}.unpublished_at` as const++ return (+ <div className="flex flex-col gap-3 rounded-md border border-border bg-muted/20 px-3 py-3">+ <div className="flex items-center justify-between">+ <span className="text-sm font-medium">{channelName}</span>+ <Button type="button" variant="ghost" size="sm" className="h-7 text-xs" onClick={onDone}>+ {t('admin.actions.done')}+ </Button>+ </div>++ <Field>+ <FieldLabel>{t('admin.fields.product_publication.published_at.label')}</FieldLabel>+ <Controller+ control={form.control}+ name={publishedAtPath}+ render={({ field }) => (+ <StoreDatePicker+ value={field.value ?? null}+ onChange={(next) => field.onChange(next ?? null)}+ placeholder={t('admin.fields.product_publication.published_at.placeholder')}+ includeTime+ inline+ />+ )}+ />+ <span className="text-xs text-muted-foreground">+ {t('admin.fields.product_publication.published_at.help')}+ </span>+ </Field>++ <Field>+ <FieldLabel>{t('admin.fields.product_publication.unpublished_at.label')}</FieldLabel>+ <Controller+ control={form.control}+ name={unpublishedAtPath}+ render={({ field }) => (+ <StoreDatePicker+ value={field.value ?? null}+ onChange={(next) => field.onChange(next ?? null)}+ placeholder={t('admin.fields.product_publication.unpublished_at.placeholder')}+ includeTime+ inline+ />+ )}+ />+ <span className="text-xs text-muted-foreground">+ {t('admin.fields.product_publication.unpublished_at.help')}+ </span>+ </Field>+ </div>+ )+}++function ManageChannelsSheet({+ open,+ onOpenChange,+ publicationsArray,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+ publicationsArray: ReturnType<+ typeof useFieldArray<ProductFormValues, 'product_publications', '_key'>+ >+}) {+ const { t } = useTranslation()+ const { data: channelsResponse, isLoading } = useChannels()+ const channels = channelsResponse?.data ?? []++ const toggle = (channel: Channel, checked: boolean) => {+ const existingIndex = publicationsArray.fields.findIndex((f) => f.channel_id === channel.id)+ if (checked && existingIndex === -1) {+ publicationsArray.append({+ channel_id: channel.id,+ published_at: null,+ unpublished_at: null,+ })+ } else if (!checked && existingIndex !== -1) {+ publicationsArray.remove(existingIndex)+ }+ }++ return (+ <Sheet open={open} onOpenChange={onOpenChange}>+ <SheetContent>+ <SheetHeader>+ <SheetTitle>{t('admin.pages.products.publishing.manage_title')}</SheetTitle>+ <SheetDescription>+ {t('admin.pages.products.publishing.manage_description')}+ </SheetDescription>+ </SheetHeader>+ <div className="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-4">+ {isLoading && (+ <>+ <Skeleton className="h-9 w-full" />+ <Skeleton className="h-9 w-full" />+ <Skeleton className="h-9 w-full" />+ </>+ )}+ {!isLoading && channels.length === 0 && (+ <p className="text-sm text-muted-foreground">+ {t('admin.pages.products.publishing.no_channels')}+ </p>+ )}+ {!isLoading &&+ channels.map((channel) => {+ const checked = publicationsArray.fields.some((f) => f.channel_id === channel.id)+ return (+ <button+ key={channel.id}+ type="button"+ onClick={() => toggle(channel, !checked)}+ className="flex w-full cursor-pointer items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-left hover:bg-muted/40"+ >+ <Checkbox checked={checked} tabIndex={-1} />+ <span className="flex-1 text-sm">+ {channel.name ?? channel.code ?? channel.id}+ </span>+ {!channel.active && (+ <span className="text-xs text-muted-foreground">+ {t('admin.pages.products.publishing.inactive_marker')}+ </span>+ )}+ </button>+ )+ })}+ </div>+ <SheetFooter>+ <Button type="button" size="sm" onClick={() => onOpenChange(false)}>+ {t('admin.actions.done')}+ </Button>+ </SheetFooter>+ </SheetContent>+ </Sheet>+ )+}diff --git a/packages/dashboard/src/hooks/use-channels.ts b/packages/dashboard/src/hooks/use-channels.tsnew file mode 100644index 0000000000..00f6c01121--- /dev/null+++ b/packages/dashboard/src/hooks/use-channels.ts@@ -0,0 +1,86 @@+import type { Channel, ChannelCreateParams, ChannelUpdateParams } from '@spree/admin-sdk'+import { adminClient, useResourceMutation, useStore } from '@spree/dashboard-core'+import { useQuery, useQueryClient } from '@tanstack/react-query'+import i18n from 'i18next'++// Channels are store-scoped on the backend (`for_store(current_store)`), so+// query keys MUST include the storeId — otherwise switching stores within+// the staleTime window serves the previous store's channels. The hooks read+// storeId from <StoreProvider> at call time.+export function channelsQueryKey(storeId: string) {+ return ['channels', storeId] as const+}++export function channelQueryKey(storeId: string, id: string) {+ return ['channels', storeId, id] as const+}++interface UseChannelsParams {+ page?: number+ limit?: number+ expand?: string[]+}++export function useChannels({ page = 1, limit = 100, expand }: UseChannelsParams = {}) {+ const { storeId } = useStore()+ return useQuery({+ queryKey: [...channelsQueryKey(storeId), { page, limit, expand: expand?.join(',') ?? '' }],+ queryFn: () => adminClient.channels.list({ page, limit, ...(expand ? { expand } : {}) }),+ staleTime: 1000 * 60 * 5,+ })+}++export function useChannel(id: string | undefined) {+ const { storeId } = useStore()+ return useQuery({+ queryKey: id ? channelQueryKey(storeId, id) : ['channels', storeId, 'noop'],+ queryFn: () => adminClient.channels.get(id as string),+ enabled: !!id,+ })+}++export function useCreateChannel() {+ const { storeId } = useStore()+ return useResourceMutation<Channel, Error, ChannelCreateParams>({+ mutationFn: (params) => adminClient.channels.create(params),+ invalidate: [channelsQueryKey(storeId)],+ successMessage: 'Channel created',+ errorMessage: 'Failed to create channel',+ })+}++export function useUpdateChannel(id: string) {+ const { storeId } = useStore()+ return useResourceMutation<Channel, Error, ChannelUpdateParams>({+ mutationFn: (params) => adminClient.channels.update(id, params),+ invalidate: [channelsQueryKey(storeId), channelQueryKey(storeId, id)],+ successMessage: 'Channel updated',+ errorMessage: 'Failed to update channel',+ })+}++export function useDeleteChannel() {+ const queryClient = useQueryClient()+ const { storeId } = useStore()++ return useResourceMutation<void, Error, string>({+ mutationFn: (id) => adminClient.channels.delete(id),+ invalidate: [channelsQueryKey(storeId)],+ successMessage: 'Channel deleted',+ errorMessage: 'Failed to delete channel',+ onSuccess: (_data, id) => {+ queryClient.removeQueries({ queryKey: channelQueryKey(storeId, id) })+ },+ })+}++export function channelAutocompleteProps(queryKey: string) {+ return {+ queryKey,+ search: (q: string) => adminClient.channels.list({ name_cont: q, limit: 20, sort: 'name' }),+ hydrate: (ids: string[]) => adminClient.channels.list({ id_in: ids, limit: ids.length }),+ getOptionLabel: (c: Channel) => c.name ?? c.code ?? c.id,+ placeholder: i18n.t('admin.pages.channels.search_placeholder'),+ emptyText: i18n.t('admin.pages.channels.no_channels_found'),+ }+}diff --git a/packages/dashboard/src/hooks/use-product.ts b/packages/dashboard/src/hooks/use-product.tsindex cff6941dd5..b5b843ff99 100644--- a/packages/dashboard/src/hooks/use-product.ts+++ b/packages/dashboard/src/hooks/use-product.ts@@ -1,3 +1,4 @@+import type { ProductCreateParams, ProductUpdateParams } from '@spree/admin-sdk'import { adminClient } from '@spree/dashboard-core'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'@@ -18,17 +19,30 @@ export function useProduct(id: string) {'option_types','categories','tax_category',+ 'product_publications',+ 'channels',],}),enabled: !!id,})}+export function useCreateProduct() {+ const queryClient = useQueryClient()++ return useMutation({+ mutationFn: (params: ProductCreateParams) => adminClient.products.create(params),+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: ['products'] })+ },+ })+}+export function useUpdateProduct() {const queryClient = useQueryClient()return useMutation({- mutationFn: ({ id, ...params }: { id: string } & Record<string, unknown>) =>+ mutationFn: ({ id, ...params }: { id: string } & ProductUpdateParams) =>adminClient.products.update(id, params),onSuccess: (_data, variables) => {queryClient.invalidateQueries({ queryKey: ['products', variables.id] })diff --git a/packages/dashboard/src/hooks/use-products.ts b/packages/dashboard/src/hooks/use-products.tsindex aa0d206dbf..f48912e56d 100644--- a/packages/dashboard/src/hooks/use-products.ts+++ b/packages/dashboard/src/hooks/use-products.ts@@ -45,6 +45,7 @@ export function useProducts({type BulkStatusParams = Parameters<typeof adminClient.products.bulkStatusUpdate>[0]type BulkCategoriesParams = Parameters<typeof adminClient.products.bulkAddToCategories>[0]+type BulkChannelsParams = Parameters<typeof adminClient.products.bulkAddToChannels>[0]type BulkTagsParams = Parameters<typeof adminClient.products.bulkAddTags>[0]type BulkDestroyParams = Parameters<typeof adminClient.products.bulkDestroy>[0]@@ -74,6 +75,18 @@ export function useBulkRemoveProductsFromCategories() {)}+export function useBulkAddProductsToChannels() {+ return useBulkProductMutation((p: BulkChannelsParams) =>+ adminClient.products.bulkAddToChannels(p),+ )+}++export function useBulkRemoveProductsFromChannels() {+ return useBulkProductMutation((p: BulkChannelsParams) =>+ adminClient.products.bulkRemoveFromChannels(p),+ )+}+export function useBulkAddProductTags() {return useBulkProductMutation((p: BulkTagsParams) => adminClient.products.bulkAddTags(p))}diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex d48123b877..46c3fc3fb8 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -181,6 +181,18 @@"help": "Bare scheme + host (+ optional port). No path, query, or fragment."}},+ "channel": {+ "name": { "placeholder": "e.g. POS, Wholesale, Meta Shop" },+ "code": {+ "label": "Code",+ "placeholder": "e.g. pos",+ "help": "Stable identifier used by API clients via the X-Spree-Channel header and for order attribution. Lowercase letters, numbers, hyphens, underscores."+ },+ "active": {+ "label": "Active",+ "help": "Inactive sales channels stop accepting orders and aren't matched by the X-Spree-Channel header."+ }+ },"invitation_acceptance": {"password": {"label": "Password"@@ -403,9 +415,11 @@},"product": {"name": {+ "label": "Name","placeholder": "Product name"},"description": {+ "label": "Description","placeholder": "Write a product description…"},"make_active_at": {@@ -420,10 +434,25 @@"category_ids": {"label": "Categories"},+ "channels": {+ "label": "Sales channels"+ },"tags": {"label": "Tags"}},+ "product_publication": {+ "published_at": {+ "label": "Publish from",+ "placeholder": "Live immediately",+ "help": "Leave empty to go live immediately."+ },+ "unpublished_at": {+ "label": "Unpublish on",+ "placeholder": "Never",+ "help": "Leave empty to keep listed indefinitely."+ }+ },"gift_card": {"code": {"label": "Code",@@ -491,6 +520,17 @@"coupon_code": {"label": "Coupon code","placeholder": "Optional"+ },+ "channel": {+ "label": "Sales channel",+ "placeholder": "Use store default",+ "help": "Attribute the order to a specific sales channel. Defaults to the store's online channel."+ }+ },+ "media": {+ "alt": {+ "label": "Alt text",+ "placeholder": "Describe the image for accessibility and SEO"}}},@@ -617,6 +657,20 @@"removed": "Removed from staff"}},+ "channels": {+ "add_cta": "New sales channel",+ "add_sheet_title": "Add sales channel",+ "edit_sheet_title": "Edit sales channel",+ "create_label": "Create sales channel",+ "create_description": "Sales channels group orders and product listings — \"online\", \"pos\", a marketplace integration, etc.",+ "edit_description": "Rename a sales channel or pause it. Inactive sales channels stop accepting orders.",+ "delete_confirm": {+ "title": "Delete sales channel?",+ "message": "{{name}} will be removed. Products and orders attached to it will lose their sales-channel reference."+ },+ "search_placeholder": "Search sales channels…",+ "no_channels_found": "No sales channels found"+ },"customers": {"new_cta": "New Customer","create_label": "Create customer",@@ -678,7 +732,7 @@"market": "Market","locale": "Locale","currency": "Currency",- "channel": "Channel",+ "channel": "Sales channel","ip_address": "IP address"},"empty_payments": "No payments yet.",@@ -702,6 +756,13 @@}},"products": {+ "add_cta": "Add product",+ "new": {+ "title": "New product",+ "description": "Start with a name. Pricing, media, and sales channels can be added on the next screen.",+ "save_label": "Create product",+ "create_failed": "Failed to create product"+ },"edit": {"bulk_prices": {"dialog_title": "Edit prices — {{name}}"@@ -717,6 +778,25 @@"section_variants": "Variants","section_status": "Status","section_custom_fields": "Custom fields",+ "publishing": {+ "title": "Publishing",+ "manage_cta": "Manage",+ "manage_title": "Manage sales channels",+ "manage_description": "Pick which sales channels list this product. Toggle a channel off to unlist it everywhere.",+ "empty": "Not listed on any sales channel yet.",+ "no_channels": "No sales channels available. Create one in Settings → Sales channels.",+ "inactive_marker": "Inactive",+ "status_live": "Live",+ "status_scheduled": "Scheduled",+ "status_hidden": "Hidden",+ "status_not_available": "Not available",+ "caption_live": "Visible to customers now",+ "caption_scheduled": "Goes live {{date}}",+ "caption_hidden_after": "Comes down {{date}}",+ "caption_unpublished": "Was hidden on {{date}}",+ "caption_window": "Live {{start}} → {{end}}",+ "caption_not_available": "Hidden — product is {{product_status}}"+ },"clone_succeeded": "Product duplicated","clone_failed": "Failed to duplicate product","delete_succeeded": "Product deleted",@@ -725,6 +805,8 @@"set_status_action": "Set status…","add_categories_action": "Add to categories…","remove_categories_action": "Remove from categories…",+ "add_channels_action": "Add to sales channels…",+ "remove_channels_action": "Remove from sales channels…","add_tags_action": "Add tags…","remove_tags_action": "Remove tags…","delete_action": "Delete",@@ -734,6 +816,10 @@"categories_add_description": "Pick the categories to add these products to.","categories_remove_title": "Remove from categories","categories_remove_description": "Pick the categories to remove these products from.",+ "channels_add_title": "Add to sales channels",+ "channels_add_description": "Pick the sales channels to list these products on.",+ "channels_remove_title": "Remove from sales channels",+ "channels_remove_description": "Pick the sales channels to unlist these products from.","tags_add_title": "Add tags","tags_add_description": "Pick or create tags to add to these products.","tags_remove_title": "Remove tags",@@ -748,6 +834,10 @@"categories_add_failed": "Failed to add products to categories","categories_removed": "Removed {n} products from categories","categories_remove_failed": "Failed to remove products from categories",+ "channels_added": "Listed {n} products on sales channels",+ "channels_add_failed": "Failed to list products on sales channels",+ "channels_removed": "Unlisted {n} products from sales channels",+ "channels_remove_failed": "Failed to unlist products from sales channels","tags_added": "Added tags to {n} products","tags_add_failed": "Failed to add tags","tags_removed": "Removed tags from {n} products",diff --git a/packages/dashboard/src/nav/settings.ts b/packages/dashboard/src/nav/settings.tsindex 88bd2e1bfd..a5e8c132dc 100644--- a/packages/dashboard/src/nav/settings.ts+++ b/packages/dashboard/src/nav/settings.ts@@ -5,6 +5,7 @@ import {GlobeLockIcon,KeyRoundIcon,PercentIcon,+ RadioTowerIcon,StoreIcon,TagIcon,UsersRoundIcon,@@ -26,6 +27,16 @@ settingsNav.add({subject: Subject.Store,})+settingsNav.add({+ key: 'settings.channels',+ label: 'Sales channels',+ path: '/channels',+ icon: RadioTowerIcon,+ group: 'store',+ position: 150,+ subject: Subject.Channel,+})+settingsNav.add({key: 'settings.payment-methods',label: 'Payment methods',diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.tsindex 7ac6c73ee5..dd329d3b16 100644--- a/packages/dashboard/src/routeTree.gen.ts+++ b/packages/dashboard/src/routeTree.gen.ts@@ -28,6 +28,7 @@ import { Route as AuthenticatedStoreIdSettingsStaffRouteImport } from './routes/import { Route as AuthenticatedStoreIdSettingsPaymentMethodsRouteImport } from './routes/_authenticated/$storeId/settings/payment-methods'import { Route as AuthenticatedStoreIdSettingsMarketsRouteImport } from './routes/_authenticated/$storeId/settings/markets'import { Route as AuthenticatedStoreIdSettingsCustomFieldDefinitionsRouteImport } from './routes/_authenticated/$storeId/settings/custom-field-definitions'+import { Route as AuthenticatedStoreIdSettingsChannelsRouteImport } from './routes/_authenticated/$storeId/settings/channels'import { Route as AuthenticatedStoreIdSettingsApiKeysRouteImport } from './routes/_authenticated/$storeId/settings/api-keys'import { Route as AuthenticatedStoreIdSettingsAllowedOriginsRouteImport } from './routes/_authenticated/$storeId/settings/allowed-origins'import { Route as AuthenticatedStoreIdPromotionsNewRouteImport } from './routes/_authenticated/$storeId/promotions/new'@@ -35,6 +36,7 @@ import { Route as AuthenticatedStoreIdPromotionsGiftCardsRouteImport } from './rimport { Route as AuthenticatedStoreIdPromotionsPromotionIdRouteImport } from './routes/_authenticated/$storeId/promotions/$promotionId'import { Route as AuthenticatedStoreIdProductsTransfersRouteImport } from './routes/_authenticated/$storeId/products/transfers'import { Route as AuthenticatedStoreIdProductsOptionsRouteImport } from './routes/_authenticated/$storeId/products/options'+import { Route as AuthenticatedStoreIdProductsNewRouteImport } from './routes/_authenticated/$storeId/products/new'import { Route as AuthenticatedStoreIdProductsProductIdRouteImport } from './routes/_authenticated/$storeId/products/$productId'import { Route as AuthenticatedStoreIdOrdersNewRouteImport } from './routes/_authenticated/$storeId/orders/new'import { Route as AuthenticatedStoreIdOrdersDraftsRouteImport } from './routes/_authenticated/$storeId/orders/drafts'@@ -154,6 +156,12 @@ const AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute =path: '/custom-field-definitions',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)+const AuthenticatedStoreIdSettingsChannelsRoute =+ AuthenticatedStoreIdSettingsChannelsRouteImport.update({+ id: '/channels',+ path: '/channels',+ getParentRoute: () => AuthenticatedStoreIdSettingsRoute,+ } as any)const AuthenticatedStoreIdSettingsApiKeysRoute =AuthenticatedStoreIdSettingsApiKeysRouteImport.update({id: '/api-keys',@@ -196,6 +204,12 @@ const AuthenticatedStoreIdProductsOptionsRoute =path: '/products/options',getParentRoute: () => AuthenticatedStoreIdRoute,} as any)+const AuthenticatedStoreIdProductsNewRoute =+ AuthenticatedStoreIdProductsNewRouteImport.update({+ id: '/products/new',+ path: '/products/new',+ getParentRoute: () => AuthenticatedStoreIdRoute,+ } as any)const AuthenticatedStoreIdProductsProductIdRoute =AuthenticatedStoreIdProductsProductIdRouteImport.update({id: '/products/$productId',@@ -264,6 +278,7 @@ export interface FileRoutesByFullPath {'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute+ '/$storeId/products/new': typeof AuthenticatedStoreIdProductsNewRoute'/$storeId/products/options': typeof AuthenticatedStoreIdProductsOptionsRoute'/$storeId/products/transfers': typeof AuthenticatedStoreIdProductsTransfersRoute'/$storeId/promotions/$promotionId': typeof AuthenticatedStoreIdPromotionsPromotionIdRoute@@ -271,6 +286,7 @@ export interface FileRoutesByFullPath {'/$storeId/promotions/new': typeof AuthenticatedStoreIdPromotionsNewRoute'/$storeId/settings/allowed-origins': typeof AuthenticatedStoreIdSettingsAllowedOriginsRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/$storeId/settings/channels': typeof AuthenticatedStoreIdSettingsChannelsRoute'/$storeId/settings/custom-field-definitions': typeof AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute'/$storeId/settings/markets': typeof AuthenticatedStoreIdSettingsMarketsRoute'/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute@@ -298,6 +314,7 @@ export interface FileRoutesByTo {'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute+ '/$storeId/products/new': typeof AuthenticatedStoreIdProductsNewRoute'/$storeId/products/options': typeof AuthenticatedStoreIdProductsOptionsRoute'/$storeId/products/transfers': typeof AuthenticatedStoreIdProductsTransfersRoute'/$storeId/promotions/$promotionId': typeof AuthenticatedStoreIdPromotionsPromotionIdRoute@@ -305,6 +322,7 @@ export interface FileRoutesByTo {'/$storeId/promotions/new': typeof AuthenticatedStoreIdPromotionsNewRoute'/$storeId/settings/allowed-origins': typeof AuthenticatedStoreIdSettingsAllowedOriginsRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/$storeId/settings/channels': typeof AuthenticatedStoreIdSettingsChannelsRoute'/$storeId/settings/custom-field-definitions': typeof AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute'/$storeId/settings/markets': typeof AuthenticatedStoreIdSettingsMarketsRoute'/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute@@ -336,6 +354,7 @@ export interface FileRoutesById {'/_authenticated/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/_authenticated/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/_authenticated/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute+ '/_authenticated/$storeId/products/new': typeof AuthenticatedStoreIdProductsNewRoute'/_authenticated/$storeId/products/options': typeof AuthenticatedStoreIdProductsOptionsRoute'/_authenticated/$storeId/products/transfers': typeof AuthenticatedStoreIdProductsTransfersRoute'/_authenticated/$storeId/promotions/$promotionId': typeof AuthenticatedStoreIdPromotionsPromotionIdRoute@@ -343,6 +362,7 @@ export interface FileRoutesById {'/_authenticated/$storeId/promotions/new': typeof AuthenticatedStoreIdPromotionsNewRoute'/_authenticated/$storeId/settings/allowed-origins': typeof AuthenticatedStoreIdSettingsAllowedOriginsRoute'/_authenticated/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/_authenticated/$storeId/settings/channels': typeof AuthenticatedStoreIdSettingsChannelsRoute'/_authenticated/$storeId/settings/custom-field-definitions': typeof AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute'/_authenticated/$storeId/settings/markets': typeof AuthenticatedStoreIdSettingsMarketsRoute'/_authenticated/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute@@ -374,6 +394,7 @@ export interface FileRouteTypes {| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'+ | '/$storeId/products/new'| '/$storeId/products/options'| '/$storeId/products/transfers'| '/$storeId/promotions/$promotionId'@@ -381,6 +402,7 @@ export interface FileRouteTypes {| '/$storeId/promotions/new'| '/$storeId/settings/allowed-origins'| '/$storeId/settings/api-keys'+ | '/$storeId/settings/channels'| '/$storeId/settings/custom-field-definitions'| '/$storeId/settings/markets'| '/$storeId/settings/payment-methods'@@ -408,6 +430,7 @@ export interface FileRouteTypes {| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'+ | '/$storeId/products/new'| '/$storeId/products/options'| '/$storeId/products/transfers'| '/$storeId/promotions/$promotionId'@@ -415,6 +438,7 @@ export interface FileRouteTypes {| '/$storeId/promotions/new'| '/$storeId/settings/allowed-origins'| '/$storeId/settings/api-keys'+ | '/$storeId/settings/channels'| '/$storeId/settings/custom-field-definitions'| '/$storeId/settings/markets'| '/$storeId/settings/payment-methods'@@ -445,6 +469,7 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/orders/drafts'| '/_authenticated/$storeId/orders/new'| '/_authenticated/$storeId/products/$productId'+ | '/_authenticated/$storeId/products/new'| '/_authenticated/$storeId/products/options'| '/_authenticated/$storeId/products/transfers'| '/_authenticated/$storeId/promotions/$promotionId'@@ -452,6 +477,7 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/promotions/new'| '/_authenticated/$storeId/settings/allowed-origins'| '/_authenticated/$storeId/settings/api-keys'+ | '/_authenticated/$storeId/settings/channels'| '/_authenticated/$storeId/settings/custom-field-definitions'| '/_authenticated/$storeId/settings/markets'| '/_authenticated/$storeId/settings/payment-methods'@@ -610,6 +636,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsCustomFieldDefinitionsRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}+ '/_authenticated/$storeId/settings/channels': {+ id: '/_authenticated/$storeId/settings/channels'+ path: '/channels'+ fullPath: '/$storeId/settings/channels'+ preLoaderRoute: typeof AuthenticatedStoreIdSettingsChannelsRouteImport+ parentRoute: typeof AuthenticatedStoreIdSettingsRoute+ }'/_authenticated/$storeId/settings/api-keys': {id: '/_authenticated/$storeId/settings/api-keys'path: '/api-keys'@@ -659,6 +692,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdProductsOptionsRouteImportparentRoute: typeof AuthenticatedStoreIdRoute}+ '/_authenticated/$storeId/products/new': {+ id: '/_authenticated/$storeId/products/new'+ path: '/products/new'+ fullPath: '/$storeId/products/new'+ preLoaderRoute: typeof AuthenticatedStoreIdProductsNewRouteImport+ parentRoute: typeof AuthenticatedStoreIdRoute+ }'/_authenticated/$storeId/products/$productId': {id: '/_authenticated/$storeId/products/$productId'path: '/products/$productId'@@ -728,6 +768,7 @@ declare module '@tanstack/react-router' {interface AuthenticatedStoreIdSettingsRouteChildren {AuthenticatedStoreIdSettingsAllowedOriginsRoute: typeof AuthenticatedStoreIdSettingsAllowedOriginsRouteAuthenticatedStoreIdSettingsApiKeysRoute: typeof AuthenticatedStoreIdSettingsApiKeysRoute+ AuthenticatedStoreIdSettingsChannelsRoute: typeof AuthenticatedStoreIdSettingsChannelsRouteAuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute: typeof AuthenticatedStoreIdSettingsCustomFieldDefinitionsRouteAuthenticatedStoreIdSettingsMarketsRoute: typeof AuthenticatedStoreIdSettingsMarketsRouteAuthenticatedStoreIdSettingsPaymentMethodsRoute: typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute@@ -744,6 +785,8 @@ const AuthenticatedStoreIdSettingsRouteChildren: AuthenticatedStoreIdSettingsRouAuthenticatedStoreIdSettingsAllowedOriginsRoute,AuthenticatedStoreIdSettingsApiKeysRoute:AuthenticatedStoreIdSettingsApiKeysRoute,+ AuthenticatedStoreIdSettingsChannelsRoute:+ AuthenticatedStoreIdSettingsChannelsRoute,AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute:AuthenticatedStoreIdSettingsCustomFieldDefinitionsRoute,AuthenticatedStoreIdSettingsMarketsRoute:@@ -776,6 +819,7 @@ interface AuthenticatedStoreIdRouteChildren {AuthenticatedStoreIdOrdersDraftsRoute: typeof AuthenticatedStoreIdOrdersDraftsRouteAuthenticatedStoreIdOrdersNewRoute: typeof AuthenticatedStoreIdOrdersNewRouteAuthenticatedStoreIdProductsProductIdRoute: typeof AuthenticatedStoreIdProductsProductIdRoute+ AuthenticatedStoreIdProductsNewRoute: typeof AuthenticatedStoreIdProductsNewRouteAuthenticatedStoreIdProductsOptionsRoute: typeof AuthenticatedStoreIdProductsOptionsRouteAuthenticatedStoreIdProductsTransfersRoute: typeof AuthenticatedStoreIdProductsTransfersRouteAuthenticatedStoreIdPromotionsPromotionIdRoute: typeof AuthenticatedStoreIdPromotionsPromotionIdRoute@@ -804,6 +848,7 @@ const AuthenticatedStoreIdRouteChildren: AuthenticatedStoreIdRouteChildren = {AuthenticatedStoreIdOrdersNewRoute: AuthenticatedStoreIdOrdersNewRoute,AuthenticatedStoreIdProductsProductIdRoute:AuthenticatedStoreIdProductsProductIdRoute,+ AuthenticatedStoreIdProductsNewRoute: AuthenticatedStoreIdProductsNewRoute,AuthenticatedStoreIdProductsOptionsRoute:AuthenticatedStoreIdProductsOptionsRoute,AuthenticatedStoreIdProductsTransfersRoute:diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsxindex e5e7d9a712..7d2e2d297c 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx@@ -28,6 +28,8 @@ import { TrashIcon } from 'lucide-react'import { useState } from 'react'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'+import { ChannelSelect } from '@/components/spree/channel-select'+import { useChannels } from '@/hooks/use-channels'import { customerAutocompleteProps } from '@/hooks/use-customers'import { NEW_ORDER_DEFAULTS, type NewOrderFormValues, newOrderFormSchema } from '@/schemas/order'@@ -68,6 +70,9 @@ function NewOrderPage() {})const variantResults = variantsData?.data ?? []+ const { data: channelsData } = useChannels()+ const channels = channelsData?.data ?? []+const createMutation = useMutation({mutationFn: (values: NewOrderFormValues) => {const payload: Record<string, unknown> = {@@ -82,6 +87,7 @@ function NewOrderPage() {if (values.internal_note) payload.internal_note = values.internal_noteif (values.customer_note) payload.customer_note = values.customer_noteif (values.coupon_code) payload.coupon_code = values.coupon_code+ if (values.channel_id) payload.channel_id = values.channel_idreturn adminClient.orders.create(payload)},onSuccess: (order) => {@@ -304,6 +310,28 @@ function NewOrderPage() {</CardContent></Card>+ {channels.length > 1 && (+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.fields.order.channel.label')}</CardTitle>+ </CardHeader>+ <CardContent>+ <FieldGroup>+ <Field>+ <ChannelSelect+ value={form.watch('channel_id') || ''}+ onChange={(v) => form.setValue('channel_id', v, { shouldDirty: true })}+ placeholder={t('admin.fields.order.channel.placeholder')}+ />+ <span className="text-xs text-muted-foreground">+ {t('admin.fields.order.channel.help')}+ </span>+ </Field>+ </FieldGroup>+ </CardContent>+ </Card>+ )}+<Card><CardHeader><CardTitle>{t('admin.orders.new.section_discount')}</CardTitle>diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsxindex 0d382a67b2..d0c9e2abc2 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx@@ -20,7 +20,6 @@ import {mapSpreeErrorsToForm,PageHeader,ResourceMultiAutocomplete,- StoreDatePicker,TagCombobox,useDirectUpload,} from '@spree/dashboard-core'@@ -60,7 +59,8 @@ import { BulkPriceEditorDialog } from '@/components/spree/bulk-price-editor/bulkimport { CustomFieldsCard } from '@/components/spree/custom-fields/custom-fields-card'import { InventorySection } from '@/components/spree/products/inventory-section'import { MediaEditSheet } from '@/components/spree/products/media-edit-sheet'-import { categoryAutocompleteProps } from '@/hooks/use-categories'+import { PublishingCard } from '@/components/spree/products/publishing-card'+import { categoryAutocompleteProps, useCategories } from '@/hooks/use-categories'import { useDeleteProduct, useProduct, useUpdateProduct } from '@/hooks/use-product'import {useCreateProductMedia,@@ -110,9 +110,6 @@ function productToFormValues(product: Product): ProductFormValues {name: product.name,description: product.description ?? '',status: (product.status as ProductFormValues['status']) ?? 'draft',- make_active_at: product.make_active_at ?? null,- available_on: product.available_on ?? null,- discontinue_on: product.discontinue_on ?? null,category_ids: product.categories?.map((t) => t.id) ?? [],tags: product.tags ?? [],tax_category_id: product.tax_category_id ?? null,@@ -120,6 +117,12 @@ function productToFormValues(product: Product): ProductFormValues {meta_description: product.meta_description ?? '',slug: product.slug ?? '',variants_inventory: inventorySource.map(variantInventoryFromVariant),+ product_publications: (product.product_publications ?? []).map((l) => ({+ id: l.id,+ channel_id: l.channel_id,+ published_at: l.published_at ?? null,+ unpublished_at: l.unpublished_at ?? null,+ })),}}@@ -270,6 +273,7 @@ function ProductForm({ product }: { product: Product }) {sidebar={<><StatusCard form={form} />+ <PublishingCard form={form} /><CategorizationCard form={form} /><TaxCard form={form} /><SEOCard form={form} product={product} />@@ -719,7 +723,6 @@ function SEOCard({ form, product }: FormCardProps & { product: Product }) {function StatusCard({ form }: FormCardProps) {const { t } = useTranslation()- const status = form.watch('status')return (<Card>@@ -735,7 +738,9 @@ function StatusCard({ form }: FormCardProps) {render={({ field }) => (<Select value={field.value} onValueChange={field.onChange}><SelectTrigger className="w-full">- <SelectValue />+ <SelectValue>+ {(v) => t(`admin.pages.products.status_options.${v as string}`)}+ </SelectValue></SelectTrigger><SelectContent><SelectItem value="draft">@@ -752,56 +757,6 @@ function StatusCard({ form }: FormCardProps) {)}/></Field>-- {status !== 'active' && (- <Field>- <FieldLabel>{t('admin.fields.product.make_active_at.label')}</FieldLabel>- <Controller- name="make_active_at"- control={form.control}- render={({ field }) => (- <StoreDatePicker- value={field.value}- onChange={field.onChange}- placeholder={t('admin.common.pick_date')}- includeTime- />- )}- />- </Field>- )}-- <Field>- <FieldLabel>{t('admin.fields.product.available_on.label')}</FieldLabel>- <Controller- name="available_on"- control={form.control}- render={({ field }) => (- <StoreDatePicker- value={field.value}- onChange={field.onChange}- placeholder={t('admin.common.pick_date')}- includeTime- />- )}- />- </Field>-- <Field>- <FieldLabel>{t('admin.fields.product.discontinue_on.label')}</FieldLabel>- <Controller- name="discontinue_on"- control={form.control}- render={({ field }) => (- <StoreDatePicker- value={field.value}- onChange={field.onChange}- placeholder={t('admin.common.pick_date')}- includeTime- />- )}- />- </Field></CardContent></Card>)@@ -813,6 +768,9 @@ function StatusCard({ form }: FormCardProps) {function CategorizationCard({ form }: FormCardProps) {const { t } = useTranslation()+ // Surface the store's categories on focus so editors don't have to type+ // to discover them. Cached by +useCategories+ (5-min stale time).+ const { data: categoriesData } = useCategories()return (<Card>@@ -828,6 +786,7 @@ function CategorizationCard({ form }: FormCardProps) {render={({ field }) => (<ResourceMultiAutocomplete{...categoryAutocompleteProps('product-edit-category-picker')}+ initialItems={categoriesData?.data}value={field.value ?? []}onChange={field.onChange}/>@@ -877,7 +836,12 @@ function TaxCard({ form }: FormCardProps) {render={({ field }) => (<Select value={field.value ?? ''} onValueChange={(v) => field.onChange(v || null)}><SelectTrigger className="w-full">- <SelectValue placeholder={t('admin.products.tax_category_placeholder')} />+ <SelectValue placeholder={t('admin.products.tax_category_placeholder')}>+ {(v) =>+ taxCategories.find((c) => c.id === v)?.name ??+ t('admin.products.tax_category_placeholder')+ }+ </SelectValue></SelectTrigger><SelectContent>{taxCategories.map((cat) => (diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsxindex 3da7045eab..79dfde28fb 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx@@ -28,6 +28,7 @@ import {FolderMinusIcon,FolderPlusIcon,PlusIcon,+ RadioTowerIcon,TagIcon,TagsIcon,Trash2Icon,@@ -35,14 +36,17 @@ import {import { useCallback, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { toast } from 'sonner'-import { categoryAutocompleteProps } from '@/hooks/use-categories'+import { categoryAutocompleteProps, useCategories } from '@/hooks/use-categories'+import { channelAutocompleteProps, useChannels } from '@/hooks/use-channels'import { useDeleteProduct } from '@/hooks/use-product'import {useBulkAddProductsToCategories,+ useBulkAddProductsToChannels,useBulkAddProductTags,useBulkDestroyProducts,useBulkProductStatusUpdate,useBulkRemoveProductsFromCategories,+ useBulkRemoveProductsFromChannels,useBulkRemoveProductTags,useCloneProduct,} from '@/hooks/use-products'@@ -56,16 +60,20 @@ export const Route = createFileRoute('/_authenticated/$storeId/products/')({type ProductStatus = 'draft' | 'active' | 'archived'type StatusFormValues = { status: ProductStatus }type CategoriesFormValues = { category_ids: string[] }+type ChannelsFormValues = { channel_ids: string[] }type TagsFormValues = { tags: string[] }function ProductsPage() {const { t } = useTranslation()const { storeId } = Route.useParams()const searchParams = Route.useSearch()+ const navigate = useNavigate()const bulkStatus = useBulkProductStatusUpdate()const bulkAddCategories = useBulkAddProductsToCategories()const bulkRemoveCategories = useBulkRemoveProductsFromCategories()+ const bulkAddChannels = useBulkAddProductsToChannels()+ const bulkRemoveChannels = useBulkRemoveProductsFromChannels()const bulkAddTags = useBulkAddProductTags()const bulkRemoveTags = useBulkRemoveProductTags()const bulkDestroy = useBulkDestroyProducts()@@ -125,6 +133,46 @@ function ProductsPage() {errorMessage: t('admin.pages.products.bulk.categories_remove_failed'),}+ const addChannels: BulkAction<ChannelsFormValues> = {+ key: 'add-to-channels',+ label: t('admin.pages.products.bulk.add_channels_action'),+ icon: <RadioTowerIcon className="size-4" />,+ subject: Subject.Product,+ form: (props) => (+ <ChannelPickerSheet+ {...props}+ title={t('admin.pages.products.bulk.channels_add_title')}+ description={t('admin.pages.products.bulk.channels_add_description')}+ submitLabel={t('admin.actions.add')}+ />+ ),+ run: ({ ids, formValues }) =>+ bulkAddChannels.mutateAsync({ ids, channel_ids: formValues!.channel_ids }),+ invalidate: [['channels']],+ successMessage: t('admin.pages.products.bulk.channels_added'),+ errorMessage: t('admin.pages.products.bulk.channels_add_failed'),+ }++ const removeChannels: BulkAction<ChannelsFormValues> = {+ key: 'remove-from-channels',+ label: t('admin.pages.products.bulk.remove_channels_action'),+ icon: <RadioTowerIcon className="size-4" />,+ subject: Subject.Product,+ form: (props) => (+ <ChannelPickerSheet+ {...props}+ title={t('admin.pages.products.bulk.channels_remove_title')}+ description={t('admin.pages.products.bulk.channels_remove_description')}+ submitLabel={t('admin.actions.remove')}+ />+ ),+ run: ({ ids, formValues }) =>+ bulkRemoveChannels.mutateAsync({ ids, channel_ids: formValues!.channel_ids }),+ invalidate: [['channels']],+ successMessage: t('admin.pages.products.bulk.channels_removed'),+ errorMessage: t('admin.pages.products.bulk.channels_remove_failed'),+ }+const addTags: BulkAction<TagsFormValues> = {key: 'add-tags',label: t('admin.pages.products.bulk.add_tags_action'),@@ -182,6 +230,8 @@ function ProductsPage() {statusAction,addCategories,removeCategories,+ addChannels,+ removeChannels,addTags,removeTags,deleteAction,@@ -191,6 +241,8 @@ function ProductsPage() {bulkStatus,bulkAddCategories,bulkRemoveCategories,+ bulkAddChannels,+ bulkRemoveChannels,bulkAddTags,bulkRemoveTags,bulkDestroy,@@ -206,15 +258,20 @@ function ProductsPage() {tableKey="products"queryKey="products"queryFn={(params) => adminClient.products.list(params)}+ defaultParams={{ expand: ['channels'] }}searchParams={searchParams}bulkActions={bulkActions}rowActions={renderRowActions}actions={(ctx) => (<><ExportButton type="Spree::Exports::Products" {...ctx} />- <Button size="sm" className="h-[2.125rem]">+ <Button+ size="sm"+ className="h-[2.125rem]"+ onClick={() => navigate({ to: '/$storeId/products/new', params: { storeId } })}+ ><PlusIcon className="size-4" />- Add Product+ {t('admin.pages.products.add_cta')}</Button></>)}@@ -333,6 +390,10 @@ function CategoryPickerSheet({}: BulkActionFormProps<CategoriesFormValues> & CopyProps) {const { t } = useTranslation()const [categoryIds, setCategoryIds] = useState<string[]>([])+ // Surface the store's categories on focus so the merchant doesn't have to+ // type to discover them. The list is small and already cached by+ // +useCategories+ (5-min stale time).+ const { data: categoriesData } = useCategories()return (<BulkDialog@@ -347,6 +408,7 @@ function CategoryPickerSheet({<FieldLabel>{t('admin.fields.product.category_ids.label')}</FieldLabel><ResourceMultiAutocomplete{...categoryAutocompleteProps('bulk-products-category-picker')}+ initialItems={categoriesData?.data}value={categoryIds}onChange={setCategoryIds}/>@@ -355,6 +417,41 @@ function CategoryPickerSheet({)}+function ChannelPickerSheet({+ onSubmit,+ onCancel,+ title,+ description,+ submitLabel,+}: BulkActionFormProps<ChannelsFormValues> & CopyProps) {+ const { t } = useTranslation()+ const [channelIds, setChannelIds] = useState<string[]>([])+ // Surface all channels on focus so the merchant doesn't have to type to+ // discover them. The list is small and already cached by +useChannels+.+ const { data: channelsData } = useChannels()++ return (+ <BulkDialog+ title={title}+ description={description}+ submitLabel={submitLabel}+ submitDisabled={channelIds.length === 0}+ onCancel={onCancel}+ onSubmit={() => onSubmit({ channel_ids: channelIds })}+ >+ <Field>+ <FieldLabel>{t('admin.fields.product.channels.label')}</FieldLabel>+ <ResourceMultiAutocomplete+ {...channelAutocompleteProps('bulk-products-channel-picker')}+ initialItems={channelsData?.data}+ value={channelIds}+ onChange={setChannelIds}+ />+ </Field>+ </BulkDialog>+ )+}+function TagPickerSheet({onSubmit,onCancel,diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/new.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/new.tsxindex 734c5f104c..3ddbb5ff54 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/new.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/new.tsx@@ -1,4 +1,5 @@import { zodResolver } from '@hookform/resolvers/zod'+import type { ProductCreateParams } from '@spree/admin-sdk'import { mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'import {Button,@@ -47,7 +48,7 @@ function NewProductPage() {async function onSubmit(values: CreateValues) {try {- const payload: Record<string, unknown> = { ...values }+ const payload: ProductCreateParams = { ...values }if (defaultChannelId) {payload.product_publications = [{ channel_id: defaultChannelId }]}@@ -70,7 +71,7 @@ function NewProductPage() {header={<PageHeadertitle={t('admin.pages.products.new.title')}- description={t('admin.pages.products.new.description')}+ subtitle={t('admin.pages.products.new.description')}backTo="products"actions={<Button type="submit" size="sm" disabled={form.formState.isSubmitting}>diff --git a/packages/dashboard/src/schemas/order.ts b/packages/dashboard/src/schemas/order.tsindex 12a27336ee..89581563f9 100644--- a/packages/dashboard/src/schemas/order.ts+++ b/packages/dashboard/src/schemas/order.ts@@ -19,6 +19,9 @@ export const newOrderFormSchema = z.object({customer_note: z.string(),internal_note: z.string(),coupon_code: z.string(),+ // Empty string = "use store default" (resolved server-side via+ // Order#ensure_channel_presence).+ channel_id: z.string(),})export type NewOrderFormValues = z.infer<typeof newOrderFormSchema>@@ -28,4 +31,5 @@ export const NEW_ORDER_DEFAULTS: NewOrderFormValues = {customer_note: '',internal_note: '',coupon_code: '',+ channel_id: '',}diff --git a/packages/dashboard/src/schemas/product.ts b/packages/dashboard/src/schemas/product.tsindex 2b566bdedf..c5d59a1ac0 100644--- a/packages/dashboard/src/schemas/product.ts+++ b/packages/dashboard/src/schemas/product.ts@@ -19,6 +19,15 @@ export const variantInventoryFormSchema = z.object({export type VariantInventoryFormValues = z.infer<typeof variantInventoryFormSchema>+export const productPublicationFormSchema = z.object({+ id: z.string().optional(),+ channel_id: z.string(),+ published_at: z.string().nullable().optional(),+ unpublished_at: z.string().nullable().optional(),+})++export type ProductPublicationFormValues = z.infer<typeof productPublicationFormSchema>+export const productFormSchema = z.object({// Generalname: z.string().min(1, { error: requiredMessage('name') }),@@ -26,9 +35,6 @@ export const productFormSchema = z.object({// Statusstatus: z.enum(['draft', 'active', 'archived']).optional(),- make_active_at: z.string().nullable().optional(),- available_on: z.string().nullable().optional(),- discontinue_on: z.string().nullable().optional(),// Categorizationcategory_ids: z.array(z.string()).optional(),@@ -45,6 +51,8 @@ export const productFormSchema = z.object({// Per-variant inventory across stock locations. For single-variant products// this carries one entry (the default variant).variants_inventory: z.array(variantInventoryFormSchema).optional(),++ product_publications: z.array(productPublicationFormSchema).optional(),})export type ProductFormValues = z.infer<typeof productFormSchema>diff --git a/packages/dashboard/src/tables/orders.tsx b/packages/dashboard/src/tables/orders.tsxindex 2dfd95697d..4c87c88d09 100644--- a/packages/dashboard/src/tables/orders.tsx+++ b/packages/dashboard/src/tables/orders.tsx@@ -3,6 +3,7 @@ import { RelativeTime, StatusBadge, TagList } from '@spree/dashboard-ui'import { Link } from '@tanstack/react-router'import i18n from 'i18next'import { ShoppingCartIcon } from 'lucide-react'+import { channelAutocompleteProps } from '@/hooks/use-channels'defineTable('orders', {title: 'Orders',@@ -175,5 +176,15 @@ defineTable('orders', {displayable: false,ransackAttribute: 'line_items_variant_sku',},+ {+ key: 'channels',+ label: i18n.t('admin.fields.product.channels.label'),+ filterable: true,+ filterType: 'resource',+ filterResource: channelAutocompleteProps('orders-table-channel-filter'),+ ransackAttribute: 'channel_id',+ displayable: false,+ default: false,+ },],})diff --git a/packages/dashboard/src/tables/products.tsx b/packages/dashboard/src/tables/products.tsxindex 79c927cb4a..b1b87c0e4d 100644--- a/packages/dashboard/src/tables/products.tsx+++ b/packages/dashboard/src/tables/products.tsx@@ -1,9 +1,11 @@+import type { Channel } from '@spree/admin-sdk'import { defineTable, formatPrice, Subject } from '@spree/dashboard-core'import { RelativeTime, StatusBadge, TagList } from '@spree/dashboard-ui'import { Link } from '@tanstack/react-router'import i18n from 'i18next'import { PackageIcon } from 'lucide-react'import { categoryAutocompleteProps } from '@/hooks/use-categories'+import { channelAutocompleteProps } from '@/hooks/use-channels'defineTable('products', {title: i18n.t('admin.nav.products'),@@ -170,5 +172,16 @@ defineTable('products', {displayable: false,default: false,},+ {+ key: 'channels',+ label: i18n.t('admin.fields.product.channels.label'),+ sortable: false,+ filterable: true,+ filterType: 'resource',+ filterResource: channelAutocompleteProps('products-table-channel-filter'),+ ransackAttribute: 'channels_id',+ default: false,+ render: (product) => product.channels?.map((c: Channel) => c.name).join(', ') ?? '—',+ },],})diff --git a/packages/sdk/src/types/generated/Channel.ts b/packages/sdk/src/types/generated/Channel.tsindex 8e7fd86615..3c2461e657 100644--- a/packages/sdk/src/types/generated/Channel.ts+++ b/packages/sdk/src/types/generated/Channel.ts@@ -1,4 +1,4 @@-// Typelizer digest ba03e6a05baa9ef6d4bf1e6fb5f3841e+// Typelizer digest 4c5cf138d1101c91b0986650b24c0a73//// DO NOT MODIFY: This file was automatically generated by Typelizer.@@ -7,6 +7,7 @@ interface Channel {name: string;code: string;active: boolean;+ default: boolean;}export default Channel;diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 91cec18817..3af6a76c6b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -318,6 +318,12 @@ importers:'@tanstack/react-router':specifier: ^1.169.2+ date-fns:+ specifier: ^4.1.0+ version: 4.1.0+ date-fns-tz:+ specifier: ^3.2.0+ version: 3.2.0([email protected])i18next:specifier: ^26.2.0version: 26.2.0([email protected])