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
PageHeader + Slot + JsonPreviewDrawer + hooks moved to dashboard-core (#14108)
Damian Legawiec5f3c1a48b943
diff --git a/packages/dashboard/src/components/spree/page-header.tsx b/packages/dashboard-core/src/components/page-header.tsxsimilarity index 92%rename from packages/dashboard/src/components/spree/page-header.tsxrename to packages/dashboard-core/src/components/page-header.tsxindex ff72ebe4cc..a75c57831f 100644--- a/packages/dashboard/src/components/spree/page-header.tsx+++ b/packages/dashboard-core/src/components/page-header.tsx@@ -1,4 +1,3 @@-import { useCopyToClipboard, useScrolled } from '@spree/dashboard-core'import {BackButton,Button,@@ -9,25 +8,30 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,useConfirm,+ useCopyToClipboard,+ useScrolled,} from '@spree/dashboard-ui'-import { useParams } from '@tanstack/react-router'+import type { JsonPreviewDrawerProps } from '@spree/dashboard-ui/spree/json-preview-drawer'import { BracesIcon, CheckIcon, CopyIcon, EllipsisVerticalIcon, TrashIcon } from 'lucide-react'import { lazy, type ReactNode, Suspense, useState } from 'react'import { useTranslation } from 'react-i18next'-import type { JsonPreviewDrawerProps } from '@/components/spree/json-preview-drawer'-import { Slot } from '@/components/spree/slot'+import { Slot } from './slot'// JSON drawer is a developer-only feature; pulling its tree (which includes// @uiw/react-json-view at ~30KB gzip) into the route bundle is wasteful.// Lazy-load on first open so the chunk only ships to admins who use it.+// Deep subpath import bypasses the dashboard-ui barrel so the JSON view+// libs only live in the chunk Rollup splits off here.const JsonPreviewDrawer = lazy(() =>- import('@/components/spree/json-preview-drawer').then((m) => ({ default: m.JsonPreviewDrawer })),+ import('@spree/dashboard-ui/spree/json-preview-drawer').then((m) => ({+ default: m.JsonPreviewDrawer,+ })),)-/** Subset of `JsonPreviewDrawerProps` callers supply; PageHeader provides storeId + open state. */+/** Subset of `JsonPreviewDrawerProps` callers supply; PageHeader manages open state. */export type PageHeaderJsonPreview = Pick<JsonPreviewDrawerProps,- 'title' | 'queryKey' | 'queryFn' | 'endpoint'+ 'title' | 'fetch' | 'endpoint' | 'resolveLink'>/**@@ -114,7 +118,6 @@ export function PageHeader({setJsonEverOpened(true)setJsonOpen(true)}- const { storeId } = useParams({ strict: false }) as { storeId?: string }const scrolled = useScrolled()return (@@ -163,19 +166,14 @@ export function PageHeader({dropdownItems={dropdownItems}onDelete={onDelete}deleteLabel={deleteLabel}- onOpenJson={jsonPreview && storeId ? openJson : undefined}+ onOpenJson={jsonPreview ? openJson : undefined}/>)}</div>- {jsonPreview && storeId && jsonEverOpened && (+ {jsonPreview && jsonEverOpened && (<Suspense fallback={null}>- <JsonPreviewDrawer- open={jsonOpen}- onOpenChange={setJsonOpen}- storeId={storeId}- {...jsonPreview}- />+ <JsonPreviewDrawer open={jsonOpen} onOpenChange={setJsonOpen} {...jsonPreview} /></Suspense>)}</header>diff --git a/packages/dashboard/src/components/spree/slot.tsx b/packages/dashboard-core/src/components/slot.tsxsimilarity index 94%rename from packages/dashboard/src/components/spree/slot.tsxrename to packages/dashboard-core/src/components/slot.tsxindex 4c6f769dfa..e28b32ca1a 100644--- a/packages/dashboard/src/components/spree/slot.tsx+++ b/packages/dashboard-core/src/components/slot.tsx@@ -1,5 +1,5 @@-import { type SlotAmbientContext, useSlotEntries } from '@spree/dashboard-core'import { Fragment } from 'react'+import { type SlotAmbientContext, useSlotEntries } from '../lib/slot-registry'interface SlotProps<TContext> {/** Slot name, e.g. "product.form_sidebar" or "order.dropdown". */diff --git a/packages/dashboard-core/src/index.ts b/packages/dashboard-core/src/index.tsindex f603b25679..dac28b9762 100644--- a/packages/dashboard-core/src/index.ts+++ b/packages/dashboard-core/src/index.ts@@ -14,19 +14,19 @@// Admin SDK client (Vite-aware singleton; reads VITE_SPREE_API_URL at build)// ---------------------------------------------------------------------------export { adminClient } from './client'+export * from './components/page-header'+export * from './components/slot'// ---------------------------------------------------------------------------// Infra hooks// ---------------------------------------------------------------------------export * from './hooks/use-auth'export * from './hooks/use-command-palette'-export * from './hooks/use-copy-to-clipboard'export * from './hooks/use-countries'export * from './hooks/use-custom-fields'export * from './hooks/use-direct-upload'export * from './hooks/use-export'export * from './hooks/use-global-search'export * from './hooks/use-resource-mutation'-export * from './hooks/use-scrolled'// ---------------------------------------------------------------------------// Helpers// ---------------------------------------------------------------------------diff --git a/packages/dashboard-ui/package.json b/packages/dashboard-ui/package.jsonindex 1e5b013559..d3179999d1 100644--- a/packages/dashboard-ui/package.json+++ b/packages/dashboard-ui/package.json@@ -47,6 +47,7 @@"@tiptap/extension-placeholder": "^3.22.5","@tiptap/react": "^3.22.5","@tiptap/starter-kit": "^3.22.5",+ "@uiw/react-json-view": "^1.12","class-variance-authority": "^0.7.1","clsx": "^2.1.1","cmdk": "^1.1.1",diff --git a/packages/dashboard-core/src/hooks/use-copy-to-clipboard.ts b/packages/dashboard-ui/src/hooks/use-copy-to-clipboard.tssimilarity index 100%rename from packages/dashboard-core/src/hooks/use-copy-to-clipboard.tsrename to packages/dashboard-ui/src/hooks/use-copy-to-clipboard.tsdiff --git a/packages/dashboard-core/src/hooks/use-scrolled.ts b/packages/dashboard-ui/src/hooks/use-scrolled.tssimilarity index 100%rename from packages/dashboard-core/src/hooks/use-scrolled.tsrename to packages/dashboard-ui/src/hooks/use-scrolled.tsdiff --git a/packages/dashboard-ui/src/index.ts b/packages/dashboard-ui/src/index.tsindex de035cd8fb..4496b5eb96 100644--- a/packages/dashboard-ui/src/index.ts+++ b/packages/dashboard-ui/src/index.ts@@ -11,7 +11,9 @@//// CSS lives at `@spree/dashboard-ui/styles.css` — import once from your Vite app.+export * from './hooks/use-copy-to-clipboard'export { useIsMobile } from './hooks/use-mobile'+export * from './hooks/use-scrolled'// ---------------------------------------------------------------------------// Helpers + hooks// ---------------------------------------------------------------------------@@ -30,6 +32,12 @@ export * from './spree/country-flag'export * from './spree/data-grid'export * from './spree/drag-handle'export * from './spree/form-actions'+// JsonPreviewDrawer is intentionally NOT re-exported from this barrel: it+// pulls in `@uiw/react-json-view` (~30KB gzip), and code-splitting only+// works when consumers can deep-import via `@spree/dashboard-ui/spree/json-preview-drawer`+// (the dashboard's `PageHeader` does this lazily). The type is available+// the same way — import { type JsonPreviewDrawerProps } from '@spree/dashboard-ui/spree/json-preview-drawer'.+export * from './spree/metadata/metadata-card'export * from './spree/relative-time'export * from './spree/resource-layout'diff --git a/packages/dashboard/src/components/spree/json-preview-drawer.tsx b/packages/dashboard-ui/src/spree/json-preview-drawer.tsxsimilarity index 68%rename from packages/dashboard/src/components/spree/json-preview-drawer.tsxrename to packages/dashboard-ui/src/spree/json-preview-drawer.tsxindex 347a4b1b98..c8a2176f5f 100644--- a/packages/dashboard/src/components/spree/json-preview-drawer.tsx+++ b/packages/dashboard-ui/src/spree/json-preview-drawer.tsx@@ -1,4 +1,3 @@-import { useCopyToClipboard } from '@spree/dashboard-core'import {Button,cn,@@ -7,8 +6,8 @@ import {SheetDescription,SheetHeader,SheetTitle,+ useCopyToClipboard,} from '@spree/dashboard-ui'-import { useQuery } from '@tanstack/react-query'import { Link } from '@tanstack/react-router'import JsonView from '@uiw/react-json-view'import { vscodeTheme } from '@uiw/react-json-view/vscode'@@ -23,22 +22,23 @@ import {XIcon,} from 'lucide-react'import type { ComponentProps } from 'react'-import { useMemo, useState } from 'react'+import { useEffect, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'-const PREFIX_DESTINATIONS: Record<string, { route: string; param: string }> = {- or: { route: '/$storeId/orders/$orderId', param: 'orderId' },- prod: { route: '/$storeId/products/$productId', param: 'productId' },- cus: { route: '/$storeId/customers/$customerId', param: 'customerId' },-}--const PREFIXED_ID_RE = /^([a-z]+(?:_[a-z]+)*)_([A-Za-z0-9]{6,})$/--function parsePrefixedId(value: unknown): { route: string; param: string } | null {- if (typeof value !== 'string') return null- const match = PREFIXED_ID_RE.exec(value)- return match ? (PREFIX_DESTINATIONS[match[1]] ?? null) : null-}+/**+ * Maps a string value (typically a prefixed ID like `or_abc123`) to an+ * in-app route. Returned `to` is a `<Link to>` template; `params` is the+ * positional-param map passed straight through. Return `null` for values+ * that aren't linkable.+ *+ * The drawer doesn't ship with any built-in prefix conventions —+ * `@spree/dashboard` provides Spree's `or`→orders / `prod`→products /+ * `cus`→customers mapping at the call site so dashboard-ui stays+ * Spree-vocabulary-free.+ */+export type JsonValueLinkResolver = (+ value: string,+) => { to: string; params: Record<string, string> } | nullconst VALUE_TYPE_STYLES: Record<string, { color: string; format: (v: unknown) => string }> = {string: { color: 'text-emerald-300', format: (v) => `"${v}"` },@@ -53,37 +53,81 @@ export interface JsonPreviewDrawerProps {/** Display title shown in the drawer header. Default "JSON". */title?: string/**- * React-Query key for the fetch. Each open refetches (`staleTime: 0`) — the- * drawer is a debug tool, so it always shows the latest server state.+ * Fetcher that returns the resource JSON. Called every time the drawer+ * opens (so it always shows the latest server state — it's a debug tool)+ * and every time the user clicks the refresh button. The drawer manages+ * its own loading/error state internally; no react-query is involved.*/- queryKey: readonly unknown[]- /** Fetcher that returns the resource JSON. Called inside `useQuery`. */- queryFn: () => Promise<unknown>+ fetch: () => Promise<unknown>/*** Resource path the JSON came from, e.g. `'/api/v3/admin/orders/or_xyz'`.* Shown in the toolbar and used as the "Open raw" target.*/endpoint?: string- /** Store ID for prefixed-ID links to other admin pages. */- storeId: string+ /**+ * Turn string values (typically prefixed IDs) into clickable links to+ * other admin pages. Omit to render every string as inert text — the+ * default for plugin authors who haven't wired up their own ID→route+ * convention.+ */+ resolveLink?: JsonValueLinkResolver}export function JsonPreviewDrawer({open,onOpenChange,title = 'JSON',- queryKey,- queryFn,+ fetch,endpoint,- storeId,+ resolveLink,}: JsonPreviewDrawerProps) {const { t } = useTranslation()- const { data, isLoading, isFetching, error, refetch } = useQuery({- queryKey,- queryFn,- enabled: open,- staleTime: 0,- })+ const [data, setData] = useState<unknown>(undefined)+ const [error, setError] = useState<Error | null>(null)+ const [isFetching, setIsFetching] = useState(false)+ // True only on the first load of an opened session — `isFetching` covers+ // subsequent refetches and animates the spinner button without blanking+ // the previously rendered JSON.+ const isLoading = isFetching && data === undefined && error === null++ // Refetch on every open + when the resource being inspected changes + on+ // manual refresh. The drawer is a debug tool, so staleness would be worse+ // than the extra request. `endpoint` stands in for "which resource is this+ // drawer pointing at" since it's a stable per-resource string; `fetch`+ // intentionally isn't in the deps because a fresh inline-arrow identity+ // every render would otherwise loop.+ // biome-ignore lint/correctness/useExhaustiveDependencies: see above+ useEffect(() => {+ if (!open) return+ let cancelled = false+ setIsFetching(true)+ setError(null)+ fetch()+ .then((result) => {+ if (cancelled) return+ setData(result)+ })+ .catch((err) => {+ if (cancelled) return+ setError(err instanceof Error ? err : new Error(String(err)))+ })+ .finally(() => {+ if (cancelled) return+ setIsFetching(false)+ })+ return () => {+ cancelled = true+ }+ }, [open, endpoint])++ const refetch = () => {+ setIsFetching(true)+ setError(null)+ fetch()+ .then(setData)+ .catch((err) => setError(err instanceof Error ? err : new Error(String(err))))+ .finally(() => setIsFetching(false))+ }const [collapsed, setCollapsed] = useState<boolean | number>(2)const { copied: copiedAll, copy } = useCopyToClipboard()@@ -170,9 +214,7 @@ export function JsonPreviewDrawer({{isLoading ? (<p className="text-zinc-500">Loading…</p>) : error ? (- <p className="text-red-400">- Failed to load: {error instanceof Error ? error.message : String(error)}- </p>+ <p className="text-red-400">Failed to load: {error.message}</p>) : data ? (<JsonViewvalue={data as object}@@ -186,7 +228,7 @@ export function JsonPreviewDrawer({shortenTextAfterLength={60}components={{value: ({ value, type, ...rest }) => (- <ValueRenderer value={value} type={type} storeId={storeId} {...rest} />+ <ValueRenderer value={value} type={type} resolveLink={resolveLink} {...rest} />),}}/>@@ -240,28 +282,28 @@ function DepthControl({interface ValueRendererProps {value: unknowntype: string- storeId: string+ resolveLink?: JsonValueLinkResolver}function ValueRenderer({value,type,- storeId,+ resolveLink,...rest}: ValueRendererProps & React.HTMLAttributes<HTMLSpanElement>) {- if (type === 'string') {- const parsed = parsePrefixedId(value)- if (parsed) {+ if (type === 'string' && typeof value === 'string' && resolveLink) {+ const resolved = resolveLink(value)+ if (resolved) {return (<span {...rest} className="text-emerald-300">"<Link- to={parsed.route}- params={{ storeId, [parsed.param]: value as string }}+ to={resolved.to}+ params={resolved.params}className="text-emerald-300 underline decoration-emerald-700 hover:decoration-emerald-300 transition-colors"onClick={(e) => e.stopPropagation()}>- {String(value)}+ {value}</Link>"</span>diff --git a/packages/dashboard/src/components/spree/page-tabs.tsx b/packages/dashboard/src/components/spree/page-tabs.tsxindex b196cd5b12..6ffd9ad9c7 100644--- a/packages/dashboard/src/components/spree/page-tabs.tsx+++ b/packages/dashboard/src/components/spree/page-tabs.tsx@@ -1,7 +1,7 @@+import { Slot } from '@spree/dashboard-core'import { cn } from '@spree/dashboard-ui'import { Link, type LinkProps, useLocation, useRouter } from '@tanstack/react-router'import type { ReactNode } from 'react'-import { Slot } from '@/components/spree/slot'export interface PageTab {/** Stable key used for React lists. */diff --git a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsxindex d3dec5b6ee..ca4785e55e 100644--- a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx+++ b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx@@ -1,5 +1,5 @@import type { PaymentMethod, PreferenceField } from '@spree/admin-sdk'-import { useSlotEntries } from '@spree/dashboard-core'+import { Slot, useSlotEntries } from '@spree/dashboard-core'import {Field,FieldError,@@ -18,7 +18,6 @@ import {import { Controller, type UseFormReturn } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { PreferencesForm } from '@/components/spree/preferences-form'-import { Slot } from '@/components/spree/slot'import {type PaymentMethodEditorContext,type PaymentMethodFormMode,diff --git a/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx b/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsxindex baf48c4922..182b51ac17 100644--- a/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx+++ b/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import type { PriceList, PriceRule, ResourceTypeDefinition } from '@spree/admin-sdk'-import { adminClient, useStore } from '@spree/dashboard-core'+import { adminClient, PageHeader, useStore } from '@spree/dashboard-core'import { useConfirm } from '@spree/dashboard-ui'import { parseISO } from 'date-fns'import { formatInTimeZone } from 'date-fns-tz'@@ -18,7 +18,6 @@ import { Controller, type UseFormReturn, useFieldArray, useForm } from 'react-hoimport { useTranslation } from 'react-i18next'import { BulkPriceEditorDialog } from '@/components/spree/bulk-price-editor/bulk-price-editor-dialog'import { Can } from '@/components/spree/can'-import { PageHeader } from '@/components/spree/page-header'import { PreferencesForm } from '@/components/spree/preferences-form'import { PriceListStatusBadge } from '@/components/spree/price-list-editors/status-badge'import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-autocomplete'@@ -26,7 +25,7 @@ import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-aut// group, …) into the slot registry. Must run before any RuleEditSheet// mounts.import '@/components/spree/price-list-editors/register'-import { mapSpreeErrorsToForm, Subject } from '@spree/dashboard-core'+import { mapSpreeErrorsToForm, Slot, Subject } from '@spree/dashboard-core'import {Button,Card,@@ -56,7 +55,6 @@ import {ruleFormSlot,} from '@/components/spree/price-list-editors/types'import { EditorShell } from '@/components/spree/promotion-editors/editor-shell'-import { Slot } from '@/components/spree/slot'import { StoreDatePicker } from '@/components/spree/store-date-picker'import {useActivatePriceList,diff --git a/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx b/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsxindex 56855146d6..6edbd939a3 100644--- a/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx+++ b/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx@@ -8,18 +8,18 @@ import type {PromotionRuleDraft,ResourceTypeDefinition,} from '@spree/admin-sdk'+import { PageHeader } from '@spree/dashboard-core'import { formatCalculatorSummary, useConfirm } from '@spree/dashboard-ui'import { DownloadIcon, PlusIcon, SparklesIcon, TrashIcon } from 'lucide-react'import { useEffect, useState } from 'react'import { Controller, type UseFormReturn, useFieldArray, useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { Can } from '@/components/spree/can'-import { PageHeader } from '@/components/spree/page-header'import { PreferencesForm } from '@/components/spree/preferences-form'import { EditorShell } from '@/components/spree/promotion-editors/editor-shell'import { StoreDatePicker } from '@/components/spree/store-date-picker'import '@/components/spree/promotion-editors/register'-import { mapSpreeErrorsToForm, Subject, useExport, useStore } from '@spree/dashboard-core'+import { mapSpreeErrorsToForm, Slot, Subject, useExport, useStore } from '@spree/dashboard-core'import {ActiveBadge,Badge,@@ -68,7 +68,6 @@ import {ruleDraftToPayload,ruleFormSlot,} from '@/components/spree/promotion-editors/types'-import { Slot } from '@/components/spree/slot'import {usePromotionActionTypes,usePromotionCouponCodes,diff --git a/packages/dashboard/src/lib/json-link-resolver.ts b/packages/dashboard/src/lib/json-link-resolver.tsnew file mode 100644index 0000000000..b67ea371c7--- /dev/null+++ b/packages/dashboard/src/lib/json-link-resolver.ts@@ -0,0 +1,34 @@+import type { JsonValueLinkResolver } from '@spree/dashboard-ui/spree/json-preview-drawer'++/**+ * Spree's prefixed-ID → admin-route mapping. Used by `<JsonPreviewDrawer>`+ * (and any other consumer of `JsonValueLinkResolver`) to turn IDs like+ * `or_abc123` or `prod_xyz789` that appear in a JSON payload into clickable+ * links to the corresponding admin page.+ *+ * Lives in `@spree/dashboard` (not `@spree/dashboard-ui`) so the design+ * system stays Spree-vocabulary-free. Plugins targeting a non-Spree backend+ * can pass their own resolver.+ */+const PREFIX_DESTINATIONS: Record<string, { to: string; paramName: string }> = {+ or: { to: '/$storeId/orders/$orderId', paramName: 'orderId' },+ prod: { to: '/$storeId/products/$productId', paramName: 'productId' },+ cus: { to: '/$storeId/customers/$customerId', paramName: 'customerId' },+}++const PREFIXED_ID_RE = /^([a-z]+(?:_[a-z]+)*)_([A-Za-z0-9]{6,})$/++/**+ * Build a `JsonValueLinkResolver` bound to the current store. Pass the+ * result to `<JsonPreviewDrawer resolveLink={...} />` (or via+ * `<PageHeader jsonPreview={{ resolveLink: ..., ... }} />`).+ */+export function spreeJsonLinkResolver(storeId: string): JsonValueLinkResolver {+ return (value) => {+ const match = PREFIXED_ID_RE.exec(value)+ if (!match) return null+ const dest = PREFIX_DESTINATIONS[match[1]]+ if (!dest) return null+ return { to: dest.to, params: { storeId, [dest.paramName]: value } }+ }+}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/customers/$customerId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/customers/$customerId.tsxindex 7a388ce0f6..d3bac15849 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/customers/$customerId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/customers/$customerId.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import type { Address, Customer, Order, StoreCredit } from '@spree/admin-sdk'-import { mapSpreeErrorsToForm, useCountries, useStore } from '@spree/dashboard-core'+import { mapSpreeErrorsToForm, PageHeader, useCountries, useStore } from '@spree/dashboard-core'import {Badge,Button,@@ -61,7 +61,6 @@ import { useTranslation } from 'react-i18next'import { AddressFormDialog, type AddressParams } from '@/components/spree/address-form-dialog'import { CurrencySelect } from '@/components/spree/currency-select'import { CustomFieldsCard } from '@/components/spree/custom-fields/custom-fields-card'-import { PageHeader } from '@/components/spree/page-header'import { TagCombobox } from '@/components/spree/tag-combobox'import {type StoreCreditUpdateParams,@@ -79,6 +78,7 @@ import {useUpdateCustomerAddress,} from '@/hooks/use-customers'import { useStoreCreditCategories } from '@/hooks/use-store-credit-categories'+import { spreeJsonLinkResolver } from '@/lib/json-link-resolver'import { type CustomerProfileFormValues, customerProfileFormSchema } from '@/schemas/customer'import {type EditStoreCreditFormValues,@@ -146,11 +146,11 @@ function CustomerBody({ customer }: { customer: Customer }) {deleteLabel={t('admin.customers.detail.delete_label')}jsonPreview={{title: `Customer ${customer.email}`,- queryKey: ['json', 'customer', customer.id],// Reuse what `useCustomer` already loaded — opening the drawer// shouldn't trigger a duplicate fetch.- queryFn: () => Promise.resolve(customer),+ fetch: () => Promise.resolve(customer),endpoint: `/api/v3/admin/customers/${customer.id}`,+ resolveLink: spreeJsonLinkResolver(storeId),}}/>{deleteMutation.error && (diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsxindex 1b7bdbfe9a..61eb1dcf0f 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx@@ -1,5 +1,11 @@import type { Order, Variant } from '@spree/admin-sdk'-import { adminClient, formatPrice, getInitials, useResourceMutation } from '@spree/dashboard-core'+import {+ adminClient,+ formatPrice,+ getInitials,+ PageHeader,+ useResourceMutation,+} from '@spree/dashboard-core'import {AddressBlock,Avatar,@@ -73,9 +79,9 @@ import { type FormEvent, useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { AddressFormDialog, type AddressParams } from '@/components/spree/address-form-dialog'import { CustomFieldsCard } from '@/components/spree/custom-fields/custom-fields-card'-import { PageHeader } from '@/components/spree/page-header'import { TagCombobox } from '@/components/spree/tag-combobox'import { orderQueryKey, useOrder, useOrderMutation } from '@/hooks/use-order'+import { spreeJsonLinkResolver } from '@/lib/json-link-resolver'export const Route = createFileRoute('/_authenticated/$storeId/orders/$orderId')({component: OrderDetailPage,@@ -149,7 +155,7 @@ function OrderDetailPage() {function OrderHeader({ order }: { order: Order }) {const { t } = useTranslation()- const { orderId } = Route.useParams()+ const { orderId, storeId } = Route.useParams()const confirm = useConfirm()const backFallback = order.completed_at ? 'orders' : 'orders/drafts'@@ -302,9 +308,9 @@ function OrderHeader({ order }: { order: Order }) {resource={{ id: order.id, number: order.number }}jsonPreview={{title: `Order ${order.number}`,- queryKey: ['json', 'order', orderId],- queryFn: () => adminClient.orders.get(orderId),+ fetch: () => adminClient.orders.get(orderId),endpoint: `/api/v3/admin/orders/${orderId}`,+ resolveLink: spreeJsonLinkResolver(storeId),}}/>)diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsxindex bc329ed9ef..09f04b6f1b 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/new.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import type { Customer, Variant } from '@spree/admin-sdk'-import { adminClient, formatPrice, mapSpreeErrorsToForm } from '@spree/dashboard-core'+import { adminClient, formatPrice, mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'import {Button,Card,@@ -22,7 +22,6 @@ import { TrashIcon } from 'lucide-react'import { useState } from 'react'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'-import { PageHeader } from '@/components/spree/page-header'import { ResourceCombobox } from '@/components/spree/resource-combobox'import { customerAutocompleteProps } from '@/hooks/use-customers'import { NEW_ORDER_DEFAULTS, type NewOrderFormValues, newOrderFormSchema } from '@/schemas/order'diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsxindex ff1892be3f..ce3553d909 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx@@ -15,7 +15,12 @@ import {import { CSS } from '@dnd-kit/utilities'import { zodResolver } from '@hookform/resolvers/zod'import { type Media, type Product, SpreeError, type Variant } from '@spree/admin-sdk'-import { adminClient, mapSpreeErrorsToForm, useDirectUpload } from '@spree/dashboard-core'+import {+ adminClient,+ mapSpreeErrorsToForm,+ PageHeader,+ useDirectUpload,+} from '@spree/dashboard-core'import {Button,Card,@@ -50,7 +55,6 @@ import { useTranslation } from 'react-i18next'import { toast } from 'sonner'import { BulkPriceEditorDialog } from '@/components/spree/bulk-price-editor/bulk-price-editor-dialog'import { CustomFieldsCard } from '@/components/spree/custom-fields/custom-fields-card'-import { PageHeader } from '@/components/spree/page-header'import { InventorySection } from '@/components/spree/products/inventory-section'import { MediaEditSheet } from '@/components/spree/products/media-edit-sheet'import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-autocomplete'@@ -65,6 +69,7 @@ import {useUpdateProductMedia,} from '@/hooks/use-product-media'import { useTaxCategories } from '@/hooks/use-tax-categories'+import { spreeJsonLinkResolver } from '@/lib/json-link-resolver'import { type ProductFormValues, productFormSchema } from '@/schemas/product'// Purchasable attributes (sku, barcode, prices, weight, dimensions, stock,@@ -243,9 +248,9 @@ function ProductForm({ product }: { product: Product }) {deleteLabel={t('admin.products.delete_label')}jsonPreview={{title: `Product ${product.name}`,- queryKey: ['json', 'product', productId],- queryFn: () => adminClient.products.get(productId),+ fetch: () => adminClient.products.get(productId),endpoint: `/api/v3/admin/products/${productId}`,+ resolveLink: spreeJsonLinkResolver(storeId),}}/>}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/api-keys.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/api-keys.tsxindex f2cdc412c8..625df18c84 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/api-keys.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/api-keys.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { type ApiKey, type ApiKeyCreateParams, SpreeError } from '@spree/admin-sdk'-import { mapSpreeErrorsToForm, useCopyToClipboard } from '@spree/dashboard-core'+import { mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'import {Badge,Button,@@ -50,6 +50,7 @@ import {TableHeader,TableRow,useConfirm,+ useCopyToClipboard,} from '@spree/dashboard-ui'import { createFileRoute } from '@tanstack/react-router'import {@@ -65,7 +66,6 @@ import { Controller, useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { toast } from 'sonner'import { z } from 'zod/v4'-import { PageHeader } from '@/components/spree/page-header'import { useApiKeys, useCreateApiKey, useDeleteApiKey, useRevokeApiKey } from '@/hooks/use-api-keys'export const Route = createFileRoute('/_authenticated/$storeId/settings/api-keys')({diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/staff.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/staff.tsxindex 2115a32a2d..ca0e092de0 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/staff.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/staff.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { type AdminUser, type Invitation, type Role, SpreeError } from '@spree/admin-sdk'-import { getInitials, mapSpreeErrorsToForm, useCopyToClipboard } from '@spree/dashboard-core'+import { getInitials, mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'import {Avatar,AvatarFallback,@@ -48,6 +48,7 @@ import {TableHeader,TableRow,useConfirm,+ useCopyToClipboard,} from '@spree/dashboard-ui'import { createFileRoute } from '@tanstack/react-router'import {@@ -64,7 +65,6 @@ import { Controller, useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { toast } from 'sonner'import { z } from 'zod/v4'-import { PageHeader } from '@/components/spree/page-header'import {useCreateInvitation,useDeleteInvitation,diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsxindex 2d06c433f5..464de9e24c 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { SpreeError, type Store } from '@spree/admin-sdk'-import { mapSpreeErrorsToForm } from '@spree/dashboard-core'+import { mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'import {Card,CardContent,@@ -33,7 +33,6 @@ import {} from 'react-hook-form'import { useTranslation } from 'react-i18next'import { toast } from 'sonner'-import { PageHeader } from '@/components/spree/page-header'import { useStoreSettings, useUpdateStoreSettings } from '@/hooks/use-store-settings'import {ADMIN_LOCALE_OPTIONS,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ba8da7fa50..0d198bd298 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -388,6 +388,9 @@ importers:'@tiptap/starter-kit':specifier: ^3.22.5version: 3.22.5+ '@uiw/react-json-view':+ specifier: ^1.12+ version: 1.12.2(@babel/[email protected])([email protected]([email protected]))([email protected])class-variance-authority:specifier: ^0.7.1version: 0.7.1