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
Improve Stock Locations UI in Admin SPA (#14003)
Damian Legawiec97b2998fb386
diff --git a/CLAUDE.md b/CLAUDE.mdindex 3b9c706da8..8c4d942977 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -443,6 +443,30 @@ pnpm dev # http://localhost:5173 (proxies /api/* to :3000)If a needed Admin API endpoint or attribute is missing, **add it to `spree/api` first** (see backend conventions above), regenerate types via the [Type Generation Pipeline](#type-generation-pipeline), then consume it from the SPA.+**Base UI vs Radix — `<Select>` does not auto-render labels.** The admin SPA's `<Select>` wraps **Base UI** (`@base-ui/react/select`), not Radix. Unlike Radix, Base UI's `<Select.Value />` defaults to rendering the raw selected `value` (e.g. the ISO code, the slug, the prefixed ID) instead of the matching `<SelectItem>`'s children. A bare `<SelectValue />` next to `<SelectItem value="warehouse">Warehouse</SelectItem>` will display `warehouse`, not `Warehouse`.++There are two correct ways to make the trigger show the label:++1. **Pass `items` to `<Select>` (preferred when option labels are static).** Base UI resolves the trigger label from the items array automatically:+ ```tsx+ const KIND_OPTIONS = [{ value: 'warehouse', label: 'Warehouse' }, ...] as const++ <Select items={KIND_OPTIONS} value={...} onValueChange={...}>+ <SelectTrigger><SelectValue /></SelectTrigger>+ <SelectContent>+ {KIND_OPTIONS.map((o) => <SelectItem key={o.value} value={o.value}>{o.label}</SelectItem>)}+ </SelectContent>+ </Select>+ ```+2. **Use the `<SelectValue>` children render-prop (when labels are dynamic, e.g. fetched options).** Base UI calls the function with the current value:+ ```tsx+ <SelectValue>+ {(value) => roles.find((r) => r.id === value)?.name ?? (value as string)}+ </SelectValue>+ ```++For free-text **searchable** pickers, prefer `<Combobox>` over `<Select>` — see `components/spree/country-state-fields.tsx` for the country/state pattern.+### @spree/sdk-core — Shared HTTP LayerPrivate package providing `createRequestFn()`, `SpreeError`, retry logic, and Ransack param transformation. Used internally by both SDKs.diff --git a/packages/admin/src/components/spree/address-form-dialog.tsx b/packages/admin/src/components/spree/address-form-dialog.tsxindex 1bd2194be8..e245573aa8 100644--- a/packages/admin/src/components/spree/address-form-dialog.tsx+++ b/packages/admin/src/components/spree/address-form-dialog.tsx@@ -1,14 +1,11 @@import type { Address } from '@spree/admin-sdk'-import { type FormEvent, useCallback, useMemo, useState } from 'react'-import { Button } from '@/components/ui/button'+import { type FormEvent, useCallback, useState } from 'react'import {- Combobox,- ComboboxContent,- ComboboxEmpty,- ComboboxInput,- ComboboxItem,- ComboboxList,-} from '@/components/ui/combobox'+ CountryCombobox,+ StateCombobox,+ useCountryStates,+} from '@/components/spree/country-state-fields'+import { Button } from '@/components/ui/button'import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'import { Input } from '@/components/ui/input'import {@@ -19,14 +16,6 @@ import {SheetHeader,SheetTitle,} from '@/components/ui/sheet'-import { useCountries } from '@/hooks/use-countries'--/** Convert 2-letter ISO code to flag emoji (e.g. "US" → "🇺🇸") */-function countryFlag(iso: string): string {- return [...iso.toUpperCase()]- .map((c) => String.fromCodePoint(0x1f1e6 + c.charCodeAt(0) - 65))- .join('')-}export interface AddressParams {first_name: string@@ -43,9 +32,6 @@ export interface AddressParams {is_default_shipping?: boolean}-type CountryOption = { iso: string; name: string }-type StateOption = { abbr: string; name: string }-export function AddressFormDialog({address,open,@@ -65,37 +51,20 @@ export function AddressFormDialog({showLabel?: booleanshowDefaultFlags?: boolean}) {- const { countries } = useCountries()-- const countryItems: CountryOption[] = useMemo(- () => countries.map((c) => ({ iso: c.iso, name: c.name })),- [countries],- )+ // The parent keys the dialog on the address id so a fresh instance mounts+ // for each open — that's what lets us seed `countryIso` from the address+ // once and forget about it.+ const [countryIso, setCountryIso] = useState<string>(() => address?.country_iso ?? '')+ const [stateAbbr, setStateAbbr] = useState<string>(() => address?.state_abbr ?? '')- // Lazy initializer runs once on mount; the parent keys the dialog on the- // address id so a fresh instance mounts for each open.- const [selectedCountry, setSelectedCountry] = useState<CountryOption | null>(- () => countryItems.find((c) => c.iso === address?.country_iso) ?? null,- )+ const { states, statesRequired } = useCountryStates(countryIso)+ const useStateCombobox = statesRequired && states.length > 0- const countryData = useMemo(- () => countries.find((c) => c.iso === selectedCountry?.iso),- [countries, selectedCountry],- )-- const statesRequired = countryData?.states_required ?? false- const stateItems: StateOption[] = useMemo(- () => ((countryData as any)?.states ?? []) as StateOption[],- [countryData],- )-- const [selectedState, setSelectedState] = useState<StateOption | null>(- () => stateItems.find((s) => s.abbr === address?.state_abbr) ?? null,- )-- const handleCountryChange = useCallback((country: CountryOption | null) => {- setSelectedCountry(country)- setSelectedState(null)+ const handleCountryChange = useCallback((iso: string) => {+ setCountryIso(iso)+ // Clear the previously selected state — the combobox is keyed on the+ // country, but we still need the form field to reset across countries.+ setStateAbbr('')}, [])function handleSubmit(e: FormEvent<HTMLFormElement>) {@@ -108,8 +77,8 @@ export function AddressFormDialog({address2: fd.get('address2') as string,city: fd.get('city') as string,postal_code: fd.get('postal_code') as string,- country_iso: selectedCountry?.iso ?? '',- state_abbr: statesRequired ? (selectedState?.abbr ?? '') : (fd.get('state_abbr') as string),+ country_iso: countryIso,+ state_abbr: useStateCombobox ? stateAbbr : (fd.get('state_abbr') as string),phone: fd.get('phone') as string,...(showLabel && { label: (fd.get('label') as string) || undefined }),...(showDefaultFlags && {@@ -172,29 +141,7 @@ export function AddressFormDialog({</Field><Field><FieldLabel>Country</FieldLabel>- <Combobox- items={countryItems}- value={selectedCountry}- onValueChange={handleCountryChange as any}- itemToStringLabel={(c: any) => {- const co = c as CountryOption- return co?.iso ? `${countryFlag(co.iso)} ${co.name}` : (co?.name ?? '')- }}- itemToStringValue={(c: any) => (c as CountryOption)?.iso ?? ''}- >- <ComboboxInput placeholder="Search countries..." />- <ComboboxContent>- <ComboboxEmpty>No countries found</ComboboxEmpty>- <ComboboxList>- {(country: CountryOption) => (- <ComboboxItem key={country.iso} value={country}>- <span className="mr-1.5">{countryFlag(country.iso)}</span>- {country.name}- </ComboboxItem>- )}- </ComboboxList>- </ComboboxContent>- </Combobox>+ <CountryCombobox value={countryIso} onValueChange={handleCountryChange} /></Field><div className="grid grid-cols-2 gap-3"><Field>@@ -203,27 +150,13 @@ export function AddressFormDialog({</Field><Field><FieldLabel>State / Province</FieldLabel>- {statesRequired && stateItems.length > 0 ? (- <Combobox- key={selectedCountry?.iso ?? 'no-country'}- items={stateItems}- value={selectedState}- onValueChange={setSelectedState as any}- itemToStringLabel={(s: any) => (s as StateOption)?.name ?? ''}- itemToStringValue={(s: any) => (s as StateOption)?.abbr ?? ''}- >- <ComboboxInput placeholder="Search states..." />- <ComboboxContent>- <ComboboxEmpty>No states found</ComboboxEmpty>- <ComboboxList>- {(state: StateOption) => (- <ComboboxItem key={state.abbr} value={state}>- {state.name}- </ComboboxItem>- )}- </ComboboxList>- </ComboboxContent>- </Combobox>+ {useStateCombobox ? (+ <StateCombobox+ countryIso={countryIso}+ states={states}+ value={stateAbbr}+ onValueChange={setStateAbbr}+ />) : (<Inputid="addr-state"diff --git a/packages/admin/src/components/spree/country-state-fields.tsx b/packages/admin/src/components/spree/country-state-fields.tsxnew file mode 100644index 0000000000..8a1413bfd3--- /dev/null+++ b/packages/admin/src/components/spree/country-state-fields.tsx@@ -0,0 +1,150 @@+import type { State } from '@spree/admin-sdk'+import { useMemo } from 'react'+import {+ Combobox,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxInput,+ ComboboxItem,+ ComboboxList,+} from '@/components/ui/combobox'+import { useCountries } from '@/hooks/use-countries'++/** 2-letter ISO code → flag emoji ("US" → "🇺🇸"). */+export function countryFlag(iso: string): string {+ return [...iso.toUpperCase()]+ .map((c) => String.fromCodePoint(0x1f1e6 + c.charCodeAt(0) - 65))+ .join('')+}++type CountryOption = { iso: string; name: string }+type StateOption = { abbr: string; name: string }++/**+ * Country/state lookup for the active country selection. `states` is empty+ * when the country doesn't enumerate them (free-text region); `statesRequired`+ * tells callers whether to fall back to a plain text input.+ */+export function useCountryStates(countryIso: string | null | undefined) {+ const { countries } = useCountries()+ const country = useMemo(+ () => countries.find((c) => c.iso === countryIso) ?? null,+ [countries, countryIso],+ )+ return {+ states: ((country?.states ?? []) as StateOption[]).filter((s) => Boolean(s.abbr)),+ statesRequired: country?.states_required ?? false,+ }+}++// ---------------------------------------------------------------------------+// CountryCombobox+// ---------------------------------------------------------------------------++/**+ * Searchable country picker. Value is the 2-letter ISO code (so the field+ * round-trips cleanly with the Spree API). Renders the country name + flag in+ * the trigger and dropdown.+ */+export function CountryCombobox({+ value,+ onValueChange,+ placeholder = 'Search countries...',+ disabled = false,+}: {+ value: string | null | undefined+ onValueChange: (iso: string) => void+ placeholder?: string+ disabled?: boolean+}) {+ const { countries } = useCountries()++ const items: CountryOption[] = useMemo(+ () => countries.map((c) => ({ iso: c.iso, name: c.name })),+ [countries],+ )++ // The Combobox holds the selected object internally; we adapt to a flat ISO+ // string at the boundary so callers don't have to thread the option shape.+ const selected = useMemo(() => items.find((c) => c.iso === value) ?? null, [items, value])++ return (+ <Combobox+ items={items}+ value={selected}+ onValueChange={(c: CountryOption | null) => onValueChange(c?.iso ?? '')}+ itemToStringLabel={(c: CountryOption | null) =>+ c?.iso ? `${countryFlag(c.iso)} ${c.name}` : (c?.name ?? '')+ }+ itemToStringValue={(c: CountryOption | null) => c?.iso ?? ''}+ >+ <ComboboxInput placeholder={placeholder} disabled={disabled} />+ <ComboboxContent>+ <ComboboxEmpty>No countries found</ComboboxEmpty>+ <ComboboxList>+ {(country: CountryOption) => (+ <ComboboxItem key={country.iso} value={country}>+ <span className="mr-1.5">{countryFlag(country.iso)}</span>+ {country.name}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ )+}++// ---------------------------------------------------------------------------+// StateCombobox+// ---------------------------------------------------------------------------++/**+ * Searchable state/province picker for a given country. Value is the state+ * abbreviation (e.g. "CA"). Callers should hide this and render a free-text+ * Input when `useCountryStates(...).states` is empty.+ *+ * Keyed on `countryIso` so the internal state is reset when the country+ * changes — prevents a stale highlight from a previous country.+ */+export function StateCombobox({+ countryIso,+ states,+ value,+ onValueChange,+ placeholder = 'Search states...',+ disabled = false,+}: {+ countryIso: string | null | undefined+ /** State list for the active country (typically from `useCountryStates`). */+ states: Pick<State, 'abbr' | 'name'>[]+ value: string | null | undefined+ onValueChange: (abbr: string) => void+ placeholder?: string+ disabled?: boolean+}) {+ const items = states as StateOption[]+ const selected = useMemo(() => items.find((s) => s.abbr === value) ?? null, [items, value])++ return (+ <Combobox+ key={countryIso ?? 'no-country'}+ items={items}+ value={selected}+ onValueChange={(s: StateOption | null) => onValueChange(s?.abbr ?? '')}+ itemToStringLabel={(s: StateOption | null) => s?.name ?? ''}+ itemToStringValue={(s: StateOption | null) => s?.abbr ?? ''}+ >+ <ComboboxInput placeholder={placeholder} disabled={disabled} />+ <ComboboxContent>+ <ComboboxEmpty>No states found</ComboboxEmpty>+ <ComboboxList>+ {(state: StateOption) => (+ <ComboboxItem key={state.abbr} value={state}>+ {state.name}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ )+}diff --git a/packages/admin/src/nav/default.ts b/packages/admin/src/nav/default.tsindex d3564728a3..e4cd03544f 100644--- a/packages/admin/src/nav/default.ts+++ b/packages/admin/src/nav/default.ts@@ -51,13 +51,6 @@ nav.add({subject: Subject.Product,position: 100,},- {- key: 'products.stock',- label: 'Stock',- path: '/products/stock',- subject: Subject.StockLocation,- position: 200,- },{key: 'products.categories',label: 'Categories',diff --git a/packages/admin/src/nav/settings.ts b/packages/admin/src/nav/settings.tsindex 5d96729533..8631eef4af 100644--- a/packages/admin/src/nav/settings.ts+++ b/packages/admin/src/nav/settings.ts@@ -1,9 +1,10 @@-import { KeyRoundIcon, StoreIcon, UsersRoundIcon } from 'lucide-react'+import { KeyRoundIcon, StoreIcon, UsersRoundIcon, WarehouseIcon } from 'lucide-react'import { Subject } from '@/lib/permissions'import { settingsNav } from '@/lib/settings-nav-registry'settingsNav.addGroup({ key: 'store', label: 'Store', position: 100 })-settingsNav.addGroup({ key: 'team', label: 'Team & access', position: 200 })+settingsNav.addGroup({ key: 'fulfillment', label: 'Fulfillment', position: 200 })+settingsNav.addGroup({ key: 'team', label: 'Team & access', position: 300 })settingsNav.add({key: 'settings.store',@@ -15,6 +16,16 @@ settingsNav.add({subject: Subject.Store,})+settingsNav.add({+ key: 'settings.stock-locations',+ label: 'Stock locations',+ path: '/stock-locations',+ icon: WarehouseIcon,+ group: 'fulfillment',+ position: 100,+ subject: Subject.StockLocation,+})+settingsNav.add({key: 'settings.staff',label: 'Staff',diff --git a/packages/admin/src/routeTree.gen.ts b/packages/admin/src/routeTree.gen.tsindex 81ed88691c..cf22fb32cd 100644--- a/packages/admin/src/routeTree.gen.ts+++ b/packages/admin/src/routeTree.gen.ts@@ -21,9 +21,9 @@ import { Route as AuthenticatedStoreIdProductsIndexRouteImport } from './routes/import { Route as AuthenticatedStoreIdOrdersIndexRouteImport } from './routes/_authenticated/$storeId/orders/index'import { Route as AuthenticatedStoreIdCustomersIndexRouteImport } from './routes/_authenticated/$storeId/customers/index'import { Route as AuthenticatedStoreIdSettingsStoreRouteImport } from './routes/_authenticated/$storeId/settings/store'+import { Route as AuthenticatedStoreIdSettingsStockLocationsRouteImport } from './routes/_authenticated/$storeId/settings/stock-locations'import { Route as AuthenticatedStoreIdSettingsStaffRouteImport } from './routes/_authenticated/$storeId/settings/staff'import { Route as AuthenticatedStoreIdSettingsApiKeysRouteImport } from './routes/_authenticated/$storeId/settings/api-keys'-import { Route as AuthenticatedStoreIdProductsStockRouteImport } from './routes/_authenticated/$storeId/products/stock'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'@@ -97,6 +97,12 @@ const AuthenticatedStoreIdSettingsStoreRoute =path: '/store',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)+const AuthenticatedStoreIdSettingsStockLocationsRoute =+ AuthenticatedStoreIdSettingsStockLocationsRouteImport.update({+ id: '/stock-locations',+ path: '/stock-locations',+ getParentRoute: () => AuthenticatedStoreIdSettingsRoute,+ } as any)const AuthenticatedStoreIdSettingsStaffRoute =AuthenticatedStoreIdSettingsStaffRouteImport.update({id: '/staff',@@ -109,12 +115,6 @@ const AuthenticatedStoreIdSettingsApiKeysRoute =path: '/api-keys',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)-const AuthenticatedStoreIdProductsStockRoute =- AuthenticatedStoreIdProductsStockRouteImport.update({- id: '/products/stock',- path: '/products/stock',- getParentRoute: () => AuthenticatedStoreIdRoute,- } as any)const AuthenticatedStoreIdProductsProductIdRoute =AuthenticatedStoreIdProductsProductIdRouteImport.update({id: '/products/$productId',@@ -158,9 +158,9 @@ export interface FileRoutesByFullPath {'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute- '/$storeId/products/stock': typeof AuthenticatedStoreIdProductsStockRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute'/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute+ '/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute'/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute'/$storeId/customers/': typeof AuthenticatedStoreIdCustomersIndexRoute'/$storeId/orders/': typeof AuthenticatedStoreIdOrdersIndexRoute@@ -177,9 +177,9 @@ export interface FileRoutesByTo {'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute- '/$storeId/products/stock': typeof AuthenticatedStoreIdProductsStockRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute'/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute+ '/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute'/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute'/$storeId/customers': typeof AuthenticatedStoreIdCustomersIndexRoute'/$storeId/orders': typeof AuthenticatedStoreIdOrdersIndexRoute@@ -200,9 +200,9 @@ export interface FileRoutesById {'/_authenticated/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute'/_authenticated/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/_authenticated/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute- '/_authenticated/$storeId/products/stock': typeof AuthenticatedStoreIdProductsStockRoute'/_authenticated/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute'/_authenticated/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute+ '/_authenticated/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute'/_authenticated/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute'/_authenticated/$storeId/customers/': typeof AuthenticatedStoreIdCustomersIndexRoute'/_authenticated/$storeId/orders/': typeof AuthenticatedStoreIdOrdersIndexRoute@@ -223,9 +223,9 @@ export interface FileRouteTypes {| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'- | '/$storeId/products/stock'| '/$storeId/settings/api-keys'| '/$storeId/settings/staff'+ | '/$storeId/settings/stock-locations'| '/$storeId/settings/store'| '/$storeId/customers/'| '/$storeId/orders/'@@ -242,9 +242,9 @@ export interface FileRouteTypes {| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'- | '/$storeId/products/stock'| '/$storeId/settings/api-keys'| '/$storeId/settings/staff'+ | '/$storeId/settings/stock-locations'| '/$storeId/settings/store'| '/$storeId/customers'| '/$storeId/orders'@@ -264,9 +264,9 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/orders/drafts'| '/_authenticated/$storeId/orders/new'| '/_authenticated/$storeId/products/$productId'- | '/_authenticated/$storeId/products/stock'| '/_authenticated/$storeId/settings/api-keys'| '/_authenticated/$storeId/settings/staff'+ | '/_authenticated/$storeId/settings/stock-locations'| '/_authenticated/$storeId/settings/store'| '/_authenticated/$storeId/customers/'| '/_authenticated/$storeId/orders/'@@ -366,6 +366,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsStoreRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}+ '/_authenticated/$storeId/settings/stock-locations': {+ id: '/_authenticated/$storeId/settings/stock-locations'+ path: '/stock-locations'+ fullPath: '/$storeId/settings/stock-locations'+ preLoaderRoute: typeof AuthenticatedStoreIdSettingsStockLocationsRouteImport+ parentRoute: typeof AuthenticatedStoreIdSettingsRoute+ }'/_authenticated/$storeId/settings/staff': {id: '/_authenticated/$storeId/settings/staff'path: '/staff'@@ -380,13 +387,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsApiKeysRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}- '/_authenticated/$storeId/products/stock': {- id: '/_authenticated/$storeId/products/stock'- path: '/products/stock'- fullPath: '/$storeId/products/stock'- preLoaderRoute: typeof AuthenticatedStoreIdProductsStockRouteImport- parentRoute: typeof AuthenticatedStoreIdRoute- }'/_authenticated/$storeId/products/$productId': {id: '/_authenticated/$storeId/products/$productId'path: '/products/$productId'@@ -428,6 +428,7 @@ declare module '@tanstack/react-router' {interface AuthenticatedStoreIdSettingsRouteChildren {AuthenticatedStoreIdSettingsApiKeysRoute: typeof AuthenticatedStoreIdSettingsApiKeysRouteAuthenticatedStoreIdSettingsStaffRoute: typeof AuthenticatedStoreIdSettingsStaffRoute+ AuthenticatedStoreIdSettingsStockLocationsRoute: typeof AuthenticatedStoreIdSettingsStockLocationsRouteAuthenticatedStoreIdSettingsStoreRoute: typeof AuthenticatedStoreIdSettingsStoreRouteAuthenticatedStoreIdSettingsIndexRoute: typeof AuthenticatedStoreIdSettingsIndexRoute}@@ -438,6 +439,8 @@ const AuthenticatedStoreIdSettingsRouteChildren: AuthenticatedStoreIdSettingsRouAuthenticatedStoreIdSettingsApiKeysRoute,AuthenticatedStoreIdSettingsStaffRoute:AuthenticatedStoreIdSettingsStaffRoute,+ AuthenticatedStoreIdSettingsStockLocationsRoute:+ AuthenticatedStoreIdSettingsStockLocationsRoute,AuthenticatedStoreIdSettingsStoreRoute:AuthenticatedStoreIdSettingsStoreRoute,AuthenticatedStoreIdSettingsIndexRoute:@@ -457,7 +460,6 @@ interface AuthenticatedStoreIdRouteChildren {AuthenticatedStoreIdOrdersDraftsRoute: typeof AuthenticatedStoreIdOrdersDraftsRouteAuthenticatedStoreIdOrdersNewRoute: typeof AuthenticatedStoreIdOrdersNewRouteAuthenticatedStoreIdProductsProductIdRoute: typeof AuthenticatedStoreIdProductsProductIdRoute- AuthenticatedStoreIdProductsStockRoute: typeof AuthenticatedStoreIdProductsStockRouteAuthenticatedStoreIdCustomersIndexRoute: typeof AuthenticatedStoreIdCustomersIndexRouteAuthenticatedStoreIdOrdersIndexRoute: typeof AuthenticatedStoreIdOrdersIndexRouteAuthenticatedStoreIdProductsIndexRoute: typeof AuthenticatedStoreIdProductsIndexRoute@@ -475,8 +477,6 @@ const AuthenticatedStoreIdRouteChildren: AuthenticatedStoreIdRouteChildren = {AuthenticatedStoreIdOrdersNewRoute: AuthenticatedStoreIdOrdersNewRoute,AuthenticatedStoreIdProductsProductIdRoute:AuthenticatedStoreIdProductsProductIdRoute,- AuthenticatedStoreIdProductsStockRoute:- AuthenticatedStoreIdProductsStockRoute,AuthenticatedStoreIdCustomersIndexRoute:AuthenticatedStoreIdCustomersIndexRoute,AuthenticatedStoreIdOrdersIndexRoute: AuthenticatedStoreIdOrdersIndexRoute,diff --git a/packages/admin/src/routes/_authenticated/$storeId/products/stock.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsxsimilarity index 92%rename from packages/admin/src/routes/_authenticated/$storeId/products/stock.tsxrename to packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsxindex 8c686d71d6..2c68a393fa 100644--- a/packages/admin/src/routes/_authenticated/$storeId/products/stock.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsx@@ -12,6 +12,11 @@ import { z } from 'zod/v4'import { adminClient } from '@/client'import { Can } from '@/components/spree/can'import { useConfirm } from '@/components/spree/confirm-dialog'+import {+ CountryCombobox,+ StateCombobox,+ useCountryStates,+} from '@/components/spree/country-state-fields'import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'import { Button } from '@/components/ui/button'import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'@@ -33,7 +38,6 @@ import {} from '@/components/ui/sheet'import { Switch } from '@/components/ui/switch'import { Textarea } from '@/components/ui/textarea'-import { useCountries } from '@/hooks/use-countries'import {useCreateStockLocation,useDeleteStockLocation,@@ -50,7 +54,7 @@ const stockSearchSchema = resourceSearchSchema.extend({new: z.coerce.boolean().optional(),})-export const Route = createFileRoute('/_authenticated/$storeId/products/stock')({+export const Route = createFileRoute('/_authenticated/$storeId/settings/stock-locations')({validateSearch: stockSearchSchema,component: StockLocationsPage,})@@ -428,11 +432,8 @@ function StockLocationFormFields({// eslint-disable-next-line @typescript-eslint/no-explicit-anyform: any}) {- const { countries, isLoading: countriesLoading } = useCountries()-const countryIso = form.watch('country_iso')- const selectedCountry = countries.find((c) => c.iso === countryIso)- const states = selectedCountry?.states ?? []+ const { states } = useCountryStates(countryIso)const pickupEnabled = form.watch('pickup_enabled')@@ -467,7 +468,7 @@ function StockLocationFormFields({name="kind"control={form.control}render={({ field }) => (- <Select value={field.value} onValueChange={field.onChange}>+ <Select items={KIND_OPTIONS} value={field.value} onValueChange={field.onChange}><SelectTrigger><SelectValue /></SelectTrigger>@@ -535,28 +536,16 @@ function StockLocationFormFields({name="country_iso"control={form.control}render={({ field }) => (- <Select- value={field.value || ''}- onValueChange={(v) => {- field.onChange(v)+ <CountryCombobox+ value={field.value}+ onValueChange={(iso) => {+ field.onChange(iso)// Clear both shapes so a previously-typed free-text state// doesn't bleed across countries.form.setValue('state_abbr', '', { shouldDirty: true })form.setValue('state_name', '', { shouldDirty: true })}}- disabled={countriesLoading}- >- <SelectTrigger>- <SelectValue placeholder="Select a country" />- </SelectTrigger>- <SelectContent className="max-h-80">- {countries.map((c) => (- <SelectItem key={c.iso} value={c.iso}>- {c.name}- </SelectItem>- ))}- </SelectContent>- </Select>+ />)}/></Field>@@ -567,18 +556,12 @@ function StockLocationFormFields({name="state_abbr"control={form.control}render={({ field }) => (- <Select value={field.value || ''} onValueChange={field.onChange}>- <SelectTrigger>- <SelectValue placeholder="Select a state" />- </SelectTrigger>- <SelectContent className="max-h-80">- {states.map((s) => (- <SelectItem key={s.abbr ?? s.name} value={s.abbr ?? ''}>- {s.name}- </SelectItem>- ))}- </SelectContent>- </Select>+ <StateCombobox+ countryIso={countryIso}+ states={states}+ value={field.value}+ onValueChange={field.onChange}+ />)}/></Field>@@ -616,7 +599,11 @@ function StockLocationFormFields({name="pickup_stock_policy"control={form.control}render={({ field }) => (- <Select value={field.value} onValueChange={field.onChange}>+ <Select+ items={PICKUP_POLICY_OPTIONS}+ value={field.value}+ onValueChange={field.onChange}+ ><SelectTrigger><SelectValue /></SelectTrigger>diff --git a/packages/admin/src/routes/_authenticated/$storeId/settings/store.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/store.tsxindex 5a54087e9d..284361d311 100644--- a/packages/admin/src/routes/_authenticated/$storeId/settings/store.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/store.tsx@@ -177,6 +177,7 @@ function StoreSettingsForm({ store }: { store: Store }) {control={form.control}render={({ field }) => (<Select+ items={ADMIN_LOCALE_OPTIONS}value={field.value ?? ''}onValueChange={(v) => field.onChange(v || null)}>@@ -228,7 +229,11 @@ function StoreSettingsForm({ store }: { store: Store }) {name="preferred_unit_system"control={form.control}render={({ field }) => (- <Select value={field.value} onValueChange={field.onChange}>+ <Select+ items={UNIT_SYSTEM_OPTIONS}+ value={field.value}+ onValueChange={field.onChange}+ ><SelectTrigger id="preferred_unit_system"><SelectValue /></SelectTrigger>@@ -249,22 +254,28 @@ function StoreSettingsForm({ store }: { store: Store }) {<Controllername="preferred_weight_unit"control={form.control}- render={({ field }) => (- <Select value={field.value} onValueChange={field.onChange}>- <SelectTrigger id="preferred_weight_unit">- <SelectValue />- </SelectTrigger>- <SelectContent>- {(WEIGHT_UNIT_OPTIONS[unitSystem] ?? WEIGHT_UNIT_OPTIONS.metric).map(- (opt) => (+ render={({ field }) => {+ const weightOptions =+ WEIGHT_UNIT_OPTIONS[unitSystem] ?? WEIGHT_UNIT_OPTIONS.metric+ return (+ <Select+ items={weightOptions}+ value={field.value}+ onValueChange={field.onChange}+ >+ <SelectTrigger id="preferred_weight_unit">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {weightOptions.map((opt) => (<SelectItem key={opt.value} value={opt.value}>{opt.label}</SelectItem>- ),- )}- </SelectContent>- </Select>- )}+ ))}+ </SelectContent>+ </Select>+ )+ }}/></Field></FieldGroup>diff --git a/packages/admin/src/tables/stock-locations.tsx b/packages/admin/src/tables/stock-locations.tsxindex 30896e69e9..361aa691bf 100644--- a/packages/admin/src/tables/stock-locations.tsx+++ b/packages/admin/src/tables/stock-locations.tsx@@ -1,6 +1,7 @@import type { StockLocation } from '@spree/admin-sdk'-import { WarehouseIcon } from 'lucide-react'+import { PencilIcon, WarehouseIcon } from 'lucide-react'import { Badge } from '@/components/ui/badge'+import { Button } from '@/components/ui/button'import { defineTable } from '@/lib/table-registry'defineTable<StockLocation>('stock-locations', {@@ -88,5 +89,24 @@ defineTable<StockLocation>('stock-locations', {filterType: 'boolean',render: (sl) => (sl.default ? <Badge>Default</Badge> : '—'),},+ {+ key: 'actions',+ label: '',+ default: true,+ className: 'w-12 text-right',+ // Same `data-stock-location-id` hook as the Name column — the route's+ // RowClickBridge picks this up and opens the edit Sheet.+ render: (sl) => (+ <Button+ type="button"+ variant="ghost"+ size="icon-sm"+ data-stock-location-id={sl.id}+ aria-label={`Edit ${sl.name}`}+ >+ <PencilIcon data-stock-location-id={sl.id} className="size-4" />+ </Button>+ ),+ },],})