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
Sprint 3 SPA — Tax Categories, Payment Methods, Stock Transfers
Damian Legawiec0abf7555dac6
diff --git a/packages/admin/src/components/spree/row-click-bridge.tsx b/packages/admin/src/components/spree/row-click-bridge.tsxnew file mode 100644index 0000000000..aeac0973df--- /dev/null+++ b/packages/admin/src/components/spree/row-click-bridge.tsx@@ -0,0 +1,17 @@+import { useEffect } from 'react'++export function useRowClickBridge(dataAttribute: string, onClick: (id: string) => void) {+ useEffect(() => {+ function handler(e: MouseEvent) {+ const target = e.target as HTMLElement | null+ const cell = target?.closest(`[${dataAttribute}]`) as HTMLElement | null+ if (!cell) return+ const id = cell.getAttribute(dataAttribute)+ if (!id) return+ e.preventDefault()+ onClick(id)+ }+ document.addEventListener('click', handler)+ return () => document.removeEventListener('click', handler)+ }, [dataAttribute, onClick])+}diff --git a/packages/admin/src/hooks/use-payment-methods.ts b/packages/admin/src/hooks/use-payment-methods.tsnew file mode 100644index 0000000000..58f2b290bf--- /dev/null+++ b/packages/admin/src/hooks/use-payment-methods.ts@@ -0,0 +1,76 @@+import type {+ PaymentMethod,+ PaymentMethodCreateParams,+ PaymentMethodUpdateParams,+} from '@spree/admin-sdk'+import { useQuery, useQueryClient } from '@tanstack/react-query'+import { adminClient } from '@/client'+import { useResourceMutation } from '@/hooks/use-resource-mutation'++export const paymentMethodTypesQueryKey = ['payment-methods', 'types'] as const++export function usePaymentMethodTypes() {+ return useQuery({+ queryKey: paymentMethodTypesQueryKey,+ queryFn: () => adminClient.paymentMethods.types(),+ staleTime: Infinity,+ })+}++export const paymentMethodsQueryKey = ['payment-methods'] as const++export function paymentMethodQueryKey(id: string) {+ return ['payment-methods', id] as const+}++interface UsePaymentMethodsParams {+ page?: number+ limit?: number+}++export function usePaymentMethods({ page = 1, limit = 100 }: UsePaymentMethodsParams = {}) {+ return useQuery({+ queryKey: [...paymentMethodsQueryKey, { page, limit }],+ queryFn: () => adminClient.paymentMethods.list({ page, limit }),+ })+}++export function usePaymentMethod(id: string | undefined) {+ return useQuery({+ queryKey: id ? paymentMethodQueryKey(id) : ['payment-methods', 'noop'],+ queryFn: () => adminClient.paymentMethods.get(id as string),+ enabled: !!id,+ })+}++export function useCreatePaymentMethod() {+ return useResourceMutation<PaymentMethod, Error, PaymentMethodCreateParams>({+ mutationFn: (params) => adminClient.paymentMethods.create(params),+ invalidate: [paymentMethodsQueryKey],+ successMessage: 'Payment method created',+ errorMessage: 'Failed to create payment method',+ })+}++export function useUpdatePaymentMethod(id: string) {+ return useResourceMutation<PaymentMethod, Error, PaymentMethodUpdateParams>({+ mutationFn: (params) => adminClient.paymentMethods.update(id, params),+ invalidate: [paymentMethodsQueryKey, paymentMethodQueryKey(id)],+ successMessage: 'Payment method updated',+ errorMessage: 'Failed to update payment method',+ })+}++export function useDeletePaymentMethod() {+ const queryClient = useQueryClient()++ return useResourceMutation<void, Error, string>({+ mutationFn: (id) => adminClient.paymentMethods.delete(id),+ invalidate: [paymentMethodsQueryKey],+ successMessage: 'Payment method deleted',+ errorMessage: 'Failed to delete payment method',+ onSuccess: (_data, id) => {+ queryClient.removeQueries({ queryKey: paymentMethodQueryKey(id) })+ },+ })+}diff --git a/packages/admin/src/hooks/use-stock-items.ts b/packages/admin/src/hooks/use-stock-items.tsnew file mode 100644index 0000000000..d5e4fe66dc--- /dev/null+++ b/packages/admin/src/hooks/use-stock-items.ts@@ -0,0 +1,58 @@+import type { StockItem, StockItemUpdateParams } from '@spree/admin-sdk'+import { useQuery, useQueryClient } from '@tanstack/react-query'+import { adminClient } from '@/client'+import { useResourceMutation } from '@/hooks/use-resource-mutation'++export const stockItemsQueryKey = ['stock-items'] as const++export function stockItemQueryKey(id: string) {+ return ['stock-items', id] as const+}++interface UseStockItemsParams {+ page?: number+ limit?: number+ stock_location_id_eq?: string+ variant_sku_or_variant_product_name_cont?: string+}++export function useStockItems(params: UseStockItemsParams = {}) {+ return useQuery({+ queryKey: [...stockItemsQueryKey, params],+ queryFn: () =>+ adminClient.stockItems.list({+ page: params.page ?? 1,+ limit: params.limit ?? 25,+ ...(params.stock_location_id_eq && {+ stock_location_id_eq: params.stock_location_id_eq,+ }),+ ...(params.variant_sku_or_variant_product_name_cont && {+ variant_sku_or_variant_product_name_cont: params.variant_sku_or_variant_product_name_cont,+ }),+ }),+ enabled: !!params.stock_location_id_eq,+ })+}++export function useUpdateStockItem(id: string) {+ return useResourceMutation<StockItem, Error, StockItemUpdateParams>({+ mutationFn: (params) => adminClient.stockItems.update(id, params),+ invalidate: [stockItemsQueryKey, stockItemQueryKey(id)],+ successMessage: 'Stock updated',+ errorMessage: 'Failed to update stock',+ })+}++export function useDeleteStockItem() {+ const queryClient = useQueryClient()++ return useResourceMutation<void, Error, string>({+ mutationFn: (id) => adminClient.stockItems.delete(id),+ invalidate: [stockItemsQueryKey],+ successMessage: 'Stock item deleted',+ errorMessage: 'Failed to delete stock item',+ onSuccess: (_data, id) => {+ queryClient.removeQueries({ queryKey: stockItemQueryKey(id) })+ },+ })+}diff --git a/packages/admin/src/hooks/use-stock-transfers.ts b/packages/admin/src/hooks/use-stock-transfers.tsnew file mode 100644index 0000000000..b95773f766--- /dev/null+++ b/packages/admin/src/hooks/use-stock-transfers.ts@@ -0,0 +1,44 @@+import type { StockTransfer, StockTransferCreateParams } from '@spree/admin-sdk'+import { useQuery, useQueryClient } from '@tanstack/react-query'+import { adminClient } from '@/client'+import { useResourceMutation } from '@/hooks/use-resource-mutation'++export const stockTransfersQueryKey = ['stock-transfers'] as const++export function stockTransferQueryKey(id: string) {+ return ['stock-transfers', id] as const+}++export function useStockTransfer(id: string | undefined) {+ return useQuery({+ queryKey: id ? stockTransferQueryKey(id) : ['stock-transfers', 'noop'],+ queryFn: () =>+ adminClient.stockTransfers.get(id as string, {+ expand: ['source_location', 'destination_location'],+ }),+ enabled: !!id,+ })+}++export function useCreateStockTransfer() {+ return useResourceMutation<StockTransfer, Error, StockTransferCreateParams>({+ mutationFn: (params) => adminClient.stockTransfers.create(params),+ invalidate: [stockTransfersQueryKey],+ successMessage: 'Stock transfer recorded',+ errorMessage: 'Failed to record stock transfer',+ })+}++export function useDeleteStockTransfer() {+ const queryClient = useQueryClient()++ return useResourceMutation<void, Error, string>({+ mutationFn: (id) => adminClient.stockTransfers.delete(id),+ invalidate: [stockTransfersQueryKey],+ successMessage: 'Stock transfer deleted',+ errorMessage: 'Failed to delete stock transfer',+ onSuccess: (_data, id) => {+ queryClient.removeQueries({ queryKey: stockTransferQueryKey(id) })+ },+ })+}diff --git a/packages/admin/src/hooks/use-tax-categories.ts b/packages/admin/src/hooks/use-tax-categories.tsindex c46815b6c7..eec80ebff0 100644--- a/packages/admin/src/hooks/use-tax-categories.ts+++ b/packages/admin/src/hooks/use-tax-categories.ts@@ -1,10 +1,67 @@-import { useQuery } from '@tanstack/react-query'+import type {+ TaxCategory,+ TaxCategoryCreateParams,+ TaxCategoryUpdateParams,+} from '@spree/admin-sdk'+import { useQuery, useQueryClient } from '@tanstack/react-query'import { adminClient } from '@/client'+import { useResourceMutation } from '@/hooks/use-resource-mutation'-export function useTaxCategories() {+export const taxCategoriesQueryKey = ['tax-categories'] as const++export function taxCategoryQueryKey(id: string) {+ return ['tax-categories', id] as const+}++interface UseTaxCategoriesParams {+ page?: number+ limit?: number+}++export function useTaxCategories({ page = 1, limit = 100 }: UseTaxCategoriesParams = {}) {return useQuery({- queryKey: ['tax-categories'],- queryFn: () => adminClient.taxCategories.list(),+ queryKey: [...taxCategoriesQueryKey, { page, limit }],+ queryFn: () => adminClient.taxCategories.list({ page, limit }),staleTime: 1000 * 60 * 5,})}++export function useTaxCategory(id: string | undefined) {+ return useQuery({+ queryKey: id ? taxCategoryQueryKey(id) : ['tax-categories', 'noop'],+ queryFn: () => adminClient.taxCategories.get(id as string),+ enabled: !!id,+ })+}++export function useCreateTaxCategory() {+ return useResourceMutation<TaxCategory, Error, TaxCategoryCreateParams>({+ mutationFn: (params) => adminClient.taxCategories.create(params),+ invalidate: [taxCategoriesQueryKey],+ successMessage: 'Tax category created',+ errorMessage: 'Failed to create tax category',+ })+}++export function useUpdateTaxCategory(id: string) {+ return useResourceMutation<TaxCategory, Error, TaxCategoryUpdateParams>({+ mutationFn: (params) => adminClient.taxCategories.update(id, params),+ invalidate: [taxCategoriesQueryKey, taxCategoryQueryKey(id)],+ successMessage: 'Tax category updated',+ errorMessage: 'Failed to update tax category',+ })+}++export function useDeleteTaxCategory() {+ const queryClient = useQueryClient()++ return useResourceMutation<void, Error, string>({+ mutationFn: (id) => adminClient.taxCategories.delete(id),+ invalidate: [taxCategoriesQueryKey],+ successMessage: 'Tax category deleted',+ errorMessage: 'Failed to delete tax category',+ onSuccess: (_data, id) => {+ queryClient.removeQueries({ queryKey: taxCategoryQueryKey(id) })+ },+ })+}diff --git a/packages/admin/src/lib/permissions.ts b/packages/admin/src/lib/permissions.tsindex b2c152024a..0554579278 100644--- a/packages/admin/src/lib/permissions.ts+++ b/packages/admin/src/lib/permissions.ts@@ -21,6 +21,8 @@ export const Subject = {PaymentMethod: 'Spree::PaymentMethod',ShippingMethod: 'Spree::ShippingMethod',StockLocation: 'Spree::StockLocation',+ StockItem: 'Spree::StockItem',+ StockTransfer: 'Spree::StockTransfer',Promotion: 'Spree::Promotion',Wishlist: 'Spree::Wishlist',} as constdiff --git a/packages/admin/src/nav/settings.ts b/packages/admin/src/nav/settings.tsindex 8631eef4af..c3fd6f4cf6 100644--- a/packages/admin/src/nav/settings.ts+++ b/packages/admin/src/nav/settings.ts@@ -1,8 +1,17 @@-import { KeyRoundIcon, StoreIcon, UsersRoundIcon, WarehouseIcon } from 'lucide-react'+import {+ ArrowLeftRightIcon,+ CreditCardIcon,+ KeyRoundIcon,+ PercentIcon,+ 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: 'payments', label: 'Payments & taxes', position: 150 })settingsNav.addGroup({ key: 'fulfillment', label: 'Fulfillment', position: 200 })settingsNav.addGroup({ key: 'team', label: 'Team & access', position: 300 })@@ -16,6 +25,26 @@ settingsNav.add({subject: Subject.Store,})+settingsNav.add({+ key: 'settings.payment-methods',+ label: 'Payment methods',+ path: '/payment-methods',+ icon: CreditCardIcon,+ group: 'payments',+ position: 100,+ subject: Subject.PaymentMethod,+})++settingsNav.add({+ key: 'settings.tax-categories',+ label: 'Tax categories',+ path: '/tax-categories',+ icon: PercentIcon,+ group: 'payments',+ position: 200,+ subject: Subject.TaxCategory,+})+settingsNav.add({key: 'settings.stock-locations',label: 'Stock locations',@@ -26,6 +55,16 @@ settingsNav.add({subject: Subject.StockLocation,})+settingsNav.add({+ key: 'settings.stock-transfers',+ label: 'Stock transfers',+ path: '/stock-transfers',+ icon: ArrowLeftRightIcon,+ group: 'fulfillment',+ position: 200,+ subject: Subject.StockTransfer,+})+settingsNav.add({key: 'settings.staff',label: 'Staff',diff --git a/packages/admin/src/routeTree.gen.ts b/packages/admin/src/routeTree.gen.tsindex cf22fb32cd..915a4d4f3d 100644--- a/packages/admin/src/routeTree.gen.ts+++ b/packages/admin/src/routeTree.gen.ts@@ -20,9 +20,12 @@ import { Route as AuthenticatedStoreIdSettingsIndexRouteImport } from './routes/import { Route as AuthenticatedStoreIdProductsIndexRouteImport } from './routes/_authenticated/$storeId/products/index'import { Route as AuthenticatedStoreIdOrdersIndexRouteImport } from './routes/_authenticated/$storeId/orders/index'import { Route as AuthenticatedStoreIdCustomersIndexRouteImport } from './routes/_authenticated/$storeId/customers/index'+import { Route as AuthenticatedStoreIdSettingsTaxCategoriesRouteImport } from './routes/_authenticated/$storeId/settings/tax-categories'import { Route as AuthenticatedStoreIdSettingsStoreRouteImport } from './routes/_authenticated/$storeId/settings/store'+import { Route as AuthenticatedStoreIdSettingsStockTransfersRouteImport } from './routes/_authenticated/$storeId/settings/stock-transfers'import { Route as AuthenticatedStoreIdSettingsStockLocationsRouteImport } from './routes/_authenticated/$storeId/settings/stock-locations'import { Route as AuthenticatedStoreIdSettingsStaffRouteImport } from './routes/_authenticated/$storeId/settings/staff'+import { Route as AuthenticatedStoreIdSettingsPaymentMethodsRouteImport } from './routes/_authenticated/$storeId/settings/payment-methods'import { Route as AuthenticatedStoreIdSettingsApiKeysRouteImport } from './routes/_authenticated/$storeId/settings/api-keys'import { Route as AuthenticatedStoreIdProductsProductIdRouteImport } from './routes/_authenticated/$storeId/products/$productId'import { Route as AuthenticatedStoreIdOrdersNewRouteImport } from './routes/_authenticated/$storeId/orders/new'@@ -91,12 +94,24 @@ const AuthenticatedStoreIdCustomersIndexRoute =path: '/customers/',getParentRoute: () => AuthenticatedStoreIdRoute,} as any)+const AuthenticatedStoreIdSettingsTaxCategoriesRoute =+ AuthenticatedStoreIdSettingsTaxCategoriesRouteImport.update({+ id: '/tax-categories',+ path: '/tax-categories',+ getParentRoute: () => AuthenticatedStoreIdSettingsRoute,+ } as any)const AuthenticatedStoreIdSettingsStoreRoute =AuthenticatedStoreIdSettingsStoreRouteImport.update({id: '/store',path: '/store',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)+const AuthenticatedStoreIdSettingsStockTransfersRoute =+ AuthenticatedStoreIdSettingsStockTransfersRouteImport.update({+ id: '/stock-transfers',+ path: '/stock-transfers',+ getParentRoute: () => AuthenticatedStoreIdSettingsRoute,+ } as any)const AuthenticatedStoreIdSettingsStockLocationsRoute =AuthenticatedStoreIdSettingsStockLocationsRouteImport.update({id: '/stock-locations',@@ -109,6 +124,12 @@ const AuthenticatedStoreIdSettingsStaffRoute =path: '/staff',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)+const AuthenticatedStoreIdSettingsPaymentMethodsRoute =+ AuthenticatedStoreIdSettingsPaymentMethodsRouteImport.update({+ id: '/payment-methods',+ path: '/payment-methods',+ getParentRoute: () => AuthenticatedStoreIdSettingsRoute,+ } as any)const AuthenticatedStoreIdSettingsApiKeysRoute =AuthenticatedStoreIdSettingsApiKeysRouteImport.update({id: '/api-keys',@@ -159,9 +180,12 @@ export interface FileRoutesByFullPath {'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute'/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute'/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute+ '/$storeId/settings/stock-transfers': typeof AuthenticatedStoreIdSettingsStockTransfersRoute'/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute+ '/$storeId/settings/tax-categories': typeof AuthenticatedStoreIdSettingsTaxCategoriesRoute'/$storeId/customers/': typeof AuthenticatedStoreIdCustomersIndexRoute'/$storeId/orders/': typeof AuthenticatedStoreIdOrdersIndexRoute'/$storeId/products/': typeof AuthenticatedStoreIdProductsIndexRoute@@ -178,9 +202,12 @@ export interface FileRoutesByTo {'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute'/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute'/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute'/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute+ '/$storeId/settings/stock-transfers': typeof AuthenticatedStoreIdSettingsStockTransfersRoute'/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute+ '/$storeId/settings/tax-categories': typeof AuthenticatedStoreIdSettingsTaxCategoriesRoute'/$storeId/customers': typeof AuthenticatedStoreIdCustomersIndexRoute'/$storeId/orders': typeof AuthenticatedStoreIdOrdersIndexRoute'/$storeId/products': typeof AuthenticatedStoreIdProductsIndexRoute@@ -201,9 +228,12 @@ export interface FileRoutesById {'/_authenticated/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute'/_authenticated/$storeId/products/$productId': typeof AuthenticatedStoreIdProductsProductIdRoute'/_authenticated/$storeId/settings/api-keys': typeof AuthenticatedStoreIdSettingsApiKeysRoute+ '/_authenticated/$storeId/settings/payment-methods': typeof AuthenticatedStoreIdSettingsPaymentMethodsRoute'/_authenticated/$storeId/settings/staff': typeof AuthenticatedStoreIdSettingsStaffRoute'/_authenticated/$storeId/settings/stock-locations': typeof AuthenticatedStoreIdSettingsStockLocationsRoute+ '/_authenticated/$storeId/settings/stock-transfers': typeof AuthenticatedStoreIdSettingsStockTransfersRoute'/_authenticated/$storeId/settings/store': typeof AuthenticatedStoreIdSettingsStoreRoute+ '/_authenticated/$storeId/settings/tax-categories': typeof AuthenticatedStoreIdSettingsTaxCategoriesRoute'/_authenticated/$storeId/customers/': typeof AuthenticatedStoreIdCustomersIndexRoute'/_authenticated/$storeId/orders/': typeof AuthenticatedStoreIdOrdersIndexRoute'/_authenticated/$storeId/products/': typeof AuthenticatedStoreIdProductsIndexRoute@@ -224,9 +254,12 @@ export interface FileRouteTypes {| '/$storeId/orders/new'| '/$storeId/products/$productId'| '/$storeId/settings/api-keys'+ | '/$storeId/settings/payment-methods'| '/$storeId/settings/staff'| '/$storeId/settings/stock-locations'+ | '/$storeId/settings/stock-transfers'| '/$storeId/settings/store'+ | '/$storeId/settings/tax-categories'| '/$storeId/customers/'| '/$storeId/orders/'| '/$storeId/products/'@@ -243,9 +276,12 @@ export interface FileRouteTypes {| '/$storeId/orders/new'| '/$storeId/products/$productId'| '/$storeId/settings/api-keys'+ | '/$storeId/settings/payment-methods'| '/$storeId/settings/staff'| '/$storeId/settings/stock-locations'+ | '/$storeId/settings/stock-transfers'| '/$storeId/settings/store'+ | '/$storeId/settings/tax-categories'| '/$storeId/customers'| '/$storeId/orders'| '/$storeId/products'@@ -265,9 +301,12 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/orders/new'| '/_authenticated/$storeId/products/$productId'| '/_authenticated/$storeId/settings/api-keys'+ | '/_authenticated/$storeId/settings/payment-methods'| '/_authenticated/$storeId/settings/staff'| '/_authenticated/$storeId/settings/stock-locations'+ | '/_authenticated/$storeId/settings/stock-transfers'| '/_authenticated/$storeId/settings/store'+ | '/_authenticated/$storeId/settings/tax-categories'| '/_authenticated/$storeId/customers/'| '/_authenticated/$storeId/orders/'| '/_authenticated/$storeId/products/'@@ -359,6 +398,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdCustomersIndexRouteImportparentRoute: typeof AuthenticatedStoreIdRoute}+ '/_authenticated/$storeId/settings/tax-categories': {+ id: '/_authenticated/$storeId/settings/tax-categories'+ path: '/tax-categories'+ fullPath: '/$storeId/settings/tax-categories'+ preLoaderRoute: typeof AuthenticatedStoreIdSettingsTaxCategoriesRouteImport+ parentRoute: typeof AuthenticatedStoreIdSettingsRoute+ }'/_authenticated/$storeId/settings/store': {id: '/_authenticated/$storeId/settings/store'path: '/store'@@ -366,6 +412,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsStoreRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}+ '/_authenticated/$storeId/settings/stock-transfers': {+ id: '/_authenticated/$storeId/settings/stock-transfers'+ path: '/stock-transfers'+ fullPath: '/$storeId/settings/stock-transfers'+ preLoaderRoute: typeof AuthenticatedStoreIdSettingsStockTransfersRouteImport+ parentRoute: typeof AuthenticatedStoreIdSettingsRoute+ }'/_authenticated/$storeId/settings/stock-locations': {id: '/_authenticated/$storeId/settings/stock-locations'path: '/stock-locations'@@ -380,6 +433,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsStaffRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}+ '/_authenticated/$storeId/settings/payment-methods': {+ id: '/_authenticated/$storeId/settings/payment-methods'+ path: '/payment-methods'+ fullPath: '/$storeId/settings/payment-methods'+ preLoaderRoute: typeof AuthenticatedStoreIdSettingsPaymentMethodsRouteImport+ parentRoute: typeof AuthenticatedStoreIdSettingsRoute+ }'/_authenticated/$storeId/settings/api-keys': {id: '/_authenticated/$storeId/settings/api-keys'path: '/api-keys'@@ -427,9 +487,12 @@ declare module '@tanstack/react-router' {interface AuthenticatedStoreIdSettingsRouteChildren {AuthenticatedStoreIdSettingsApiKeysRoute: typeof AuthenticatedStoreIdSettingsApiKeysRoute+ AuthenticatedStoreIdSettingsPaymentMethodsRoute: typeof AuthenticatedStoreIdSettingsPaymentMethodsRouteAuthenticatedStoreIdSettingsStaffRoute: typeof AuthenticatedStoreIdSettingsStaffRouteAuthenticatedStoreIdSettingsStockLocationsRoute: typeof AuthenticatedStoreIdSettingsStockLocationsRoute+ AuthenticatedStoreIdSettingsStockTransfersRoute: typeof AuthenticatedStoreIdSettingsStockTransfersRouteAuthenticatedStoreIdSettingsStoreRoute: typeof AuthenticatedStoreIdSettingsStoreRoute+ AuthenticatedStoreIdSettingsTaxCategoriesRoute: typeof AuthenticatedStoreIdSettingsTaxCategoriesRouteAuthenticatedStoreIdSettingsIndexRoute: typeof AuthenticatedStoreIdSettingsIndexRoute}@@ -437,12 +500,18 @@ const AuthenticatedStoreIdSettingsRouteChildren: AuthenticatedStoreIdSettingsRou{AuthenticatedStoreIdSettingsApiKeysRoute:AuthenticatedStoreIdSettingsApiKeysRoute,+ AuthenticatedStoreIdSettingsPaymentMethodsRoute:+ AuthenticatedStoreIdSettingsPaymentMethodsRoute,AuthenticatedStoreIdSettingsStaffRoute:AuthenticatedStoreIdSettingsStaffRoute,AuthenticatedStoreIdSettingsStockLocationsRoute:AuthenticatedStoreIdSettingsStockLocationsRoute,+ AuthenticatedStoreIdSettingsStockTransfersRoute:+ AuthenticatedStoreIdSettingsStockTransfersRoute,AuthenticatedStoreIdSettingsStoreRoute:AuthenticatedStoreIdSettingsStoreRoute,+ AuthenticatedStoreIdSettingsTaxCategoriesRoute:+ AuthenticatedStoreIdSettingsTaxCategoriesRoute,AuthenticatedStoreIdSettingsIndexRoute:AuthenticatedStoreIdSettingsIndexRoute,}diff --git a/packages/admin/src/routes/_authenticated/$storeId/settings/payment-methods.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/payment-methods.tsxnew file mode 100644index 0000000000..9acafc4920--- /dev/null+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/payment-methods.tsx@@ -0,0 +1,459 @@+import { zodResolver } from '@hookform/resolvers/zod'+import type {+ PaymentMethod,+ PaymentMethodCreateParams,+ PaymentMethodDisplayOn,+ PaymentMethodUpdateParams,+} from '@spree/admin-sdk'+import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { PlusIcon } from 'lucide-react'+import { useEffect } from 'react'+import { Controller, useForm } from 'react-hook-form'+import { z } from 'zod/v4'+import { adminClient } from '@/client'+import { Can } from '@/components/spree/can'+import { useConfirm } from '@/components/spree/confirm-dialog'+import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'+import { useRowClickBridge } from '@/components/spree/row-click-bridge'+import { Button } from '@/components/ui/button'+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'+import { Input } from '@/components/ui/input'+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@/components/ui/select'+import {+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from '@/components/ui/sheet'+import { Switch } from '@/components/ui/switch'+import { Textarea } from '@/components/ui/textarea'+import {+ useCreatePaymentMethod,+ useDeletePaymentMethod,+ usePaymentMethod,+ usePaymentMethodTypes,+ useUpdatePaymentMethod,+} from '@/hooks/use-payment-methods'+import { Subject } from '@/lib/permissions'+import '@/tables/payment-methods'++const paymentMethodsSearchSchema = resourceSearchSchema.extend({+ edit: z.string().optional(),+ new: z.coerce.boolean().optional(),+})++export const Route = createFileRoute('/_authenticated/$storeId/settings/payment-methods')({+ validateSearch: paymentMethodsSearchSchema,+ component: PaymentMethodsPage,+})++const DISPLAY_ON_OPTIONS: { value: PaymentMethodDisplayOn; label: string }[] = [+ { value: 'both', label: 'Storefront + Admin' },+ { value: 'front_end', label: 'Storefront only' },+ { value: 'back_end', label: 'Admin only' },+]++function PaymentMethodsPage() {+ const search = Route.useSearch() as z.infer<typeof paymentMethodsSearchSchema>+ const navigate = useNavigate()++ const editId = search.edit+ const isCreating = !!search.new++ const closeSheet = () =>+ navigate({+ search: (prev: Record<string, unknown>) => {+ const { edit: _e, new: _n, ...rest } = prev+ return rest as never+ },+ })++ const openCreate = () =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })++ const openEdit = (id: string) =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, edit: id }) as never })++ useRowClickBridge('data-payment-method-id', openEdit)++ return (+ <>+ <ResourceTable<PaymentMethod>+ tableKey="payment-methods"+ queryKey="payment-methods"+ queryFn={(params) => adminClient.paymentMethods.list(params)}+ searchParams={search}+ actions={+ <Can I="create" a={Subject.PaymentMethod}>+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>+ <PlusIcon className="size-4" />+ Add payment method+ </Button>+ </Can>+ }+ />++ {isCreating && <CreatePaymentMethodSheet open onOpenChange={(o) => !o && closeSheet()} />}+ {editId && (+ <EditPaymentMethodSheet id={editId} open onOpenChange={(o) => !o && closeSheet()} />+ )}+ </>+ )+}++const baseFormSchema = z.object({+ name: z.string().min(1, 'Name is required'),+ description: z.string().optional(),+ display_on: z.enum(['both', 'front_end', 'back_end']),+ active: z.boolean(),+ auto_capture: z.boolean(),+ position: z.coerce.number().int().nonnegative().optional(),+})++const createFormSchema = baseFormSchema.extend({+ type: z.string().min(1, 'Pick a provider'),+})++type BaseFormValues = z.infer<typeof baseFormSchema>+type CreateFormValues = z.infer<typeof createFormSchema>++const BASE_DEFAULTS: BaseFormValues = {+ name: '',+ description: '',+ display_on: 'both',+ active: true,+ auto_capture: false,+ position: undefined,+}++const CREATE_DEFAULTS: CreateFormValues = { ...BASE_DEFAULTS, type: '' }++function valuesToCreateParams(v: CreateFormValues): PaymentMethodCreateParams {+ return {+ type: v.type,+ name: v.name,+ description: v.description?.length ? v.description : null,+ active: v.active,+ auto_capture: v.auto_capture,+ display_on: v.display_on,+ position: v.position,+ }+}++function valuesToUpdateParams(v: BaseFormValues): PaymentMethodUpdateParams {+ return {+ name: v.name,+ description: v.description?.length ? v.description : null,+ active: v.active,+ auto_capture: v.auto_capture,+ display_on: v.display_on,+ position: v.position,+ }+}++function CreatePaymentMethodSheet({+ open,+ onOpenChange,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const createMutation = useCreatePaymentMethod()+ const { data: typesResponse, isLoading: loadingTypes } = usePaymentMethodTypes()+ const providerTypes = typesResponse?.data ?? []++ const form = useForm<CreateFormValues>({+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ resolver: zodResolver(createFormSchema) as any,+ defaultValues: CREATE_DEFAULTS,+ })++ async function onSubmit(values: CreateFormValues) {+ await createMutation.mutateAsync(valuesToCreateParams(values))+ form.reset(CREATE_DEFAULTS)+ onOpenChange(false)+ }++ return (+ <Sheet+ open={open}+ onOpenChange={(next) => {+ if (!next) form.reset(CREATE_DEFAULTS)+ onOpenChange(next)+ }}+ >+ <SheetContent>+ <SheetHeader>+ <SheetTitle>Add payment method</SheetTitle>+ <SheetDescription>+ Pick a provider to register a new payment method. Provider-specific configuration is+ edited after the method is created.+ </SheetDescription>+ </SheetHeader>+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">+ <Field>+ <FieldLabel htmlFor="type">Provider</FieldLabel>+ <Controller+ name="type"+ control={form.control}+ render={({ field }) => (+ <Select value={field.value} onValueChange={field.onChange}>+ <SelectTrigger id="type" aria-invalid={!!form.formState.errors.type}>+ <SelectValue placeholder={loadingTypes ? 'Loading…' : 'Select a provider'} />+ </SelectTrigger>+ <SelectContent>+ {providerTypes.map((t) => (+ <SelectItem key={t.type} value={t.type}>+ {t.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}+ />+ {form.formState.errors.type && (+ <p className="text-sm text-destructive">{form.formState.errors.type.message}</p>+ )}+ </Field>++ <PaymentMethodFormFields form={form} />+ </div>+ <SheetFooter>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => onOpenChange(false)}+ disabled={form.formState.isSubmitting}+ >+ Cancel+ </Button>+ <Button type="submit" size="sm" disabled={form.formState.isSubmitting}>+ {form.formState.isSubmitting ? 'Creating…' : 'Create payment method'}+ </Button>+ </SheetFooter>+ </form>+ </SheetContent>+ </Sheet>+ )+}++function EditPaymentMethodSheet({+ id,+ open,+ onOpenChange,+}: {+ id: string+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { data: paymentMethod, isLoading } = usePaymentMethod(id)+ const updateMutation = useUpdatePaymentMethod(id)+ const deleteMutation = useDeletePaymentMethod()+ const confirm = useConfirm()++ const form = useForm<BaseFormValues>({+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ resolver: zodResolver(baseFormSchema) as any,+ defaultValues: BASE_DEFAULTS,+ })++ useEffect(() => {+ if (paymentMethod) {+ form.reset({+ name: paymentMethod.name,+ description: paymentMethod.description ?? '',+ display_on: (paymentMethod.display_on as PaymentMethodDisplayOn) ?? 'both',+ active: paymentMethod.active,+ auto_capture: paymentMethod.auto_capture ?? false,+ position: paymentMethod.position ?? undefined,+ })+ }+ }, [paymentMethod, form])++ async function onSubmit(values: BaseFormValues) {+ await updateMutation.mutateAsync(valuesToUpdateParams(values))+ form.reset(values)+ onOpenChange(false)+ }++ async function onDelete() {+ const ok = await confirm({+ title: 'Delete payment method?',+ message: `${paymentMethod?.name ?? 'This payment method'} will be removed. Existing payments referencing it remain intact.`,+ variant: 'destructive',+ confirmLabel: 'Delete',+ })+ if (!ok) return+ await deleteMutation.mutateAsync(id)+ onOpenChange(false)+ }++ const providerLabel =+ paymentMethod?.type?.replace(/^Spree::PaymentMethod::/, '') ?? paymentMethod?.type++ return (+ <Sheet open={open} onOpenChange={onOpenChange}>+ <SheetContent>+ <SheetHeader>+ <SheetTitle>{paymentMethod?.name ?? 'Edit payment method'}</SheetTitle>+ <SheetDescription>+ {providerLabel ? `Provider: ${providerLabel}` : 'Update name, visibility, or status.'}+ </SheetDescription>+ </SheetHeader>+ {isLoading ? (+ <div className="p-4 text-sm text-muted-foreground">Loading…</div>+ ) : (+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">+ <PaymentMethodFormFields form={form} />+ </div>+ <SheetFooter>+ <Can I="destroy" a={Subject.PaymentMethod}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={onDelete}+ disabled={form.formState.isSubmitting || deleteMutation.isPending}+ className="mr-auto text-destructive hover:bg-destructive/10 hover:text-destructive"+ >+ Delete+ </Button>+ </Can>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => onOpenChange(false)}+ disabled={form.formState.isSubmitting}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ size="sm"+ disabled={form.formState.isSubmitting || !form.formState.isDirty}+ >+ {form.formState.isSubmitting ? 'Saving…' : 'Save'}+ </Button>+ </SheetFooter>+ </form>+ )}+ </SheetContent>+ </Sheet>+ )+}++function PaymentMethodFormFields({+ form,+}: {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ form: any+}) {+ return (+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="name">Name</FieldLabel>+ <Input+ id="name"+ placeholder="e.g. Credit card (Stripe)"+ {...form.register('name')}+ aria-invalid={!!form.formState.errors.name}+ />+ {form.formState.errors.name && (+ <p className="text-sm text-destructive">{form.formState.errors.name.message}</p>+ )}+ </Field>++ <Field>+ <FieldLabel htmlFor="description">Description</FieldLabel>+ <Textarea+ id="description"+ rows={2}+ placeholder="Customer-facing description shown at checkout"+ {...form.register('description')}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="display_on">Visible on</FieldLabel>+ <Controller+ name="display_on"+ control={form.control}+ render={({ field }) => (+ <Select value={field.value} onValueChange={field.onChange}>+ <SelectTrigger id="display_on">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {DISPLAY_ON_OPTIONS.map((o) => (+ <SelectItem key={o.value} value={o.value}>+ {o.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="position">Position</FieldLabel>+ <Input id="position" type="number" min={0} placeholder="0" {...form.register('position')} />+ <span className="text-xs text-muted-foreground">+ Lower numbers appear first in the checkout list.+ </span>+ </Field>++ <Field>+ <div className="flex items-start justify-between gap-4">+ <div className="flex flex-col">+ <FieldLabel htmlFor="active" className="cursor-pointer">+ Active+ </FieldLabel>+ <span className="text-xs text-muted-foreground">+ Inactive methods are hidden from checkout.+ </span>+ </div>+ <Controller+ name="active"+ control={form.control}+ render={({ field }) => (+ <Switch id="active" checked={!!field.value} onCheckedChange={field.onChange} />+ )}+ />+ </div>+ </Field>++ <Field>+ <div className="flex items-start justify-between gap-4">+ <div className="flex flex-col">+ <FieldLabel htmlFor="auto_capture" className="cursor-pointer">+ Auto-capture+ </FieldLabel>+ <span className="text-xs text-muted-foreground">+ Capture funds automatically on authorization. When off, you must capture manually.+ </span>+ </div>+ <Controller+ name="auto_capture"+ control={form.control}+ render={({ field }) => (+ <Switch id="auto_capture" checked={!!field.value} onCheckedChange={field.onChange} />+ )}+ />+ </div>+ </Field>+ </FieldGroup>+ )+}diff --git a/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsxindex 2c68a393fa..42872eea19 100644--- a/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-locations.tsx@@ -1,12 +1,13 @@import { zodResolver } from '@hookform/resolvers/zod'import type {+ StockItem,StockLocation,StockLocationCreateParams,StockLocationUpdateParams,} from '@spree/admin-sdk'import { createFileRoute, useNavigate } from '@tanstack/react-router'import { PlusIcon } from 'lucide-react'-import { useEffect } from 'react'+import { useEffect, useState } from 'react'import { Controller, useForm } from 'react-hook-form'import { z } from 'zod/v4'import { adminClient } from '@/client'@@ -38,6 +39,7 @@ import {} from '@/components/ui/sheet'import { Switch } from '@/components/ui/switch'import { Textarea } from '@/components/ui/textarea'+import { useStockItems, useUpdateStockItem } from '@/hooks/use-stock-items'import {useCreateStockLocation,useDeleteStockLocation,@@ -384,6 +386,7 @@ function EditStockLocationSheet({<form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col"><div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4"><StockLocationFormFields form={form} />+ <StockItemsPanel stockLocationId={id} /></div><SheetFooter><Can I="destroy" a={Subject.StockLocation}>@@ -422,6 +425,143 @@ function EditStockLocationSheet({)}+// ============================================================================+// Stock Items panel — adjust on-hand counts at this location+// ============================================================================++function StockItemsPanel({ stockLocationId }: { stockLocationId: string }) {+ const [search, setSearch] = useState('')+ const [page, setPage] = useState(1)+ const { data, isFetching } = useStockItems({+ stock_location_id_eq: stockLocationId,+ variant_sku_or_variant_product_name_cont: search.length >= 2 ? search : undefined,+ page,+ limit: 10,+ })+ const items = data?.data ?? []+ const totalPages = data?.meta?.pages ?? 1++ return (+ <div className="rounded-md border">+ <div className="flex items-center justify-between gap-2 border-b px-4 py-3">+ <div>+ <h3 className="text-sm font-medium">Stock at this location</h3>+ <p className="text-xs text-muted-foreground">+ Adjust on-hand counts and backorderable status per variant.+ </p>+ </div>+ <Input+ placeholder="Search SKU or product…"+ value={search}+ onChange={(e) => {+ setSearch(e.target.value)+ setPage(1)+ }}+ className="h-8 w-56"+ />+ </div>+ {isFetching && items.length === 0 ? (+ <div className="px-4 py-6 text-sm text-muted-foreground">Loading…</div>+ ) : items.length === 0 ? (+ <div className="px-4 py-6 text-sm text-muted-foreground">+ No stock items {search ? 'match your search' : 'at this location yet'}.+ </div>+ ) : (+ <div className="divide-y">+ {items.map((item) => (+ <StockItemRow key={item.id} item={item} />+ ))}+ </div>+ )}+ {totalPages > 1 && (+ <div className="flex items-center justify-between border-t px-4 py-2">+ <span className="text-xs text-muted-foreground">+ Page {page} of {totalPages}+ </span>+ <div className="flex gap-1">+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => setPage((p) => Math.max(1, p - 1))}+ disabled={page === 1 || isFetching}+ >+ Prev+ </Button>+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => setPage((p) => Math.min(totalPages, p + 1))}+ disabled={page === totalPages || isFetching}+ >+ Next+ </Button>+ </div>+ </div>+ )}+ </div>+ )+}++function StockItemRow({ item }: { item: StockItem }) {+ const updateMutation = useUpdateStockItem(item.id)+ const [count, setCount] = useState<number>(item.count_on_hand)+ const [backorderable, setBackorderable] = useState<boolean>(item.backorderable)++ // Sync local state when the underlying item changes (e.g. cache refresh).+ useEffect(() => {+ setCount(item.count_on_hand)+ setBackorderable(item.backorderable)+ }, [item.count_on_hand, item.backorderable])++ const dirty = count !== item.count_on_hand || backorderable !== item.backorderable+ const variant = item.variant+ const label = variant?.product_name ?? variant?.sku ?? item.variant_id ?? 'Unknown variant'++ function save() {+ if (!dirty) return+ updateMutation.mutate({ count_on_hand: count, backorderable })+ }++ return (+ <div className="flex items-center gap-3 px-4 py-3">+ <div className="min-w-0 flex-1">+ <div className="truncate text-sm font-medium">{label}</div>+ {variant?.sku && (+ <div className="truncate text-xs text-muted-foreground">SKU {variant.sku}</div>+ )}+ </div>+ <div className="flex items-center gap-2">+ <span className="flex items-center gap-1.5 text-xs text-muted-foreground">+ <Switch+ checked={backorderable}+ onCheckedChange={setBackorderable}+ aria-label="Backorderable"+ />+ Backorder+ </span>+ <Input+ type="number"+ value={count}+ onChange={(e) => setCount(Number(e.target.value))}+ className="w-20 text-right"+ aria-label="Count on hand"+ />+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={save}+ disabled={!dirty || updateMutation.isPending}+ >+ {updateMutation.isPending ? '…' : 'Save'}+ </Button>+ </div>+ </div>+ )+}+// ============================================================================// Shared form fields// ============================================================================diff --git a/packages/admin/src/routes/_authenticated/$storeId/settings/stock-transfers.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-transfers.tsxnew file mode 100644index 0000000000..1de4ac4096--- /dev/null+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/stock-transfers.tsx@@ -0,0 +1,471 @@+import type { StockTransfer, Variant } from '@spree/admin-sdk'+import { useQuery } from '@tanstack/react-query'+import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { ArrowLeftRightIcon, PlusIcon, TrashIcon } from 'lucide-react'+import { useMemo, useState } from 'react'+import { z } from 'zod/v4'+import { adminClient } from '@/client'+import { Can } from '@/components/spree/can'+import { useConfirm } from '@/components/spree/confirm-dialog'+import { RelativeTime } from '@/components/spree/relative-time'+import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'+import { useRowClickBridge } from '@/components/spree/row-click-bridge'+import { Badge } from '@/components/ui/badge'+import { Button } from '@/components/ui/button'+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'+import { Input } from '@/components/ui/input'+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@/components/ui/select'+import {+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from '@/components/ui/sheet'+import { useStockLocations } from '@/hooks/use-stock-locations'+import {+ useCreateStockTransfer,+ useDeleteStockTransfer,+ useStockTransfer,+} from '@/hooks/use-stock-transfers'+import { Subject } from '@/lib/permissions'+import '@/tables/stock-transfers'++const stockTransfersSearchSchema = resourceSearchSchema.extend({+ view: z.string().optional(),+ new: z.coerce.boolean().optional(),+})++export const Route = createFileRoute('/_authenticated/$storeId/settings/stock-transfers')({+ validateSearch: stockTransfersSearchSchema,+ component: StockTransfersPage,+})++const SOURCE_NONE = '__external__'++function StockTransfersPage() {+ const search = Route.useSearch() as z.infer<typeof stockTransfersSearchSchema>+ const navigate = useNavigate()++ const viewId = search.view+ const isCreating = !!search.new++ const closeSheet = () =>+ navigate({+ search: (prev: Record<string, unknown>) => {+ const { view: _v, new: _n, ...rest } = prev+ return rest as never+ },+ })++ const openCreate = () =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })++ const openView = (id: string) =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, view: id }) as never })++ useRowClickBridge('data-stock-transfer-id', openView)++ return (+ <>+ <ResourceTable<StockTransfer>+ tableKey="stock-transfers"+ queryKey="stock-transfers"+ queryFn={(params) => adminClient.stockTransfers.list(params)}+ searchParams={search}+ actions={+ <Can I="create" a={Subject.StockTransfer}>+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>+ <PlusIcon className="size-4" />+ New transfer+ </Button>+ </Can>+ }+ />++ {isCreating && <CreateStockTransferSheet open onOpenChange={(o) => !o && closeSheet()} />}+ {viewId && (+ <ViewStockTransferSheet id={viewId} open onOpenChange={(o) => !o && closeSheet()} />+ )}+ </>+ )+}++interface PendingItem {+ variant: Variant+ quantity: number+}++function CreateStockTransferSheet({+ open,+ onOpenChange,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const createMutation = useCreateStockTransfer()+ const { data: stockLocations } = useStockLocations({ limit: 100 })+ const locations = stockLocations?.data ?? []++ const [sourceId, setSourceId] = useState<string>(SOURCE_NONE)+ const [destinationId, setDestinationId] = useState<string>('')+ const [reference, setReference] = useState('')+ const [items, setItems] = useState<PendingItem[]>([])+ const [variantSearch, setVariantSearch] = useState('')++ const { data: variantsData } = useQuery({+ queryKey: ['variants', 'search', variantSearch],+ queryFn: () => adminClient.variants.list({ search: variantSearch, limit: 8 }),+ enabled: variantSearch.length >= 3,+ staleTime: 30_000,+ })+ const variantResults = variantsData?.data ?? []++ const isExternalReceive = sourceId === SOURCE_NONE+ const canSubmit =+ !!destinationId &&+ items.length > 0 &&+ items.every((i) => i.quantity > 0) &&+ (isExternalReceive || sourceId !== destinationId)++ function reset() {+ setSourceId(SOURCE_NONE)+ setDestinationId('')+ setReference('')+ setItems([])+ setVariantSearch('')+ }++ function addItem(variant: Variant) {+ const existing = items.find((i) => i.variant.id === variant.id)+ if (existing) {+ setItems(+ items.map((i) => (i.variant.id === variant.id ? { ...i, quantity: i.quantity + 1 } : i)),+ )+ } else {+ setItems([...items, { variant, quantity: 1 }])+ }+ setVariantSearch('')+ }++ function updateQuantity(variantId: string, quantity: number) {+ setItems(items.map((i) => (i.variant.id === variantId ? { ...i, quantity } : i)))+ }++ function removeItem(variantId: string) {+ setItems(items.filter((i) => i.variant.id !== variantId))+ }++ async function handleSubmit() {+ if (!canSubmit) return+ await createMutation.mutateAsync({+ source_location_id: isExternalReceive ? undefined : sourceId,+ destination_location_id: destinationId,+ reference: reference.length > 0 ? reference : undefined,+ variants: items.map((i) => ({ variant_id: i.variant.id, quantity: i.quantity })),+ })+ reset()+ onOpenChange(false)+ }++ return (+ <Sheet+ open={open}+ onOpenChange={(next) => {+ if (!next) reset()+ onOpenChange(next)+ }}+ >+ <SheetContent className="sm:max-w-2xl">+ <SheetHeader>+ <SheetTitle>New stock transfer</SheetTitle>+ <SheetDescription>+ Move stock between locations, or omit a source to record an external receive.+ </SheetDescription>+ </SheetHeader>+ <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4">+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="source">Source</FieldLabel>+ <Select value={sourceId} onValueChange={setSourceId}>+ <SelectTrigger id="source">+ <SelectValue>+ {(value) =>+ value === SOURCE_NONE+ ? 'External (vendor receive)'+ : (locations.find((l) => l.id === value)?.name ?? (value as string))+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={SOURCE_NONE}>External (vendor receive)</SelectItem>+ {locations.map((l) => (+ <SelectItem key={l.id} value={l.id}>+ {l.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>++ <Field>+ <FieldLabel htmlFor="destination">Destination</FieldLabel>+ <Select value={destinationId} onValueChange={setDestinationId}>+ <SelectTrigger id="destination">+ <SelectValue placeholder="Select destination location">+ {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {locations+ .filter((l) => l.id !== sourceId)+ .map((l) => (+ <SelectItem key={l.id} value={l.id}>+ {l.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ {sourceId !== SOURCE_NONE && sourceId === destinationId && (+ <p className="text-sm text-destructive">Source and destination must differ.</p>+ )}+ </Field>++ <Field>+ <FieldLabel htmlFor="reference">Reference (optional)</FieldLabel>+ <Input+ id="reference"+ placeholder="Vendor PO, invoice, or internal note"+ value={reference}+ onChange={(e) => setReference(e.target.value)}+ />+ </Field>++ <Field>+ <FieldLabel>Variants</FieldLabel>+ <Input+ placeholder="Search by name or SKU (3+ chars)…"+ value={variantSearch}+ onChange={(e) => setVariantSearch(e.target.value)}+ />+ {variantSearch.length >= 3 && variantResults.length > 0 && (+ <div className="mt-1 rounded-lg border border-border bg-popover text-popover-foreground shadow-xs max-h-[280px] overflow-y-auto">+ {variantResults.map((v) => (+ <button+ key={v.id}+ type="button"+ onClick={() => addItem(v)}+ className="block w-full px-3 py-2.5 text-left text-sm hover:bg-muted transition-colors border-b last:border-0"+ >+ <div className="font-medium">{v.product_name ?? v.sku ?? v.id}</div>+ <div className="text-xs text-muted-foreground">+ SKU {v.sku} · {v.display_price ?? '—'}+ </div>+ </button>+ ))}+ </div>+ )}+ </Field>+ </FieldGroup>++ {items.length > 0 && (+ <div className="overflow-x-auto rounded-md border">+ <table className="w-full text-sm">+ <thead>+ <tr className="border-b bg-muted/50 text-muted-foreground">+ <th className="p-3 pl-5 text-left font-normal">Variant</th>+ <th className="p-3 text-left font-normal">SKU</th>+ <th className="p-3 text-right font-normal">Qty</th>+ <th className="p-3 pr-5 w-10" />+ </tr>+ </thead>+ <tbody>+ {items.map(({ variant, quantity }) => (+ <tr key={variant.id} className="border-b last:border-b-0">+ <td className="p-3 pl-5 font-medium">+ {variant.product_name ?? variant.sku ?? variant.id}+ </td>+ <td className="p-3 text-muted-foreground">{variant.sku}</td>+ <td className="p-3 text-right">+ <Input+ type="number"+ min={1}+ value={quantity}+ onChange={(e) => updateQuantity(variant.id, Number(e.target.value))}+ className="w-20 text-right ml-auto"+ />+ </td>+ <td className="p-3 pr-5 text-right">+ <Button+ type="button"+ size="icon-xs"+ variant="ghost"+ onClick={() => removeItem(variant.id)}+ >+ <TrashIcon className="size-4" />+ </Button>+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ )}+ </div>+ <SheetFooter>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => onOpenChange(false)}+ disabled={createMutation.isPending}+ >+ Cancel+ </Button>+ <Button+ type="button"+ size="sm"+ onClick={handleSubmit}+ disabled={!canSubmit || createMutation.isPending}+ >+ {createMutation.isPending ? 'Recording…' : 'Record transfer'}+ </Button>+ </SheetFooter>+ </SheetContent>+ </Sheet>+ )+}++function ViewStockTransferSheet({+ id,+ open,+ onOpenChange,+}: {+ id: string+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { data: transfer, isLoading } = useStockTransfer(id)+ const deleteMutation = useDeleteStockTransfer()+ const confirm = useConfirm()+ const { data: stockLocations } = useStockLocations({ limit: 100 })++ const locationsById = useMemo(() => {+ const map = new Map<string, string>()+ for (const l of stockLocations?.data ?? []) {+ map.set(l.id, l.name)+ }+ return map+ }, [stockLocations])++ async function onDelete() {+ const ok = await confirm({+ title: 'Delete stock transfer?',+ message:+ 'Deleting a transfer reverses the stock movements. Use with caution — this is mostly for fixing erroneous entries.',+ variant: 'destructive',+ confirmLabel: 'Delete',+ })+ if (!ok) return+ await deleteMutation.mutateAsync(id)+ onOpenChange(false)+ }++ const sourceName = transfer?.source_location_id+ ? (locationsById.get(transfer.source_location_id) ?? transfer.source_location_id)+ : null+ const destinationName = transfer?.destination_location_id+ ? (locationsById.get(transfer.destination_location_id) ?? transfer.destination_location_id)+ : null++ return (+ <Sheet open={open} onOpenChange={onOpenChange}>+ <SheetContent className="sm:max-w-xl">+ <SheetHeader>+ <SheetTitle>{transfer ? `Transfer ${transfer.number}` : 'Stock transfer'}</SheetTitle>+ <SheetDescription>+ {transfer?.source_location_id ? (+ <>+ Inventory moved from <span className="font-medium">{sourceName}</span> to{' '}+ <span className="font-medium">{destinationName}</span>.+ </>+ ) : (+ <>+ External receive into <span className="font-medium">{destinationName}</span>.+ </>+ )}+ </SheetDescription>+ </SheetHeader>++ {isLoading || !transfer ? (+ <div className="p-4 text-sm text-muted-foreground">Loading…</div>+ ) : (+ <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4">+ <Card>+ <CardHeader>+ <CardTitle>Details</CardTitle>+ </CardHeader>+ <CardContent>+ <dl className="grid grid-cols-3 gap-y-2 text-sm">+ <dt className="text-muted-foreground">Type</dt>+ <dd className="col-span-2">+ {transfer.source_location_id ? (+ <Badge variant="outline">+ <ArrowLeftRightIcon className="size-3" /> Internal+ </Badge>+ ) : (+ <Badge variant="outline">External receive</Badge>+ )}+ </dd>++ {transfer.reference && (+ <>+ <dt className="text-muted-foreground">Reference</dt>+ <dd className="col-span-2">{transfer.reference}</dd>+ </>+ )}++ <dt className="text-muted-foreground">Created</dt>+ <dd className="col-span-2">+ <RelativeTime iso={transfer.created_at} />+ </dd>+ </dl>+ </CardContent>+ </Card>++ <p className="text-xs text-muted-foreground">+ Stock transfers are immutable once recorded. Deleting the transfer reverses its stock+ movements.+ </p>+ </div>+ )}++ <SheetFooter>+ <Can I="destroy" a={Subject.StockTransfer}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={onDelete}+ disabled={deleteMutation.isPending}+ className="mr-auto text-destructive hover:bg-destructive/10 hover:text-destructive"+ >+ Delete+ </Button>+ </Can>+ <Button type="button" variant="outline" size="sm" onClick={() => onOpenChange(false)}>+ Close+ </Button>+ </SheetFooter>+ </SheetContent>+ </Sheet>+ )+}diff --git a/packages/admin/src/routes/_authenticated/$storeId/settings/tax-categories.tsx b/packages/admin/src/routes/_authenticated/$storeId/settings/tax-categories.tsxnew file mode 100644index 0000000000..e25dd696c6--- /dev/null+++ b/packages/admin/src/routes/_authenticated/$storeId/settings/tax-categories.tsx@@ -0,0 +1,339 @@+import { zodResolver } from '@hookform/resolvers/zod'+import type {+ TaxCategory,+ TaxCategoryCreateParams,+ TaxCategoryUpdateParams,+} from '@spree/admin-sdk'+import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { PlusIcon } from 'lucide-react'+import { useEffect } from 'react'+import { Controller, useForm } from 'react-hook-form'+import { z } from 'zod/v4'+import { adminClient } from '@/client'+import { Can } from '@/components/spree/can'+import { useConfirm } from '@/components/spree/confirm-dialog'+import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'+import { useRowClickBridge } from '@/components/spree/row-click-bridge'+import { Button } from '@/components/ui/button'+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'+import { Input } from '@/components/ui/input'+import {+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from '@/components/ui/sheet'+import { Switch } from '@/components/ui/switch'+import { Textarea } from '@/components/ui/textarea'+import {+ useCreateTaxCategory,+ useDeleteTaxCategory,+ useTaxCategory,+ useUpdateTaxCategory,+} from '@/hooks/use-tax-categories'+import { Subject } from '@/lib/permissions'+import '@/tables/tax-categories'++const taxCategoriesSearchSchema = resourceSearchSchema.extend({+ edit: z.string().optional(),+ new: z.coerce.boolean().optional(),+})++export const Route = createFileRoute('/_authenticated/$storeId/settings/tax-categories')({+ validateSearch: taxCategoriesSearchSchema,+ component: TaxCategoriesPage,+})++function TaxCategoriesPage() {+ const search = Route.useSearch() as z.infer<typeof taxCategoriesSearchSchema>+ const navigate = useNavigate()++ const editId = search.edit+ const isCreating = !!search.new++ const closeSheet = () =>+ navigate({+ search: (prev: Record<string, unknown>) => {+ const { edit: _e, new: _n, ...rest } = prev+ return rest as never+ },+ })++ const openCreate = () =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })++ const openEdit = (id: string) =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, edit: id }) as never })++ useRowClickBridge('data-tax-category-id', openEdit)++ return (+ <>+ <ResourceTable<TaxCategory>+ tableKey="tax-categories"+ queryKey="tax-categories"+ queryFn={(params) => adminClient.taxCategories.list(params)}+ searchParams={search}+ actions={+ <Can I="create" a={Subject.TaxCategory}>+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>+ <PlusIcon className="size-4" />+ Add tax category+ </Button>+ </Can>+ }+ />++ {isCreating && <CreateTaxCategorySheet open onOpenChange={(o) => !o && closeSheet()} />}+ {editId && <EditTaxCategorySheet id={editId} open onOpenChange={(o) => !o && closeSheet()} />}+ </>+ )+}++const formSchema = z.object({+ name: z.string().min(1, 'Name is required'),+ tax_code: z.string().optional(),+ description: z.string().optional(),+ is_default: z.boolean(),+})++type FormValues = z.infer<typeof formSchema>++const DEFAULT_VALUES: FormValues = { name: '', tax_code: '', description: '', is_default: false }++function valuesToParams(v: FormValues): TaxCategoryCreateParams & TaxCategoryUpdateParams {+ const blank = (s: string | undefined) => (s && s.length > 0 ? s : undefined)+ return {+ name: v.name,+ tax_code: blank(v.tax_code) ?? null,+ description: blank(v.description) ?? null,+ is_default: v.is_default,+ }+}++function CreateTaxCategorySheet({+ open,+ onOpenChange,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const createMutation = useCreateTaxCategory()+ const form = useForm<FormValues>({+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ resolver: zodResolver(formSchema) as any,+ defaultValues: DEFAULT_VALUES,+ })++ async function onSubmit(values: FormValues) {+ await createMutation.mutateAsync(valuesToParams(values) as TaxCategoryCreateParams)+ form.reset(DEFAULT_VALUES)+ onOpenChange(false)+ }++ return (+ <Sheet+ open={open}+ onOpenChange={(next) => {+ if (!next) form.reset(DEFAULT_VALUES)+ onOpenChange(next)+ }}+ >+ <SheetContent>+ <SheetHeader>+ <SheetTitle>Add tax category</SheetTitle>+ <SheetDescription>+ Tax categories classify products for rate calculation. Setting one as the default+ demotes the previous default.+ </SheetDescription>+ </SheetHeader>+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">+ <TaxCategoryFormFields form={form} />+ </div>+ <SheetFooter>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => onOpenChange(false)}+ disabled={form.formState.isSubmitting}+ >+ Cancel+ </Button>+ <Button type="submit" size="sm" disabled={form.formState.isSubmitting}>+ {form.formState.isSubmitting ? 'Creating…' : 'Create tax category'}+ </Button>+ </SheetFooter>+ </form>+ </SheetContent>+ </Sheet>+ )+}++function EditTaxCategorySheet({+ id,+ open,+ onOpenChange,+}: {+ id: string+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { data: taxCategory, isLoading } = useTaxCategory(id)+ const updateMutation = useUpdateTaxCategory(id)+ const deleteMutation = useDeleteTaxCategory()+ const confirm = useConfirm()++ const form = useForm<FormValues>({+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ resolver: zodResolver(formSchema) as any,+ defaultValues: DEFAULT_VALUES,+ })++ useEffect(() => {+ if (taxCategory) {+ form.reset({+ name: taxCategory.name,+ tax_code: taxCategory.tax_code ?? '',+ description: taxCategory.description ?? '',+ is_default: taxCategory.is_default,+ })+ }+ }, [taxCategory, form])++ async function onSubmit(values: FormValues) {+ await updateMutation.mutateAsync(valuesToParams(values))+ form.reset(values)+ onOpenChange(false)+ }++ async function onDelete() {+ const ok = await confirm({+ title: 'Delete tax category?',+ message: `${taxCategory?.name ?? 'This category'} will be removed. Products and tax rates referencing it will lose the assignment.`,+ variant: 'destructive',+ confirmLabel: 'Delete',+ })+ if (!ok) return+ await deleteMutation.mutateAsync(id)+ onOpenChange(false)+ }++ return (+ <Sheet open={open} onOpenChange={onOpenChange}>+ <SheetContent>+ <SheetHeader>+ <SheetTitle>{taxCategory?.name ?? 'Edit tax category'}</SheetTitle>+ <SheetDescription>Update name, tax code, or default flag.</SheetDescription>+ </SheetHeader>+ {isLoading ? (+ <div className="p-4 text-sm text-muted-foreground">Loading…</div>+ ) : (+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">+ <TaxCategoryFormFields form={form} />+ </div>+ <SheetFooter>+ <Can I="destroy" a={Subject.TaxCategory}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={onDelete}+ disabled={form.formState.isSubmitting || deleteMutation.isPending}+ className="mr-auto text-destructive hover:bg-destructive/10 hover:text-destructive"+ >+ Delete+ </Button>+ </Can>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => onOpenChange(false)}+ disabled={form.formState.isSubmitting}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ size="sm"+ disabled={form.formState.isSubmitting || !form.formState.isDirty}+ >+ {form.formState.isSubmitting ? 'Saving…' : 'Save'}+ </Button>+ </SheetFooter>+ </form>+ )}+ </SheetContent>+ </Sheet>+ )+}++function TaxCategoryFormFields({+ form,+}: {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ form: any+}) {+ return (+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="name">Name</FieldLabel>+ <Input+ id="name"+ autoFocus+ placeholder="e.g. Reduced rate"+ {...form.register('name')}+ aria-invalid={!!form.formState.errors.name}+ />+ {form.formState.errors.name && (+ <p className="text-sm text-destructive">{form.formState.errors.name.message}</p>+ )}+ </Field>++ <Field>+ <FieldLabel htmlFor="tax_code">Tax code</FieldLabel>+ <Input+ id="tax_code"+ placeholder="External tax provider code (Avalara, etc.)"+ {...form.register('tax_code')}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="description">Description</FieldLabel>+ <Textarea+ id="description"+ rows={3}+ placeholder="Optional internal description"+ {...form.register('description')}+ />+ </Field>++ <Field>+ <div className="flex items-start justify-between gap-4">+ <div className="flex flex-col">+ <FieldLabel htmlFor="is_default" className="cursor-pointer">+ Default+ </FieldLabel>+ <span className="text-xs text-muted-foreground">+ Setting this demotes the previous default. Products without an explicit category fall+ back to this one.+ </span>+ </div>+ <Controller+ name="is_default"+ control={form.control}+ render={({ field }) => (+ <Switch id="is_default" checked={!!field.value} onCheckedChange={field.onChange} />+ )}+ />+ </div>+ </Field>+ </FieldGroup>+ )+}diff --git a/packages/admin/src/tables/payment-methods.tsx b/packages/admin/src/tables/payment-methods.tsxnew file mode 100644index 0000000000..29e22c2e05--- /dev/null+++ b/packages/admin/src/tables/payment-methods.tsx@@ -0,0 +1,73 @@+import type { PaymentMethod } from '@spree/admin-sdk'+import { CreditCardIcon } from 'lucide-react'+import { Badge } from '@/components/ui/badge'+import { defineTable } from '@/lib/table-registry'++defineTable<PaymentMethod>('payment-methods', {+ title: 'Payment Methods',+ searchParam: 'name_cont',+ searchPlaceholder: 'Search by name…',+ defaultSort: { field: 'position', direction: 'asc' },+ emptyIcon: <CreditCardIcon className="size-8 text-muted-foreground/50" />,+ emptyMessage: 'No payment methods configured',+ columns: [+ {+ key: 'name',+ label: 'Name',+ sortable: true,+ filterable: true,+ default: true,+ render: (pm) => (+ <button+ type="button"+ data-payment-method-id={pm.id}+ className="flex flex-col items-start text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"+ >+ <span className="font-medium">{pm.name}</span>+ {pm.description && (+ <span data-payment-method-id={pm.id} className="text-xs text-muted-foreground">+ {pm.description}+ </span>+ )}+ </button>+ ),+ },+ {+ key: 'type',+ label: 'Provider',+ sortable: true,+ filterable: true,+ default: true,+ // The STI subclass name is verbose ("Spree::PaymentMethod::Check"); strip+ // the namespace + class prefix so the table reads "Check" / "BogusGateway".+ render: (pm) => pm.type.replace(/^Spree::PaymentMethod::/, ''),+ },+ {+ key: 'display_on',+ label: 'Visible on',+ filterable: true,+ default: true,+ render: (pm) => {+ if (pm.display_on === 'both') return 'Storefront + Admin'+ if (pm.display_on === 'front_end') return 'Storefront only'+ if (pm.display_on === 'back_end') return 'Admin only'+ return pm.display_on+ },+ },+ {+ key: 'active',+ label: 'Status',+ filterable: true,+ default: true,+ filterType: 'boolean',+ render: (pm) =>+ pm.active ? (+ <Badge variant="outline">Active</Badge>+ ) : (+ <Badge variant="outline" className="text-muted-foreground">+ Disabled+ </Badge>+ ),+ },+ ],+})diff --git a/packages/admin/src/tables/stock-transfers.tsx b/packages/admin/src/tables/stock-transfers.tsxnew file mode 100644index 0000000000..4c57f4cb5f--- /dev/null+++ b/packages/admin/src/tables/stock-transfers.tsx@@ -0,0 +1,59 @@+import type { StockTransfer } from '@spree/admin-sdk'+import { ArrowLeftRightIcon } from 'lucide-react'+import { RelativeTime } from '@/components/spree/relative-time'+import { Badge } from '@/components/ui/badge'+import { defineTable } from '@/lib/table-registry'++defineTable<StockTransfer>('stock-transfers', {+ title: 'Stock Transfers',+ searchParam: 'number_cont',+ searchPlaceholder: 'Search by number or reference…',+ defaultSort: { field: 'created_at', direction: 'desc' },+ emptyIcon: <ArrowLeftRightIcon className="size-8 text-muted-foreground/50" />,+ emptyMessage: 'No stock transfers yet',+ columns: [+ {+ key: 'number',+ label: 'Number',+ sortable: true,+ filterable: true,+ default: true,+ render: (st) => (+ <button+ type="button"+ data-stock-transfer-id={st.id}+ className="font-medium tabular-nums hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"+ >+ {st.number}+ </button>+ ),+ },+ {+ key: 'source_destination',+ label: 'Direction',+ default: true,+ render: (st) =>+ st.source_location_id ? (+ <span className="text-sm">Transfer between locations</span>+ ) : (+ <Badge variant="outline">External receive</Badge>+ ),+ },+ {+ key: 'reference',+ label: 'Reference',+ filterable: true,+ default: true,+ render: (st) => st.reference ?? '—',+ },+ {+ key: 'created_at',+ label: 'Date',+ sortable: true,+ default: true,+ filterType: 'date',+ className: 'text-sm text-muted-foreground whitespace-nowrap',+ render: (st) => <RelativeTime iso={st.created_at} />,+ },+ ],+})diff --git a/packages/admin/src/tables/tax-categories.tsx b/packages/admin/src/tables/tax-categories.tsxnew file mode 100644index 0000000000..ade1ac3e06--- /dev/null+++ b/packages/admin/src/tables/tax-categories.tsx@@ -0,0 +1,50 @@+import type { TaxCategory } from '@spree/admin-sdk'+import { PercentIcon } from 'lucide-react'+import { Badge } from '@/components/ui/badge'+import { defineTable } from '@/lib/table-registry'++defineTable<TaxCategory>('tax-categories', {+ title: 'Tax Categories',+ searchParam: 'name_cont',+ searchPlaceholder: 'Search by name…',+ defaultSort: { field: 'name', direction: 'asc' },+ emptyIcon: <PercentIcon className="size-8 text-muted-foreground/50" />,+ emptyMessage: 'No tax categories yet',+ columns: [+ {+ key: 'name',+ label: 'Name',+ sortable: true,+ filterable: true,+ default: true,+ render: (tc) => (+ <button+ type="button"+ data-tax-category-id={tc.id}+ className="flex flex-col items-start text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"+ >+ <span className="font-medium">{tc.name}</span>+ {tc.description && (+ <span data-tax-category-id={tc.id} className="text-xs text-muted-foreground">+ {tc.description}+ </span>+ )}+ </button>+ ),+ },+ {+ key: 'tax_code',+ label: 'Tax code',+ sortable: true,+ filterable: true,+ default: true,+ render: (tc) => tc.tax_code ?? '—',+ },+ {+ key: 'is_default',+ label: 'Default',+ default: true,+ render: (tc) => (tc.is_default ? <Badge variant="outline">Default</Badge> : null),+ },+ ],+})