Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Rebuild the dashboard for the organization tree and add catalog pages

Damian Legawiecb6a0a1fa7d3e
diff --git a/packages/dashboard-core/src/components/page-tabs.tsx b/packages/dashboard-core/src/components/page-tabs.tsx
index 071c92216d..11c5d4ad6d 100644
--- a/packages/dashboard-core/src/components/page-tabs.tsx
+++ b/packages/dashboard-core/src/components/page-tabs.tsx
@@ -48,7 +48,10 @@ export function PageTabs({ tabs, slotName = 'page.tabs', slotContext, className
const target =
typeof tab.to === 'string'
? tab.to
- : router.buildLocation({ to: tab.to, params: tab.params, search: tab.search }).pathname
+ : // Same literal-route caveat as the <Link> below: `to` is unknown
+ // at this generic call site.
+ router.buildLocation({ to: tab.to as never, params: tab.params, search: tab.search })
+ .pathname
const active =
tab.match === 'prefix'
? location.pathname.startsWith(target)
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.ts
index 89989e70a0..100fc4fe04 100644
--- a/packages/dashboard-core/src/lib/permissions.ts
+++ b/packages/dashboard-core/src/lib/permissions.ts
@@ -33,8 +33,10 @@ export const Subject = {
TaxIdentifier: 'Spree::TaxIdentifier',
TaxExemptionCertificate: 'Spree::TaxExemptionCertificate',
Company: 'Spree::Company',
- CompanyLocation: 'Spree::CompanyLocation',
- CompanyContact: 'Spree::CompanyContact',
+ CompanyAddress: 'Spree::CompanyAddress',
+ CompanyMembership: 'Spree::CompanyMembership',
+ CompanyInvitation: 'Spree::CompanyInvitation',
+ Catalog: 'Spree::Catalog',
ReturnReason: 'Spree::ReturnReason',
ClaimReason: 'Spree::ClaimReason',
RefundReason: 'Spree::RefundReason',
diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.json
index dce652937f..63e11dc163 100644
--- a/packages/dashboard-core/src/locales/ar.json
+++ b/packages/dashboard-core/src/locales/ar.json
@@ -136,6 +136,7 @@
"no_color": "بدون لون"
},
"common": {
+ "active": "نشط",
"adjust_search_or_filters": "جرّب تعديل البحث أو عوامل التصفية",
"all": "الكل",
"and": "و",
@@ -147,6 +148,7 @@
"delete_confirm_message": "هل أنت متأكد؟ لا يمكن التراجع عن هذا الإجراء.",
"deleted": "تم الحذف",
"empty_value": "—",
+ "inactive": "غير نشط",
"loading": "جارٍ التحميل…",
"next": "التالي",
"no": "لا",
@@ -188,6 +190,8 @@
"heading": "إنشاء",
"label": "إنشاء {{noun}}",
"nouns": {
+ "catalog": "كتالوج",
+ "catalog_plural": "كتالوجات",
"category": "فئة",
"category_plural": "الفئات",
"collection": "مجموعة",
diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.json
index 16acc38cdf..dfb8e49810 100644
--- a/packages/dashboard-core/src/locales/de.json
+++ b/packages/dashboard-core/src/locales/de.json
@@ -136,6 +136,7 @@
"no_color": "Keine Farbe"
},
"common": {
+ "active": "Aktiv",
"adjust_search_or_filters": "Passen Sie Ihre Suche oder Filter an",
"all": "Alle",
"and": "und",
@@ -147,6 +148,7 @@
"delete_confirm_message": "Sind Sie sicher? Diese Aktion kann nicht rückgängig gemacht werden.",
"deleted": "Gelöscht",
"empty_value": "—",
+ "inactive": "Inaktiv",
"loading": "Wird geladen…",
"next": "Weiter",
"no": "Nein",
@@ -188,6 +190,8 @@
"heading": "Erstellen",
"label": "Neu: {{noun}}",
"nouns": {
+ "catalog": "Katalog",
+ "catalog_plural": "Kataloge",
"category": "Kategorie",
"category_plural": "Kategorien",
"collection": "Kollektion",
diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.json
index 4433f31738..8e481ec63c 100644
--- a/packages/dashboard-core/src/locales/en.json
+++ b/packages/dashboard-core/src/locales/en.json
@@ -136,6 +136,7 @@
"no_color": "No color"
},
"common": {
+ "active": "Active",
"adjust_search_or_filters": "Try adjusting your search or filters",
"all": "All",
"and": "and",
@@ -147,6 +148,7 @@
"delete_confirm_message": "Are you sure? This action cannot be undone.",
"deleted": "Deleted",
"empty_value": "—",
+ "inactive": "Inactive",
"loading": "Loading…",
"next": "Next",
"no": "No",
@@ -188,6 +190,8 @@
"heading": "Create",
"label": "New {{noun}}",
"nouns": {
+ "catalog": "Catalog",
+ "catalog_plural": "Catalogs",
"category": "Category",
"category_plural": "Categories",
"collection": "Collection",
diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.json
index fdc607bfb4..73d132c5c2 100644
--- a/packages/dashboard-core/src/locales/fr.json
+++ b/packages/dashboard-core/src/locales/fr.json
@@ -136,6 +136,7 @@
"no_color": "Aucune couleur"
},
"common": {
+ "active": "Actif",
"adjust_search_or_filters": "Essayez d’ajuster votre recherche ou vos filtres",
"all": "Tout",
"and": "et",
@@ -147,6 +148,7 @@
"delete_confirm_message": "Êtes-vous sûr ? Cette action est irréversible.",
"deleted": "Supprimé",
"empty_value": "—",
+ "inactive": "Inactif",
"loading": "Chargement…",
"next": "Suivant",
"no": "Non",
@@ -188,6 +190,8 @@
"heading": "Créer",
"label": "Créer : {{noun}}",
"nouns": {
+ "catalog": "Catalogue",
+ "catalog_plural": "Catalogues",
"category": "Catégorie",
"category_plural": "Catégories",
"collection": "Collection",
diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.json
index 5a00565b78..6fdd6f3e7e 100644
--- a/packages/dashboard-core/src/locales/pl.json
+++ b/packages/dashboard-core/src/locales/pl.json
@@ -136,6 +136,7 @@
"no_color": "Brak koloru"
},
"common": {
+ "active": "Aktywny",
"adjust_search_or_filters": "Spróbuj dostosować wyszukiwanie lub filtry",
"all": "Wszystkie",
"and": "i",
@@ -147,6 +148,7 @@
"delete_confirm_message": "Czy na pewno? Tej operacji nie można cofnąć.",
"deleted": "Usunięto",
"empty_value": "—",
+ "inactive": "Nieaktywny",
"loading": "Ładowanie…",
"next": "Następna",
"no": "Nie",
@@ -188,6 +190,8 @@
"heading": "Utwórz",
"label": "Utwórz: {{noun}}",
"nouns": {
+ "catalog": "Katalog",
+ "catalog_plural": "Katalogi",
"category": "Kategoria",
"category_plural": "Kategorie",
"collection": "Kolekcja",
diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.json
index 88929a0074..c8c661415c 100644
--- a/packages/dashboard-core/src/locales/zh-CN.json
+++ b/packages/dashboard-core/src/locales/zh-CN.json
@@ -136,6 +136,7 @@
"no_color": "无颜色"
},
"common": {
+ "active": "启用",
"adjust_search_or_filters": "请尝试调整搜索或筛选条件",
"all": "全部",
"and": "和",
@@ -147,6 +148,7 @@
"delete_confirm_message": "确定吗?此操作无法撤销。",
"deleted": "已删除",
"empty_value": "—",
+ "inactive": "停用",
"loading": "加载中…",
"next": "下一页",
"no": "否",
@@ -188,6 +190,8 @@
"heading": "创建",
"label": "新建{{noun}}",
"nouns": {
+ "catalog": "目录",
+ "catalog_plural": "目录",
"category": "分类",
"category_plural": "分类",
"collection": "系列",
diff --git a/packages/dashboard/src/components/spree/company-address-sheet.tsx b/packages/dashboard/src/components/spree/company-address-sheet.tsx
new file mode 100644
index 0000000000..45fc0fc3c8
--- /dev/null
+++ b/packages/dashboard/src/components/spree/company-address-sheet.tsx
@@ -0,0 +1,194 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import type { CompanyAddress } from '@spree/admin-sdk'
+import { mapSpreeErrorsToForm } from '@spree/dashboard-core'
+import {
+ Button,
+ Checkbox,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+} from '@spree/dashboard-ui'
+import { useEffect } from 'react'
+import { Controller, useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import { useCreateCompanyAddress, useUpdateCompanyAddress } from '../../hooks/use-companies'
+import {
+ COMPANY_ADDRESS_DEFAULTS,
+ type CompanyAddressFormValues,
+ companyAddressFormSchema,
+ companyAddressValuesToParams,
+} from '../../schemas/company'
+import { AddressFieldset } from './address-fieldset'
+
+/**
+ * Creates an entry in a company node's address book, or edits one. The entry
+ * owns its address row outright; promoting it to a default demotes the prior
+ * default of the same kind.
+ */
+export function CompanyAddressSheet({
+ companyId,
+ entry,
+ open,
+ onOpenChange,
+}: {
+ companyId: string
+ entry?: CompanyAddress
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const createMutation = useCreateCompanyAddress(companyId)
+ const updateMutation = useUpdateCompanyAddress(companyId)
+
+ const form = useForm<CompanyAddressFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(companyAddressFormSchema) as any,
+ defaultValues: COMPANY_ADDRESS_DEFAULTS,
+ })
+
+ useEffect(() => {
+ if (!open) return
+ if (!entry) {
+ form.reset(COMPANY_ADDRESS_DEFAULTS)
+ return
+ }
+
+ form.reset({
+ label: entry.label ?? '',
+ default_billing: entry.default_billing,
+ default_shipping: entry.default_shipping,
+ address: {
+ first_name: entry.address?.first_name ?? '',
+ last_name: entry.address?.last_name ?? '',
+ company: entry.address?.company ?? '',
+ address1: entry.address?.address1 ?? '',
+ address2: entry.address?.address2 ?? '',
+ city: entry.address?.city ?? '',
+ postal_code: entry.address?.postal_code ?? '',
+ phone: entry.address?.phone ?? '',
+ country_code: entry.address?.country_code ?? '',
+ state_code: entry.address?.state_code ?? '',
+ },
+ })
+ }, [open, entry, form])
+
+ async function onSubmit(values: CompanyAddressFormValues) {
+ try {
+ const params = companyAddressValuesToParams(values)
+ if (entry) {
+ await updateMutation.mutateAsync({ id: entry.id, params })
+ } else {
+ await createMutation.mutateAsync(params)
+ }
+ onOpenChange(false)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ const { errors } = form.formState
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent className="sm:max-w-xl">
+ <SheetHeader>
+ <SheetTitle>
+ {entry
+ ? t('admin.company_addresses.edit_sheet_title')
+ : t('admin.company_addresses.add_sheet_title')}
+ </SheetTitle>
+ <SheetDescription>{t('admin.company_addresses.sheet_description')}</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">
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-destructive text-sm" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+
+ <Field>
+ <FieldLabel htmlFor="company-address-label">
+ {t('admin.fields.company_address.label.label')}
+ </FieldLabel>
+ <Input
+ id="company-address-label"
+ autoFocus
+ placeholder={t('admin.fields.company_address.label.placeholder')}
+ aria-invalid={!!errors.label || undefined}
+ {...form.register('label')}
+ />
+ <FieldDescription>{t('admin.fields.company_address.label.help')}</FieldDescription>
+ <FieldError errors={[errors.label]} />
+ </Field>
+
+ <AddressFieldset
+ form={form}
+ prefix="address"
+ legend={t('admin.company_addresses.address_legend')}
+ />
+
+ <Controller
+ control={form.control}
+ name="default_billing"
+ render={({ field }) => (
+ <label
+ htmlFor="company-address-default-billing"
+ className="flex items-center gap-2 text-sm"
+ >
+ <Checkbox
+ id="company-address-default-billing"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ {t('admin.company_addresses.default_billing_label')}
+ </label>
+ )}
+ />
+ <Controller
+ control={form.control}
+ name="default_shipping"
+ render={({ field }) => (
+ <label
+ htmlFor="company-address-default-shipping"
+ className="flex items-center gap-2 text-sm"
+ >
+ <Checkbox
+ id="company-address-default-shipping"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ {t('admin.company_addresses.default_shipping_label')}
+ </label>
+ )}
+ />
+ </FieldGroup>
+ </div>
+ <SheetFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" disabled={form.formState.isSubmitting}>
+ {form.formState.isSubmitting ? t('admin.actions.saving') : t('admin.actions.save')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/company-kind-badge.tsx b/packages/dashboard/src/components/spree/company-kind-badge.tsx
new file mode 100644
index 0000000000..a73bcac071
--- /dev/null
+++ b/packages/dashboard/src/components/spree/company-kind-badge.tsx
@@ -0,0 +1,13 @@
+import { Badge } from '@spree/dashboard-ui'
+import { useTranslation } from 'react-i18next'
+
+/** Legal entity vs organizational unit — the two node kinds, fixed. */
+export function CompanyKindBadge({ kind }: { kind: string }) {
+ const { t } = useTranslation()
+
+ return (
+ <Badge variant={kind === 'company' ? 'outline' : 'secondary'}>
+ {kind === 'company' ? t('admin.companies.kind.company') : t('admin.companies.kind.division')}
+ </Badge>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/company-location-sheet.tsx b/packages/dashboard/src/components/spree/company-location-sheet.tsx
deleted file mode 100644
index 31d8934627..0000000000
--- a/packages/dashboard/src/components/spree/company-location-sheet.tsx
+++ /dev/null
@@ -1,198 +0,0 @@
-import { zodResolver } from '@hookform/resolvers/zod'
-import type { CompanyLocation } from '@spree/admin-sdk'
-import { mapSpreeErrorsToForm } from '@spree/dashboard-core'
-import {
- Button,
- Checkbox,
- Field,
- FieldError,
- FieldGroup,
- FieldLabel,
- Input,
- Sheet,
- SheetContent,
- SheetDescription,
- SheetFooter,
- SheetHeader,
- SheetTitle,
-} from '@spree/dashboard-ui'
-import { useEffect } from 'react'
-import { Controller, useForm } from 'react-hook-form'
-import { useTranslation } from 'react-i18next'
-import { useCreateCompanyLocation, useUpdateCompanyLocation } from '../../hooks/use-companies'
-import {
- addressesMatch,
- COMPANY_LOCATION_DEFAULTS,
- type CompanyLocationFormValues,
- companyLocationFormSchema,
- companyLocationValuesToParams,
-} from '../../schemas/company'
-import { AddressFieldset } from './address-fieldset'
-
-/**
- * Creates a branch under a company, or edits one addressed by its own id. A
- * branch carries both a billing and a shipping address because the business
- * it is invoiced at is not always where the goods go.
- */
-export function CompanyLocationSheet({
- companyId,
- location,
- open,
- onOpenChange,
-}: {
- companyId: string
- location?: CompanyLocation
- open: boolean
- onOpenChange: (open: boolean) => void
-}) {
- const { t } = useTranslation()
- const createMutation = useCreateCompanyLocation(companyId)
- const updateMutation = useUpdateCompanyLocation(location?.id ?? '', companyId)
-
- const form = useForm<CompanyLocationFormValues>({
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- resolver: zodResolver(companyLocationFormSchema) as any,
- defaultValues: COMPANY_LOCATION_DEFAULTS,
- })
-
- useEffect(() => {
- if (!open) return
- if (!location) {
- form.reset(COMPANY_LOCATION_DEFAULTS)
- return
- }
-
- const billing = addressToForm(location.billing_address)
- const shipping = addressToForm(location.shipping_address)
- form.reset({
- name: location.name,
- billing_address: billing,
- shipping_address: shipping,
- // A branch saved with matching addresses reopens with the box ticked, so
- // editing the billing address keeps carrying both.
- shipping_same_as_billing: addressesMatch(billing, shipping),
- })
- }, [open, location, form])
-
- const sameAsBilling = form.watch('shipping_same_as_billing')
-
- async function handleSubmit(values: CompanyLocationFormValues) {
- try {
- const params = companyLocationValuesToParams(values)
- if (location) {
- await updateMutation.mutateAsync(params)
- } else {
- await createMutation.mutateAsync(params)
- }
- onOpenChange(false)
- } catch (err) {
- if (!mapSpreeErrorsToForm(err, form.setError)) throw err
- }
- }
-
- const { errors } = form.formState
-
- return (
- <Sheet open={open} onOpenChange={onOpenChange}>
- <SheetContent className="sm:max-w-2xl">
- <SheetHeader>
- <SheetTitle>
- {location
- ? t('admin.company_locations.edit_title')
- : t('admin.company_locations.add_title')}
- </SheetTitle>
- <SheetDescription>{t('admin.company_locations.dialog_description')}</SheetDescription>
- </SheetHeader>
- <form
- onSubmit={(event) => {
- form.handleSubmit(handleSubmit)(event)
- event.stopPropagation()
- }}
- className="flex min-h-0 flex-1 flex-col"
- >
- <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
- <FieldGroup>
- {errors.root?.message && (
- <p className="text-destructive text-sm" role="alert">
- {errors.root.message}
- </p>
- )}
-
- <Field>
- <FieldLabel htmlFor="location-name">{t('admin.fields.name.label')}</FieldLabel>
- <Input
- id="location-name"
- autoFocus
- placeholder={t('admin.fields.company_location.name.placeholder')}
- aria-invalid={!!errors.name || undefined}
- {...form.register('name')}
- />
- <FieldError errors={[errors.name]} />
- </Field>
-
- <AddressFieldset
- form={form}
- prefix="billing_address"
- legend={t('admin.company_locations.billing_address')}
- />
-
- <Controller
- name="shipping_same_as_billing"
- control={form.control}
- render={({ field }) => (
- <label
- htmlFor="shipping-same-as-billing"
- className="flex cursor-pointer items-center gap-2 text-sm"
- >
- <Checkbox
- id="shipping-same-as-billing"
- checked={!!field.value}
- onCheckedChange={field.onChange}
- />
- {t('admin.company_locations.shipping_same_as_billing')}
- </label>
- )}
- />
-
- {!sameAsBilling && (
- <AddressFieldset
- form={form}
- prefix="shipping_address"
- legend={t('admin.company_locations.shipping_address')}
- />
- )}
- </FieldGroup>
- </div>
- <SheetFooter>
- <Button
- type="button"
- variant="outline"
- onClick={() => onOpenChange(false)}
- disabled={form.formState.isSubmitting}
- >
- {t('admin.actions.cancel')}
- </Button>
- <Button type="submit" disabled={form.formState.isSubmitting}>
- {form.formState.isSubmitting ? t('admin.actions.saving') : t('admin.actions.save')}
- </Button>
- </SheetFooter>
- </form>
- </SheetContent>
- </Sheet>
- )
-}
-
-function addressToForm(address: CompanyLocation['billing_address'] | undefined) {
- return {
- first_name: address?.first_name ?? '',
- last_name: address?.last_name ?? '',
- company: address?.company ?? '',
- address1: address?.address1 ?? '',
- address2: address?.address2 ?? '',
- city: address?.city ?? '',
- postal_code: address?.postal_code ?? '',
- phone: address?.phone ?? '',
- country_code: address?.country_code ?? '',
- state_code: address?.state_code ?? '',
- }
-}
diff --git a/packages/dashboard/src/hooks/use-catalogs.ts b/packages/dashboard/src/hooks/use-catalogs.ts
new file mode 100644
index 0000000000..7ded8fa2ee
--- /dev/null
+++ b/packages/dashboard/src/hooks/use-catalogs.ts
@@ -0,0 +1,139 @@
+import type {
+ Catalog,
+ CatalogAssignment,
+ CatalogAssignParams,
+ CatalogParams,
+} from '@spree/admin-sdk'
+import {
+ adminClient,
+ useResourceKey,
+ useResourceKeyBuilder,
+ useResourceMutation,
+} from '@spree/dashboard-core'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
+import i18n from 'i18next'
+
+export function useCatalog(id: string | undefined) {
+ return useQuery({
+ queryKey: useResourceKey('catalogs', id ?? 'noop'),
+ queryFn: () => adminClient.catalogs.get(id as string, { expand: ['assignments'] }),
+ enabled: !!id,
+ })
+}
+
+export function useCreateCatalog() {
+ return useResourceMutation<Catalog, Error, CatalogParams>({
+ mutationFn: (params) => adminClient.catalogs.create(params),
+ invalidate: [['catalogs']],
+ successMessage: i18n.t('admin.catalogs.messages.created'),
+ errorMessage: i18n.t('admin.errors.failed_to_create'),
+ })
+}
+
+export function useUpdateCatalog(id: string) {
+ return useResourceMutation<Catalog, Error, CatalogParams>({
+ mutationFn: (params) => adminClient.catalogs.update(id, params),
+ invalidate: [['catalogs'], ['catalogs', id]],
+ successMessage: i18n.t('admin.catalogs.messages.updated'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useDeleteCatalog() {
+ const queryClient = useQueryClient()
+ const buildKey = useResourceKeyBuilder()
+
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (id) => adminClient.catalogs.delete(id),
+ invalidate: [['catalogs']],
+ successMessage: i18n.t('admin.catalogs.messages.deleted'),
+ errorMessage: i18n.t('admin.errors.failed_to_delete'),
+ onSuccess: (_data, id) => {
+ queryClient.removeQueries({ queryKey: buildKey('catalogs', id) })
+ },
+ })
+}
+
+// ---------------------------------------------------------------------------
+// Assortment — the ProductMembershipHooks shape ProductMembershipCard expects
+// ---------------------------------------------------------------------------
+
+export function useCatalogProducts(catalogId: string | undefined, page = 1) {
+ return useQuery({
+ queryKey: useResourceKey('catalogs', catalogId ?? 'noop', 'products', `${page}`),
+ queryFn: () => adminClient.catalogs.products.list(catalogId as string, { page, limit: 25 }),
+ enabled: !!catalogId,
+ placeholderData: (previous) => previous,
+ })
+}
+
+export function useAddCatalogProducts(catalogId: string) {
+ return useResourceMutation<{ added_count: number }, Error, string[]>({
+ mutationFn: (productIds) => adminClient.catalogs.products.create(catalogId, productIds),
+ invalidate: [
+ ['catalogs', catalogId, 'products'],
+ ['catalogs', catalogId],
+ ],
+ successMessage: i18n.t('admin.catalogs.messages.products_added'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useRemoveCatalogProduct(catalogId: string) {
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (productId) => adminClient.catalogs.products.delete(catalogId, productId),
+ invalidate: [
+ ['catalogs', catalogId, 'products'],
+ ['catalogs', catalogId],
+ ],
+ successMessage: i18n.t('admin.catalogs.messages.product_removed'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useRemoveCatalogProducts(catalogId: string) {
+ return useResourceMutation<unknown, Error, string[]>({
+ mutationFn: (productIds) =>
+ Promise.all(
+ productIds.map((productId) => adminClient.catalogs.products.delete(catalogId, productId)),
+ ),
+ invalidate: [
+ ['catalogs', catalogId, 'products'],
+ ['catalogs', catalogId],
+ ],
+ successMessage: i18n.t('admin.catalogs.messages.products_removed'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useRepositionCatalogProduct(catalogId: string) {
+ return useResourceMutation<void, Error, { productId: string; new_position: number }>({
+ mutationFn: ({ productId, new_position }) =>
+ adminClient.catalogs.products.reposition(catalogId, productId, new_position),
+ invalidate: [['catalogs', catalogId, 'products']],
+ successMessage: false,
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+// ---------------------------------------------------------------------------
+// Assignments — who sees the catalog
+// ---------------------------------------------------------------------------
+
+export function useAssignCatalog(catalogId: string) {
+ return useResourceMutation<CatalogAssignment, Error, CatalogAssignParams>({
+ mutationFn: (params) => adminClient.catalogs.assign(catalogId, params),
+ invalidate: [['catalogs', catalogId]],
+ successMessage: i18n.t('admin.catalogs.messages.assigned'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useUnassignCatalog(catalogId: string) {
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (assignmentId) => adminClient.catalogAssignments.delete(assignmentId),
+ invalidate: [['catalogs', catalogId]],
+ successMessage: i18n.t('admin.catalogs.messages.unassigned'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
diff --git a/packages/dashboard/src/hooks/use-companies.ts b/packages/dashboard/src/hooks/use-companies.ts
index 427af055fb..19c036055a 100644
--- a/packages/dashboard/src/hooks/use-companies.ts
+++ b/packages/dashboard/src/hooks/use-companies.ts
@@ -1,9 +1,10 @@
import type {
Company,
- CompanyContact,
- CompanyContactParams,
- CompanyLocation,
- CompanyLocationParams,
+ CompanyAddress,
+ CompanyAddressParams,
+ CompanyInvitation,
+ CompanyMembership,
+ CompanyMembershipCreateParams,
CompanyParams,
TaxExemptionCertificate,
TaxExemptionCertificateParams,
@@ -27,6 +28,20 @@ export function useCompany(id: string | undefined) {
})
}
+/** One level of the tree: roots when `parentId` is undefined, else children. */
+export function useCompanyChildren(parentId: string | undefined, page = 1, limit = 25) {
+ return useQuery({
+ queryKey: useResourceKey('companies', 'tree', parentId ?? 'roots', `${page}:${limit}`),
+ queryFn: () =>
+ adminClient.companies.list(
+ parentId
+ ? { page, limit, parent_id_eq: parentId, sort: 'name' }
+ : { page, limit, parent_id_null: 1, sort: 'name' },
+ ),
+ placeholderData: (previous) => previous,
+ })
+}
+
export function useCreateCompany() {
return useResourceMutation<Company, Error, CompanyParams>({
mutationFn: (params) => adminClient.companies.create(params),
@@ -61,101 +76,110 @@ export function useDeleteCompany() {
}
// ---------------------------------------------------------------------------
-// Locations — listed and created under their company, then addressed by id
+// Address book — entries listed and created under their node, addressed by id
// ---------------------------------------------------------------------------
-export function useCompanyLocations(companyId: string | undefined, page = 1, limit = 25) {
+export function useCompanyAddresses(companyId: string | undefined, page = 1, limit = 25) {
return useQuery({
- queryKey: useResourceKey('companies', companyId ?? 'noop', 'locations', `${page}:${limit}`),
- queryFn: () => adminClient.companies.locations.list(companyId as string, { page, limit }),
+ queryKey: useResourceKey('companies', companyId ?? 'noop', 'addresses', `${page}:${limit}`),
+ queryFn: () => adminClient.companies.addresses.list(companyId as string, { page, limit }),
enabled: !!companyId,
placeholderData: (previous) => previous,
})
}
-export function useCompanyLocation(id: string | undefined) {
- return useQuery({
- queryKey: useResourceKey('company-locations', id ?? 'noop'),
- queryFn: () => adminClient.companyLocations.get(id as string),
- enabled: !!id,
- })
-}
-
-export function useCreateCompanyLocation(companyId: string) {
- return useResourceMutation<CompanyLocation, Error, CompanyLocationParams>({
- mutationFn: (params) => adminClient.companies.locations.create(companyId, params),
- invalidate: [['companies', companyId, 'locations']],
- successMessage: i18n.t('admin.company_locations.messages.created'),
+export function useCreateCompanyAddress(companyId: string) {
+ return useResourceMutation<CompanyAddress, Error, CompanyAddressParams>({
+ mutationFn: (params) => adminClient.companies.addresses.create(companyId, params),
+ invalidate: [['companies', companyId, 'addresses']],
+ successMessage: i18n.t('admin.company_addresses.messages.created'),
errorMessage: i18n.t('admin.errors.failed_to_create'),
})
}
-export function useUpdateCompanyLocation(id: string, companyId?: string) {
- return useResourceMutation<CompanyLocation, Error, CompanyLocationParams>({
- mutationFn: (params) => adminClient.companyLocations.update(id, params),
- invalidate: [
- ['company-locations', id],
- ...(companyId ? [['companies', companyId, 'locations']] : []),
- ],
- successMessage: i18n.t('admin.company_locations.messages.updated'),
+export function useUpdateCompanyAddress(companyId: string) {
+ return useResourceMutation<CompanyAddress, Error, { id: string; params: CompanyAddressParams }>({
+ mutationFn: ({ id, params }) => adminClient.companyAddresses.update(id, params),
+ invalidate: [['companies', companyId, 'addresses']],
+ successMessage: i18n.t('admin.company_addresses.messages.updated'),
errorMessage: i18n.t('admin.errors.failed_to_update'),
})
}
-export function useDeleteCompanyLocation(companyId?: string) {
- const queryClient = useQueryClient()
- const buildKey = useResourceKeyBuilder()
-
+export function useDeleteCompanyAddress(companyId: string) {
return useResourceMutation<void, Error, string>({
- mutationFn: (id) => adminClient.companyLocations.delete(id),
- invalidate: companyId ? [['companies', companyId, 'locations']] : [],
- successMessage: i18n.t('admin.company_locations.messages.deleted'),
+ mutationFn: (id) => adminClient.companyAddresses.delete(id),
+ invalidate: [['companies', companyId, 'addresses']],
+ successMessage: i18n.t('admin.company_addresses.messages.deleted'),
errorMessage: i18n.t('admin.errors.failed_to_delete'),
- // Drop just this branch's cached detail; invalidating the whole
- // `company-locations` prefix would refetch every branch visited this session.
- onSuccess: (_data, id) => {
- queryClient.removeQueries({ queryKey: buildKey('company-locations', id) })
- },
})
}
// ---------------------------------------------------------------------------
-// Contacts — the buyers authorised to purchase for a branch
+// Members — standing over the node and its subtree
// ---------------------------------------------------------------------------
-export function useCompanyLocationContacts(locationId: string | undefined, page = 1, limit = 25) {
+export function useCompanyMemberships(companyId: string | undefined, page = 1, limit = 25) {
return useQuery({
- queryKey: useResourceKey(
- 'company-locations',
- locationId ?? 'noop',
- 'contacts',
- `${page}:${limit}`,
- ),
- queryFn: () =>
- adminClient.companyLocations.contacts.list(locationId as string, { page, limit }),
- enabled: !!locationId,
+ queryKey: useResourceKey('companies', companyId ?? 'noop', 'memberships', `${page}:${limit}`),
+ queryFn: () => adminClient.companies.memberships.list(companyId as string, { page, limit }),
+ enabled: !!companyId,
placeholderData: (previous) => previous,
})
}
-export function useCreateCompanyContact(locationId: string) {
- return useResourceMutation<CompanyContact, Error, CompanyContactParams>({
- mutationFn: (params) => adminClient.companyLocations.contacts.create(locationId, params),
- invalidate: [['company-locations', locationId]],
- successMessage: i18n.t('admin.company_contacts.messages.created'),
+/**
+ * Adding by email does the right thing server-side — the result is a
+ * membership for an existing customer, an invitation otherwise. Both lists
+ * refresh because either may have grown.
+ */
+export function useAddCompanyMember(companyId: string) {
+ return useResourceMutation<
+ CompanyMembership | CompanyInvitation,
+ Error,
+ CompanyMembershipCreateParams
+ >({
+ mutationFn: (params) => adminClient.companies.memberships.create(companyId, params),
+ invalidate: [
+ ['companies', companyId, 'memberships'],
+ ['companies', companyId, 'invitations'],
+ ],
+ successMessage: i18n.t('admin.company_memberships.messages.added'),
errorMessage: i18n.t('admin.errors.failed_to_create'),
})
}
-export function useDeleteCompanyContact(locationId: string) {
+export function useDeleteCompanyMembership(companyId: string) {
return useResourceMutation<void, Error, string>({
- mutationFn: (id) => adminClient.companyContacts.delete(id),
- invalidate: [['company-locations', locationId]],
- successMessage: i18n.t('admin.company_contacts.messages.deleted'),
+ mutationFn: (id) => adminClient.companyMemberships.delete(id),
+ invalidate: [['companies', companyId, 'memberships']],
+ successMessage: i18n.t('admin.company_memberships.messages.removed'),
errorMessage: i18n.t('admin.errors.failed_to_delete'),
})
}
+// ---------------------------------------------------------------------------
+// Invitations — the pending state for not-yet-registered emails
+// ---------------------------------------------------------------------------
+
+export function useCompanyInvitations(companyId: string | undefined, page = 1, limit = 25) {
+ return useQuery({
+ queryKey: useResourceKey('companies', companyId ?? 'noop', 'invitations', `${page}:${limit}`),
+ queryFn: () => adminClient.companies.invitations.list(companyId as string, { page, limit }),
+ enabled: !!companyId,
+ placeholderData: (previous) => previous,
+ })
+}
+
+export function useRevokeCompanyInvitation(companyId: string) {
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (id) => adminClient.companyInvitations.delete(id),
+ invalidate: [['companies', companyId, 'invitations']],
+ successMessage: i18n.t('admin.company_invitations.messages.revoked'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
// ---------------------------------------------------------------------------
// Tax identifiers — the registration that goes on the business's invoices
// ---------------------------------------------------------------------------
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 8d3f041a52..eb30ca1356 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -87,6 +87,80 @@
"tiered_flat_rate": "Tiered Flat Rate",
"tiered_percent": "Tiered Percent"
},
+ "catalogs": {
+ "add_cta": "إضافة كتالوج",
+ "add_sheet_title": "كتالوج جديد",
+ "assignable_types": {
+ "channel": "قناة",
+ "company": "شركة",
+ "customer_group": "مجموعة عملاء",
+ "market": "سوق"
+ },
+ "assignments": {
+ "add_cta": "تعيين",
+ "add_title": "تعيين هذا الكتالوج",
+ "audience_empty": "لا نتائج",
+ "audience_label": "الجمهور",
+ "audience_placeholder": "بحث…",
+ "company_subtree_help": "تعيين شركة يشمل كامل شجرتها الفرعية.",
+ "dialog_description": "من يرى هذا الكتالوج. تعيين شركة يشمل العقدة وكل ما تحتها.",
+ "empty": "غير معين لأي جمهور — لا أحد يرى هذا الكتالوج.",
+ "remove_confirm": {
+ "message": "لن يعود {{name}} يرى هذا الكتالوج.",
+ "title": "إزالة هذا التعيين؟"
+ },
+ "title": "الجماهير",
+ "type_label": "نوع الجمهور"
+ },
+ "create_description": "يحدد الكتالوج ما يراه جمهور معين، وعبر قائمة الأسعار ما يدفعه. أضف المنتجات والجماهير بعد إنشائه.",
+ "create_label": "إنشاء كتالوج",
+ "delete_confirm": {
+ "message": "سيؤدي هذا إلى حذف {{name}} وتعييناته. لن تتأثر المنتجات وقوائم الأسعار.",
+ "title": "حذف الكتالوج؟"
+ },
+ "detail": {
+ "delete_label": "حذف الكتالوج",
+ "load_error": "تعذر تحميل هذا الكتالوج",
+ "settings": "الكتالوج"
+ },
+ "empty": "لا توجد كتالوجات بعد",
+ "messages": {
+ "assigned": "تم تعيين الكتالوج",
+ "created": "تم إنشاء الكتالوج",
+ "deleted": "تم حذف الكتالوج",
+ "product_removed": "تمت إزالة المنتج",
+ "products_added": "تمت إضافة المنتجات",
+ "products_removed": "تمت إزالة المنتجات",
+ "unassigned": "تمت إزالة التعيين",
+ "updated": "تم تحديث الكتالوج"
+ },
+ "products": {
+ "add_cta": "إضافة منتجات",
+ "column_product": "المنتج",
+ "empty": "لا توجد منتجات في هذا الكتالوج بعد.",
+ "filter_placeholder": "تصفية المنتجات…",
+ "no_matches": "لا توجد منتجات مطابقة للتصفية.",
+ "picker_description": "ابحث واختر منتجات لإضافتها إلى هذا الكتالوج.",
+ "picker_title": "إضافة منتجات إلى الكتالوج",
+ "remove": "إزالة من الكتالوج",
+ "remove_confirm": {
+ "message_few": "إزالة {{count}} منتجات من هذا الكتالوج؟ يسري ذلك فورًا. تبقى المنتجات في متجرك.",
+ "message_many": "إزالة {{count}} منتجًا من هذا الكتالوج؟ يسري ذلك فورًا. تبقى المنتجات في متجرك.",
+ "message_named": "إزالة \"{{name}}\" من هذا الكتالوج؟ يسري ذلك فورًا. يبقى المنتج في متجرك.",
+ "message_one": "إزالة منتج واحد من هذا الكتالوج؟ يسري ذلك فورًا. تبقى المنتجات في متجرك.",
+ "message_other": "إزالة {{count}} منتج من هذا الكتالوج؟ يسري ذلك فورًا. تبقى المنتجات في متجرك.",
+ "message_two": "إزالة منتجين من هذا الكتالوج؟ يسري ذلك فورًا. تبقى المنتجات في متجرك.",
+ "title": "إزالة من الكتالوج"
+ },
+ "remove_selected": "إزالة",
+ "search_placeholder": "البحث في المنتجات…",
+ "select_all": "تحديد الكل",
+ "select_row": "تحديد المنتج",
+ "title": "المنتجات"
+ },
+ "products_column": "المنتجات",
+ "search_placeholder": "البحث في الكتالوجات"
+ },
"categories": {
"add_cta": "فئة جديدة",
"collapse": "طي",
@@ -315,70 +389,99 @@
"companies": {
"add_cta": "إضافة شركة",
"add_sheet_title": "شركة جديدة",
- "create_description": "يشتري العملاء من الشركات عبر الفروع. يمكنك إضافة الفروع والرقم الضريبي وشهادات الإعفاء بعد إنشاء الشركة.",
- "create_label": "إنشاء الشركة",
+ "collapse_node": "طي",
+ "create_description": "الشركة هي جذر شجرة المؤسسة. يمكنك إضافة الوحدات الفرعية والأعضاء والعناوين والتسجيلات الضريبية وشهادات الإعفاء بعد إنشائها.",
+ "create_label": "إنشاء شركة",
"delete_confirm": {
- "message": "سيؤدي هذا إلى حذف {{name}} مع فروعها ومشترييها وشهاداتها. لا يمكن التراجع عن هذا الإجراء.",
+ "message": "سيؤدي هذا إلى حذف {{name}} مع كامل شجرتها الفرعية — الوحدات والأعضاء والعناوين والشهادات. لا يمكن التراجع عن هذا.",
"title": "حذف الشركة؟"
},
"detail": {
"delete_label": "حذف الشركة",
+ "division_tax_pointer": "لا يملك القسم تسجيلات ضريبية خاصة به. تُفرض الضرائب على مشترياته عبر كيانه القانوني:",
"load_error": "تعذر تحميل هذه الشركة",
"profile": "الشركة"
},
"empty": "لا توجد شركات بعد",
- "locations_column": "الفروع",
+ "expand_node": "توسيع",
+ "kind": {
+ "company": "شركة",
+ "division": "قسم"
+ },
+ "load_more": "عرض المزيد…",
+ "members_count_few": "{{count}} أعضاء",
+ "members_count_many": "{{count}} عضوًا",
+ "members_count_one": "عضو واحد",
+ "members_count_other": "{{count}} عضو",
+ "members_count_two": "عضوان",
"messages": {
"created": "تم إنشاء الشركة",
"deleted": "تم حذف الشركة",
"updated": "تم تحديث الشركة"
},
- "search_placeholder": "البحث في الشركات"
+ "search_empty": "لا توجد شركات مطابقة لبحثك",
+ "search_placeholder": "البحث في الشركات",
+ "sub_units": {
+ "add_cta": "إضافة وحدة فرعية",
+ "add_description": "القسم وحدة تنظيمية تشارك الهوية الضريبية لكيانها القانوني. أما الشركة فهي كيان قانوني مستقل بتسجيلاته الخاصة.",
+ "add_title": "وحدة فرعية جديدة في {{name}}",
+ "empty": "لا توجد وحدات فرعية بعد",
+ "title": "الوحدات الفرعية"
+ }
},
- "company_contacts": {
- "add_cta": "إضافة مشترٍ",
- "add_title": "تخويل مشترٍ",
- "dialog_description": "عميل يشتري لهذا الفرع. من يشتري لفرع واحد فقط تُنسب طلباته إليه تلقائياً.",
- "empty": "لم يتم تخويل أي مشترٍ بعد",
+ "company_addresses": {
+ "add_cta": "إضافة عنوان",
+ "add_sheet_title": "عنوان جديد",
+ "address_legend": "العنوان",
+ "default_billing": "الفوترة الافتراضية",
+ "default_billing_label": "استخدام كعنوان الفوترة الافتراضي",
+ "default_shipping": "الشحن الافتراضي",
+ "default_shipping_label": "استخدام كعنوان الشحن الافتراضي",
+ "edit_sheet_title": "تعديل العنوان",
+ "empty": "لا توجد عناوين بعد",
"messages": {
- "created": "تمت إضافة المشتري",
- "deleted": "تمت إزالة المشتري"
+ "created": "تمت إضافة العنوان",
+ "deleted": "تمت إزالة العنوان",
+ "updated": "تم تحديث العنوان"
},
- "remove_action": "إزالة المشتري",
"remove_confirm": {
- "message": "لن يعود {{email}} يشتري لهذا الفرع. لن يتأثر حساب العميل.",
- "title": "إزالة هذا المشتري؟"
+ "message": "ستتم إزالة {{label}} من دفتر العناوين. لا يمكن التراجع عن هذا.",
+ "title": "حذف هذا العنوان؟"
},
- "roles_enterprise_help": "يمكن للمشترين المضافين هنا تقديم الطلبات لهذا الفرع. الأدوار ومسارات الموافقة وحدود الإنفاق تأتي مع Spree Enterprise.",
- "roles_enterprise_title": "الأدوار والموافقات من مزايا Enterprise",
- "title": "المشترون"
+ "sheet_description": "موقع شحن أو فوترة مسمى لهذه العقدة. افتراضي واحد على الأكثر من كل نوع؛ ترقية عنوان تلغي الافتراضي السابق.",
+ "title": "دفتر العناوين"
},
- "company_locations": {
- "add_cta": "إضافة فرع",
- "add_title": "فرع جديد",
- "addresses": "العناوين",
- "billing_address": "عنوان الفوترة",
- "contacts_count_few": "{{count}} مشترين",
- "contacts_count_many": "{{count}} مشترياً",
- "contacts_count_one": "مشترٍ واحد",
- "contacts_count_other": "{{count}} مشترٍ",
- "contacts_count_two": "مشتريان",
- "contacts_count_zero": "لا مشترين",
- "detail": {
- "delete_label": "حذف الفرع",
- "load_error": "تعذر تحميل هذا الفرع"
+ "company_invitations": {
+ "messages": {
+ "revoked": "تم إلغاء الدعوة"
+ },
+ "pending_title": "الدعوات المعلقة",
+ "revoke_action": "إلغاء الدعوة",
+ "revoke_confirm": {
+ "message": "ستتوقف الدعوة المرسلة إلى {{email}} عن العمل.",
+ "title": "إلغاء هذه الدعوة؟"
},
- "dialog_description": "الفرع هو الجهة التي تُصدر لها الفاتورة وتُشحن إليها الطلبات. العناوين اختيارية، لكن أي عنوان تبدأ بتعبئته يتطلب الاسم والدولة.",
- "edit_title": "تعديل الفرع",
- "empty": "لا توجد فروع بعد",
+ "status": {
+ "pending": "معلقة"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "إضافة عضو",
+ "add_title": "إضافة عضو",
+ "dialog_description": "يمكن للأعضاء الشراء لهذه العقدة وكل ما تحتها. البريد الإلكتروني بدون حساب يتحول إلى دعوة.",
+ "empty": "لا يوجد أعضاء بعد",
"messages": {
- "created": "تم إنشاء الفرع",
- "deleted": "تم حذف الفرع",
- "updated": "تم تحديث الفرع"
+ "added": "تمت إضافة العضو",
+ "removed": "تمت إزالة العضو"
},
- "shipping_address": "عنوان الشحن",
- "shipping_same_as_billing": "عنوان الشحن هو نفسه عنوان الفوترة",
- "title": "الفروع"
+ "remove_action": "إزالة العضو",
+ "remove_confirm": {
+ "message": "لن يتمكن {{email}} من الشراء لهذه الشركة بعد الآن. لن يتأثر حساب العميل.",
+ "title": "إزالة هذا العضو؟"
+ },
+ "roles_enterprise_help": "الأعضاء المضافون هنا يمكنهم الشراء لهذه الشركة وإدارة دليلها. الأدوار ومسارات الموافقة وحدود الإنفاق تأتي مع Spree Enterprise.",
+ "roles_enterprise_title": "الأدوار والموافقات ميزة في نسخة Enterprise",
+ "title": "الأعضاء"
},
"components": {
"adjustment_action_editor": {
@@ -785,6 +888,17 @@
"label": "Scopes"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "البيع بالجملة"
+ },
+ "price_list": {
+ "empty": "لم يتم العثور على قوائم أسعار",
+ "help": "اختياري. بدون قائمة أسعار، يحدد الكتالوج التشكيلة فقط وتُطبق الأسعار الأساسية.",
+ "label": "قائمة الأسعار",
+ "placeholder": "الأسعار الأساسية"
+ }
+ },
"certificate_document": {
"help": "ملف PDF أو صورة، حتى 10 ميغابايت. الموظفون وحدهم يمكنهم تنزيله.",
"label": "مستند الشهادة"
@@ -905,21 +1019,30 @@
"help": "مرجعك الخاص لهذه الشركة، فريد داخل المتجر.",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "الشركة كيان قانوني يمكنه حمل تسجيلات ضريبية. القسم يستخدم تسجيلات كيانه القانوني.",
+ "label": "النوع"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "الدور"
+ "company_address": {
+ "label": {
+ "help": "كيف يُشار إلى هذا الموقع — \"المقر الرئيسي\"، \"رصيف المصنع 2\".",
+ "label": "التسمية",
+ "placeholder": "المقر الرئيسي"
}
},
"company_location": {
"external_id": {
"help": "مرجعك الخاص لهذا الفرع."
- },
- "name": {
- "placeholder": "المقر الرئيسي"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "العميل الحالي ينضم فورًا؛ أي شخص آخر يتلقى دعوة بالبريد الإلكتروني.",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2177,6 +2300,7 @@
},
"nav": {
"account": "الحساب",
+ "catalogs": "الكتالوجات",
"categories": "الفئات",
"claims": "المطالبات",
"collections": "المجموعات",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 12530c5daf..6225fbe31b 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -87,6 +87,77 @@
"tiered_flat_rate": "Gestaffelter Pauschalbetrag",
"tiered_percent": "Gestaffelter Prozentsatz"
},
+ "catalogs": {
+ "add_cta": "Katalog hinzufügen",
+ "add_sheet_title": "Neuer Katalog",
+ "assignable_types": {
+ "channel": "Kanal",
+ "company": "Unternehmen",
+ "customer_group": "Kundengruppe",
+ "market": "Markt"
+ },
+ "assignments": {
+ "add_cta": "Zuweisen",
+ "add_title": "Diesen Katalog zuweisen",
+ "audience_empty": "Nichts gefunden",
+ "audience_label": "Zielgruppe",
+ "audience_placeholder": "Suchen…",
+ "company_subtree_help": "Die Zuweisung an ein Unternehmen gilt für dessen gesamten Teilbaum.",
+ "dialog_description": "Wer diesen Katalog sieht. Eine Unternehmens-Zuweisung gilt für den Knoten und alles darunter.",
+ "empty": "Noch keiner Zielgruppe zugewiesen — niemand sieht diesen Katalog.",
+ "remove_confirm": {
+ "message": "{{name}} sieht diesen Katalog dann nicht mehr.",
+ "title": "Diese Zuweisung entfernen?"
+ },
+ "title": "Zielgruppen",
+ "type_label": "Zielgruppen-Typ"
+ },
+ "create_description": "Ein Katalog bestimmt, was eine Zielgruppe sieht und — über eine Preisliste — was sie zahlt. Produkte und Zielgruppen fügen Sie danach hinzu.",
+ "create_label": "Katalog erstellen",
+ "delete_confirm": {
+ "message": "Dies löscht {{name}} und seine Zuweisungen. Produkte und Preislisten bleiben unberührt.",
+ "title": "Katalog löschen?"
+ },
+ "detail": {
+ "delete_label": "Katalog löschen",
+ "load_error": "Katalog konnte nicht geladen werden",
+ "settings": "Katalog"
+ },
+ "empty": "Noch keine Kataloge",
+ "messages": {
+ "assigned": "Katalog zugewiesen",
+ "created": "Katalog erstellt",
+ "deleted": "Katalog gelöscht",
+ "product_removed": "Produkt entfernt",
+ "products_added": "Produkte hinzugefügt",
+ "products_removed": "Produkte entfernt",
+ "unassigned": "Zuweisung entfernt",
+ "updated": "Katalog aktualisiert"
+ },
+ "products": {
+ "add_cta": "Produkte hinzufügen",
+ "column_product": "Produkt",
+ "empty": "Noch keine Produkte in diesem Katalog.",
+ "filter_placeholder": "Produkte filtern…",
+ "no_matches": "Keine Produkte entsprechen Ihrem Filter.",
+ "picker_description": "Produkte suchen und auswählen, um sie diesem Katalog hinzuzufügen.",
+ "picker_title": "Produkte zum Katalog hinzufügen",
+ "remove": "Aus Katalog entfernen",
+ "remove_confirm": {
+ "message_named": "\"{{name}}\" aus diesem Katalog entfernen? Dies gilt sofort. Das Produkt bleibt in Ihrem Shop.",
+ "message_one": "{{count}} Produkt aus diesem Katalog entfernen? Dies gilt sofort. Die Produkte bleiben in Ihrem Shop.",
+ "message_other": "{{count}} Produkte aus diesem Katalog entfernen? Dies gilt sofort. Die Produkte bleiben in Ihrem Shop.",
+ "title": "Aus Katalog entfernen"
+ },
+ "remove_selected": "Entfernen",
+ "search_placeholder": "Produkte suchen…",
+ "select_all": "Alle auswählen",
+ "select_row": "Produkt auswählen",
+ "title": "Produkte"
+ },
+ "products_column": "Produkte",
+ "search_placeholder": "Kataloge suchen"
+ },
"categories": {
"add_cta": "Neue Kategorie",
"collapse": "Zuklappen",
@@ -313,68 +384,98 @@
"search_placeholder": "Nach Namen suchen…"
},
"companies": {
- "add_cta": "Firma hinzufügen",
- "add_sheet_title": "Neue Firma",
- "create_description": "Geschäftskunden kaufen über Niederlassungen ein. Niederlassungen, Steuernummer und Freistellungsbescheinigungen können Sie hinzufügen, sobald die Firma angelegt ist.",
- "create_label": "Firma anlegen",
+ "add_cta": "Unternehmen hinzufügen",
+ "add_sheet_title": "Neues Unternehmen",
+ "collapse_node": "Zuklappen",
+ "create_description": "Ein Unternehmen ist die Wurzel eines Organisationsbaums. Untereinheiten, Mitglieder, Adressen, Steuerregistrierung und Befreiungsnachweise fügen Sie danach hinzu.",
+ "create_label": "Unternehmen erstellen",
"delete_confirm": {
- "message": "Damit werden {{name}} sowie alle Niederlassungen, Einkäufer und Bescheinigungen gelöscht. Das lässt sich nicht rückgängig machen.",
- "title": "Firma löschen?"
+ "message": "Dies löscht {{name}} mitsamt dem gesamten Teilbaum — Untereinheiten, Mitglieder, Adressen und Nachweise. Dies kann nicht rückgängig gemacht werden.",
+ "title": "Unternehmen löschen?"
},
"detail": {
- "delete_label": "Firma löschen",
- "load_error": "Diese Firma konnte nicht geladen werden",
- "profile": "Firma"
- },
- "empty": "Noch keine Firmen",
- "locations_column": "Niederlassungen",
+ "delete_label": "Unternehmen löschen",
+ "division_tax_pointer": "Eine Abteilung hält keine eigenen Steuerregistrierungen. Ihre Käufe werden über ihre juristische Einheit besteuert:",
+ "load_error": "Unternehmen konnte nicht geladen werden",
+ "profile": "Unternehmen"
+ },
+ "empty": "Noch keine Unternehmen",
+ "expand_node": "Aufklappen",
+ "kind": {
+ "company": "Unternehmen",
+ "division": "Abteilung"
+ },
+ "load_more": "Mehr anzeigen…",
+ "members_count_one": "{{count}} Mitglied",
+ "members_count_other": "{{count}} Mitglieder",
"messages": {
- "created": "Firma angelegt",
- "deleted": "Firma gelöscht",
- "updated": "Firma aktualisiert"
- },
- "search_placeholder": "Firmen suchen"
+ "created": "Unternehmen erstellt",
+ "deleted": "Unternehmen gelöscht",
+ "updated": "Unternehmen aktualisiert"
+ },
+ "search_empty": "Keine Unternehmen entsprechen Ihrer Suche",
+ "search_placeholder": "Unternehmen suchen",
+ "sub_units": {
+ "add_cta": "Untereinheit hinzufügen",
+ "add_description": "Eine Abteilung ist eine Organisationseinheit, die die Steueridentität ihrer juristischen Einheit teilt. Ein Unternehmen ist eine eigene juristische Einheit mit eigenen Registrierungen.",
+ "add_title": "Neue Untereinheit von {{name}}",
+ "empty": "Noch keine Untereinheiten",
+ "title": "Untereinheiten"
+ }
},
- "company_contacts": {
- "add_cta": "Einkäufer hinzufügen",
- "add_title": "Einkäufer berechtigen",
- "dialog_description": "Ein Kunde, der für diese Niederlassung einkauft. Wer für genau eine Niederlassung einkauft, dessen Bestellungen werden ihr automatisch zugeordnet.",
- "empty": "Noch keine Einkäufer berechtigt",
+ "company_addresses": {
+ "add_cta": "Adresse hinzufügen",
+ "add_sheet_title": "Neue Adresse",
+ "address_legend": "Adresse",
+ "default_billing": "Standard-Rechnung",
+ "default_billing_label": "Als Standard-Rechnungsadresse verwenden",
+ "default_shipping": "Standard-Lieferung",
+ "default_shipping_label": "Als Standard-Lieferadresse verwenden",
+ "edit_sheet_title": "Adresse bearbeiten",
+ "empty": "Noch keine Adressen",
"messages": {
- "created": "Einkäufer hinzugefügt",
- "deleted": "Einkäufer entfernt"
+ "created": "Adresse hinzugefügt",
+ "deleted": "Adresse entfernt",
+ "updated": "Adresse aktualisiert"
},
- "remove_action": "Einkäufer entfernen",
"remove_confirm": {
- "message": "{{email}} kauft dann nicht mehr für diese Niederlassung ein. Das Kundenkonto bleibt bestehen.",
- "title": "Diesen Einkäufer entfernen?"
+ "message": "{{label}} wird aus dem Adressbuch entfernt. Dies kann nicht rückgängig gemacht werden.",
+ "title": "Diese Adresse löschen?"
},
- "roles_enterprise_help": "Hier hinzugefügte Einkäufer können für diese Niederlassung bestellen. Rollen, Freigabeprozesse und Ausgabenlimits gehören zu Spree Enterprise.",
- "roles_enterprise_title": "Rollen und Freigaben sind eine Enterprise-Funktion",
- "title": "Einkäufer"
+ "sheet_description": "Ein benannter Liefer- oder Rechnungsstandort dieses Knotens. Höchstens ein Standard je Art; ein neuer Standard löst den vorherigen ab.",
+ "title": "Adressbuch"
},
- "company_locations": {
- "add_cta": "Niederlassung hinzufügen",
- "add_title": "Neue Niederlassung",
- "addresses": "Adressen",
- "billing_address": "Rechnungsadresse",
- "contacts_count_one": "{{count}} Einkäufer",
- "contacts_count_other": "{{count}} Einkäufer",
- "detail": {
- "delete_label": "Niederlassung löschen",
- "load_error": "Diese Niederlassung konnte nicht geladen werden"
+ "company_invitations": {
+ "messages": {
+ "revoked": "Einladung widerrufen"
+ },
+ "pending_title": "Ausstehende Einladungen",
+ "revoke_action": "Einladung widerrufen",
+ "revoke_confirm": {
+ "message": "Die an {{email}} gesendete Einladung funktioniert dann nicht mehr.",
+ "title": "Diese Einladung widerrufen?"
},
- "dialog_description": "Eine Niederlassung ist der Ort, an den die Rechnung geht und an den geliefert wird. Adressen sind optional, benötigen aber Name und Land, sobald sie ausgefüllt werden.",
- "edit_title": "Niederlassung bearbeiten",
- "empty": "Noch keine Niederlassungen",
+ "status": {
+ "pending": "Ausstehend"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "Mitglied hinzufügen",
+ "add_title": "Mitglied hinzufügen",
+ "dialog_description": "Mitglieder können für diesen Knoten und alles darunter einkaufen. Eine E-Mail ohne Konto wird zur Einladung.",
+ "empty": "Noch keine Mitglieder",
"messages": {
- "created": "Niederlassung angelegt",
- "deleted": "Niederlassung gelöscht",
- "updated": "Niederlassung aktualisiert"
+ "added": "Mitglied hinzugefügt",
+ "removed": "Mitglied entfernt"
},
- "shipping_address": "Lieferadresse",
- "shipping_same_as_billing": "Lieferadresse entspricht der Rechnungsadresse",
- "title": "Niederlassungen"
+ "remove_action": "Mitglied entfernen",
+ "remove_confirm": {
+ "message": "{{email}} kann nicht mehr für dieses Unternehmen einkaufen. Das Kundenkonto bleibt unberührt.",
+ "title": "Dieses Mitglied entfernen?"
+ },
+ "roles_enterprise_help": "Hier hinzugefügte Mitglieder können für dieses Unternehmen einkaufen und sein Verzeichnis verwalten. Rollen, Freigabe-Workflows und Ausgabenlimits gibt es mit Spree Enterprise.",
+ "roles_enterprise_title": "Rollen und Freigaben sind ein Enterprise-Feature",
+ "title": "Mitglieder"
},
"components": {
"adjustment_action_editor": {
@@ -770,6 +871,17 @@
"label": "Geltungsbereiche"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "Großhandel"
+ },
+ "price_list": {
+ "empty": "Keine Preislisten gefunden",
+ "help": "Optional. Ohne Preisliste schränkt der Katalog nur das Sortiment ein; es gelten die Basispreise.",
+ "label": "Preisliste",
+ "placeholder": "Basispreise"
+ }
+ },
"certificate_document": {
"help": "PDF oder Bild, bis 10 MB. Nur Mitarbeiter können es herunterladen.",
"label": "Dokument"
@@ -890,21 +1002,30 @@
"help": "Ihre eigene Referenz für diese Firma, eindeutig innerhalb des Shops.",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "Ein Unternehmen ist eine juristische Einheit mit eigenen Steuerregistrierungen. Eine Abteilung nutzt die ihrer juristischen Einheit.",
+ "label": "Art"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "Rolle"
+ "company_address": {
+ "label": {
+ "help": "Wie dieser Standort genannt wird — „Hauptsitz\", „Werk 2 Rampe\".",
+ "label": "Bezeichnung",
+ "placeholder": "Hauptsitz"
}
},
"company_location": {
"external_id": {
"help": "Ihre eigene Referenz für diese Niederlassung."
- },
- "name": {
- "placeholder": "Hauptsitz"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "Ein bestehender Kunde tritt sofort bei; alle anderen erhalten eine Einladung per E-Mail.",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2162,6 +2283,7 @@
},
"nav": {
"account": "Konto",
+ "catalogs": "Kataloge",
"categories": "Kategorien",
"claims": "Reklamationen",
"collections": "Kollektionen",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index a8ed4b3fca..95039ee784 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -87,6 +87,77 @@
"tiered_flat_rate": "Tiered Flat Rate",
"tiered_percent": "Tiered Percent"
},
+ "catalogs": {
+ "add_cta": "Add catalog",
+ "add_sheet_title": "New catalog",
+ "assignable_types": {
+ "channel": "Channel",
+ "company": "Company",
+ "customer_group": "Customer group",
+ "market": "Market"
+ },
+ "assignments": {
+ "add_cta": "Assign",
+ "add_title": "Assign this catalog",
+ "audience_empty": "Nothing found",
+ "audience_label": "Audience",
+ "audience_placeholder": "Search…",
+ "company_subtree_help": "Assigning to a company covers its whole subtree.",
+ "dialog_description": "Who sees this catalog. A company assignment covers the node and everything below it.",
+ "empty": "Not assigned to any audience yet — nobody sees this catalog.",
+ "remove_confirm": {
+ "message": "{{name}} will stop seeing this catalog.",
+ "title": "Remove this assignment?"
+ },
+ "title": "Audiences",
+ "type_label": "Audience type"
+ },
+ "create_description": "A catalog narrows what an audience sees and, through a price list, what they pay. Add products and assign audiences once it exists.",
+ "create_label": "Create catalog",
+ "delete_confirm": {
+ "message": "This deletes {{name}} and its assignments. Products and price lists are not affected.",
+ "title": "Delete catalog?"
+ },
+ "detail": {
+ "delete_label": "Delete catalog",
+ "load_error": "Could not load this catalog",
+ "settings": "Catalog"
+ },
+ "empty": "No catalogs yet",
+ "messages": {
+ "assigned": "Catalog assigned",
+ "created": "Catalog created",
+ "deleted": "Catalog deleted",
+ "product_removed": "Product removed",
+ "products_added": "Products added",
+ "products_removed": "Products removed",
+ "unassigned": "Assignment removed",
+ "updated": "Catalog updated"
+ },
+ "products": {
+ "add_cta": "Add products",
+ "column_product": "Product",
+ "empty": "No products in this catalog yet.",
+ "filter_placeholder": "Filter products…",
+ "no_matches": "No products match your filter.",
+ "picker_description": "Search and select products to add to this catalog.",
+ "picker_title": "Add products to catalog",
+ "remove": "Remove from catalog",
+ "remove_confirm": {
+ "message_named": "Remove \"{{name}}\" from this catalog? This takes effect immediately. The product stays in your store.",
+ "message_one": "Remove {{count}} product from this catalog? This takes effect immediately. The products stay in your store.",
+ "message_other": "Remove {{count}} products from this catalog? This takes effect immediately. The products stay in your store.",
+ "title": "Remove from catalog"
+ },
+ "remove_selected": "Remove",
+ "search_placeholder": "Search products…",
+ "select_all": "Select all",
+ "select_row": "Select product",
+ "title": "Products"
+ },
+ "products_column": "Products",
+ "search_placeholder": "Search catalogs"
+ },
"categories": {
"add_cta": "New category",
"collapse": "Collapse",
@@ -315,66 +386,96 @@
"companies": {
"add_cta": "Add company",
"add_sheet_title": "New company",
- "create_description": "Business customers buy through branches. You can add branches, tax registration and exemption certificates once the company exists.",
+ "collapse_node": "Collapse",
+ "create_description": "A company is the root of an organization tree. Add sub-units, members, addresses, tax registration and exemption certificates once it exists.",
"create_label": "Create company",
"delete_confirm": {
- "message": "This deletes {{name}} along with its branches, buyers and certificates. This cannot be undone.",
+ "message": "This deletes {{name}} along with its whole subtree — sub-units, members, addresses and certificates. This cannot be undone.",
"title": "Delete company?"
},
"detail": {
"delete_label": "Delete company",
+ "division_tax_pointer": "A division holds no tax registrations of its own. Its purchases are taxed through its legal entity:",
"load_error": "Could not load this company",
"profile": "Company"
},
"empty": "No companies yet",
- "locations_column": "Branches",
+ "expand_node": "Expand",
+ "kind": {
+ "company": "Company",
+ "division": "Division"
+ },
+ "load_more": "Show more…",
+ "members_count_one": "{{count}} member",
+ "members_count_other": "{{count}} members",
"messages": {
"created": "Company created",
"deleted": "Company deleted",
"updated": "Company updated"
},
- "search_placeholder": "Search companies"
+ "search_empty": "No companies match your search",
+ "search_placeholder": "Search companies",
+ "sub_units": {
+ "add_cta": "Add sub-unit",
+ "add_description": "A division is an organizational unit that shares its legal entity’s tax identity. A company is a legal entity of its own, with its own registrations.",
+ "add_title": "New sub-unit of {{name}}",
+ "empty": "No sub-units yet",
+ "title": "Sub-units"
+ }
},
- "company_contacts": {
- "add_cta": "Add buyer",
- "add_title": "Authorise a buyer",
- "dialog_description": "A customer who buys for this branch. Someone who buys for exactly one branch has their orders attributed to it automatically.",
- "empty": "No buyers authorised yet",
+ "company_addresses": {
+ "add_cta": "Add address",
+ "add_sheet_title": "New address",
+ "address_legend": "Address",
+ "default_billing": "Default billing",
+ "default_billing_label": "Use as default billing address",
+ "default_shipping": "Default shipping",
+ "default_shipping_label": "Use as default shipping address",
+ "edit_sheet_title": "Edit address",
+ "empty": "No addresses yet",
"messages": {
- "created": "Buyer added",
- "deleted": "Buyer removed"
+ "created": "Address added",
+ "deleted": "Address removed",
+ "updated": "Address updated"
},
- "remove_action": "Remove buyer",
"remove_confirm": {
- "message": "{{email}} will no longer buy for this branch. Their customer account is not affected.",
- "title": "Remove this buyer?"
+ "message": "{{label}} will be removed from the address book. This cannot be undone.",
+ "title": "Delete this address?"
},
- "roles_enterprise_help": "Buyers you add here can place orders for this branch. Roles, approval workflows and spending limits come with Spree Enterprise.",
- "roles_enterprise_title": "Roles and approvals are an Enterprise feature",
- "title": "Buyers"
+ "sheet_description": "A labeled ship-to or bill-to site for this node. At most one default of each kind; promoting an entry demotes the previous default.",
+ "title": "Address book"
},
- "company_locations": {
- "add_cta": "Add branch",
- "add_title": "New branch",
- "addresses": "Addresses",
- "billing_address": "Billing address",
- "contacts_count_one": "{{count}} buyer",
- "contacts_count_other": "{{count}} buyers",
- "detail": {
- "delete_label": "Delete branch",
- "load_error": "Could not load this branch"
+ "company_invitations": {
+ "messages": {
+ "revoked": "Invitation revoked"
},
- "dialog_description": "A branch is where the business is invoiced and where its orders ship. Addresses are optional, but a partial address needs a name and country.",
- "edit_title": "Edit branch",
- "empty": "No branches yet",
+ "pending_title": "Pending invitations",
+ "revoke_action": "Revoke invitation",
+ "revoke_confirm": {
+ "message": "The invitation sent to {{email}} will stop working.",
+ "title": "Revoke this invitation?"
+ },
+ "status": {
+ "pending": "Pending"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "Add member",
+ "add_title": "Add a member",
+ "dialog_description": "Members can buy for this node and everything below it. An email without an account becomes an invitation.",
+ "empty": "No members yet",
"messages": {
- "created": "Branch created",
- "deleted": "Branch deleted",
- "updated": "Branch updated"
+ "added": "Member added",
+ "removed": "Member removed"
+ },
+ "remove_action": "Remove member",
+ "remove_confirm": {
+ "message": "{{email}} will no longer buy for this company. Their customer account is not affected.",
+ "title": "Remove this member?"
},
- "shipping_address": "Shipping address",
- "shipping_same_as_billing": "Shipping address is the same as billing",
- "title": "Branches"
+ "roles_enterprise_help": "Members you add here can buy for this company and manage its directory. Roles, approval workflows and spending limits come with Spree Enterprise.",
+ "roles_enterprise_title": "Roles and approvals are an Enterprise feature",
+ "title": "Members"
},
"components": {
"adjustment_action_editor": {
@@ -770,6 +871,17 @@
"label": "Scopes"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "Wholesale"
+ },
+ "price_list": {
+ "empty": "No price lists found",
+ "help": "Optional. Without one, the catalog only narrows the assortment and base prices apply.",
+ "label": "Price list",
+ "placeholder": "Base prices"
+ }
+ },
"certificate_document": {
"help": "PDF or image, up to 10 MB. Only staff can download it.",
"label": "Certificate document"
@@ -890,21 +1002,30 @@
"help": "Your own reference for this business, unique within the store.",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "A company is a legal entity that can hold tax registrations. A division borrows its legal entity’s.",
+ "label": "Kind"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "Role"
+ "company_address": {
+ "label": {
+ "help": "How this site is referred to — \"Headquarters\", \"Plant 2 dock\".",
+ "label": "Label",
+ "placeholder": "Headquarters"
}
},
"company_location": {
"external_id": {
"help": "Your own reference for this branch."
- },
- "name": {
- "placeholder": "Head office"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "An existing customer joins immediately; anyone else gets an emailed invitation.",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2162,6 +2283,7 @@
},
"nav": {
"account": "Account",
+ "catalogs": "Catalogs",
"categories": "Categories",
"claims": "Claims",
"collections": "Collections",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index fe6170deb8..fcd723c374 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -87,6 +87,77 @@
"tiered_flat_rate": "Tarif forfaitaire par paliers",
"tiered_percent": "Pourcentage par paliers"
},
+ "catalogs": {
+ "add_cta": "Ajouter un catalogue",
+ "add_sheet_title": "Nouveau catalogue",
+ "assignable_types": {
+ "channel": "Canal",
+ "company": "Entreprise",
+ "customer_group": "Groupe de clients",
+ "market": "Marché"
+ },
+ "assignments": {
+ "add_cta": "Affecter",
+ "add_title": "Affecter ce catalogue",
+ "audience_empty": "Rien trouvé",
+ "audience_label": "Audience",
+ "audience_placeholder": "Rechercher…",
+ "company_subtree_help": "L’affectation à une entreprise couvre tout son sous-arbre.",
+ "dialog_description": "Qui voit ce catalogue. Une affectation à une entreprise couvre le nœud et tout ce qui se trouve en dessous.",
+ "empty": "Affecté à aucune audience — personne ne voit ce catalogue.",
+ "remove_confirm": {
+ "message": "{{name}} ne verra plus ce catalogue.",
+ "title": "Retirer cette affectation ?"
+ },
+ "title": "Audiences",
+ "type_label": "Type d’audience"
+ },
+ "create_description": "Un catalogue restreint ce qu’une audience voit et, via une liste de prix, ce qu’elle paie. Ajoutez ensuite produits et audiences.",
+ "create_label": "Créer le catalogue",
+ "delete_confirm": {
+ "message": "Cela supprime {{name}} et ses affectations. Les produits et listes de prix ne sont pas affectés.",
+ "title": "Supprimer le catalogue ?"
+ },
+ "detail": {
+ "delete_label": "Supprimer le catalogue",
+ "load_error": "Impossible de charger ce catalogue",
+ "settings": "Catalogue"
+ },
+ "empty": "Aucun catalogue pour le moment",
+ "messages": {
+ "assigned": "Catalogue affecté",
+ "created": "Catalogue créé",
+ "deleted": "Catalogue supprimé",
+ "product_removed": "Produit retiré",
+ "products_added": "Produits ajoutés",
+ "products_removed": "Produits retirés",
+ "unassigned": "Affectation retirée",
+ "updated": "Catalogue mis à jour"
+ },
+ "products": {
+ "add_cta": "Ajouter des produits",
+ "column_product": "Produit",
+ "empty": "Aucun produit dans ce catalogue pour le moment.",
+ "filter_placeholder": "Filtrer les produits…",
+ "no_matches": "Aucun produit ne correspond à votre filtre.",
+ "picker_description": "Recherchez et sélectionnez des produits à ajouter à ce catalogue.",
+ "picker_title": "Ajouter des produits au catalogue",
+ "remove": "Retirer du catalogue",
+ "remove_confirm": {
+ "message_named": "Retirer « {{name}} » de ce catalogue ? Effet immédiat. Le produit reste dans votre boutique.",
+ "message_one": "Retirer {{count}} produit de ce catalogue ? Effet immédiat. Les produits restent dans votre boutique.",
+ "message_other": "Retirer {{count}} produits de ce catalogue ? Effet immédiat. Les produits restent dans votre boutique.",
+ "title": "Retirer du catalogue"
+ },
+ "remove_selected": "Retirer",
+ "search_placeholder": "Rechercher des produits…",
+ "select_all": "Tout sélectionner",
+ "select_row": "Sélectionner le produit",
+ "title": "Produits"
+ },
+ "products_column": "Produits",
+ "search_placeholder": "Rechercher des catalogues"
+ },
"categories": {
"add_cta": "Nouvelle catégorie",
"collapse": "Réduire",
@@ -315,66 +386,96 @@
"companies": {
"add_cta": "Ajouter une entreprise",
"add_sheet_title": "Nouvelle entreprise",
- "create_description": "Les clients professionnels achètent via des établissements. Vous pourrez ajouter des établissements, un numéro de TVA et des attestations d'exonération une fois l'entreprise créée.",
- "create_label": "Créer l'entreprise",
+ "collapse_node": "Replier",
+ "create_description": "Une entreprise est la racine d’un arbre organisationnel. Ajoutez ensuite sous-unités, membres, adresses, immatriculation fiscale et certificats d’exonération.",
+ "create_label": "Créer l’entreprise",
"delete_confirm": {
- "message": "Cela supprime {{name}} ainsi que ses établissements, ses acheteurs et ses attestations. Cette action est irréversible.",
- "title": "Supprimer l'entreprise ?"
+ "message": "Cela supprime {{name}} et tout son sous-arbre — sous-unités, membres, adresses et certificats. Cette action est irréversible.",
+ "title": "Supprimer l’entreprise ?"
},
"detail": {
- "delete_label": "Supprimer l'entreprise",
+ "delete_label": "Supprimer l’entreprise",
+ "division_tax_pointer": "Une division ne détient pas d’immatriculations fiscales propres. Ses achats sont taxés via son entité juridique :",
"load_error": "Impossible de charger cette entreprise",
"profile": "Entreprise"
},
"empty": "Aucune entreprise pour le moment",
- "locations_column": "Établissements",
+ "expand_node": "Déplier",
+ "kind": {
+ "company": "Entreprise",
+ "division": "Division"
+ },
+ "load_more": "Afficher plus…",
+ "members_count_one": "{{count}} membre",
+ "members_count_other": "{{count}} membres",
"messages": {
"created": "Entreprise créée",
"deleted": "Entreprise supprimée",
"updated": "Entreprise mise à jour"
},
- "search_placeholder": "Rechercher des entreprises"
+ "search_empty": "Aucune entreprise ne correspond à votre recherche",
+ "search_placeholder": "Rechercher des entreprises",
+ "sub_units": {
+ "add_cta": "Ajouter une sous-unité",
+ "add_description": "Une division est une unité organisationnelle qui partage l’identité fiscale de son entité juridique. Une entreprise est une entité juridique à part entière, avec ses propres immatriculations.",
+ "add_title": "Nouvelle sous-unité de {{name}}",
+ "empty": "Aucune sous-unité pour le moment",
+ "title": "Sous-unités"
+ }
},
- "company_contacts": {
- "add_cta": "Ajouter un acheteur",
- "add_title": "Autoriser un acheteur",
- "dialog_description": "Un client qui achète pour cet établissement. Celui qui achète pour un seul établissement voit ses commandes rattachées automatiquement.",
- "empty": "Aucun acheteur autorisé pour le moment",
+ "company_addresses": {
+ "add_cta": "Ajouter une adresse",
+ "add_sheet_title": "Nouvelle adresse",
+ "address_legend": "Adresse",
+ "default_billing": "Facturation par défaut",
+ "default_billing_label": "Utiliser comme adresse de facturation par défaut",
+ "default_shipping": "Livraison par défaut",
+ "default_shipping_label": "Utiliser comme adresse de livraison par défaut",
+ "edit_sheet_title": "Modifier l’adresse",
+ "empty": "Aucune adresse pour le moment",
"messages": {
- "created": "Acheteur ajouté",
- "deleted": "Acheteur retiré"
+ "created": "Adresse ajoutée",
+ "deleted": "Adresse supprimée",
+ "updated": "Adresse mise à jour"
},
- "remove_action": "Retirer l'acheteur",
"remove_confirm": {
- "message": "{{email}} n'achètera plus pour cet établissement. Son compte client n'est pas modifié.",
- "title": "Retirer cet acheteur ?"
+ "message": "{{label}} sera retirée du carnet d’adresses. Cette action est irréversible.",
+ "title": "Supprimer cette adresse ?"
},
- "roles_enterprise_help": "Les acheteurs ajoutés ici peuvent commander pour cet établissement. Les rôles, circuits de validation et plafonds de dépenses font partie de Spree Enterprise.",
- "roles_enterprise_title": "Les rôles et validations sont une fonctionnalité Enterprise",
- "title": "Acheteurs"
+ "sheet_description": "Un site de livraison ou de facturation nommé pour ce nœud. Au plus un défaut de chaque type ; en promouvoir un rétrograde le précédent.",
+ "title": "Carnet d’adresses"
},
- "company_locations": {
- "add_cta": "Ajouter un établissement",
- "add_title": "Nouvel établissement",
- "addresses": "Adresses",
- "billing_address": "Adresse de facturation",
- "contacts_count_one": "{{count}} acheteur",
- "contacts_count_other": "{{count}} acheteurs",
- "detail": {
- "delete_label": "Supprimer l'établissement",
- "load_error": "Impossible de charger cet établissement"
+ "company_invitations": {
+ "messages": {
+ "revoked": "Invitation révoquée"
+ },
+ "pending_title": "Invitations en attente",
+ "revoke_action": "Révoquer l’invitation",
+ "revoke_confirm": {
+ "message": "L’invitation envoyée à {{email}} cessera de fonctionner.",
+ "title": "Révoquer cette invitation ?"
},
- "dialog_description": "Un établissement est l'adresse de facturation et de livraison de l'entreprise. Les adresses sont facultatives, mais une adresse renseignée exige un nom et un pays.",
- "edit_title": "Modifier l'établissement",
- "empty": "Aucun établissement pour le moment",
+ "status": {
+ "pending": "En attente"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "Ajouter un membre",
+ "add_title": "Ajouter un membre",
+ "dialog_description": "Les membres peuvent acheter pour ce nœud et tout ce qui se trouve en dessous. Un e-mail sans compte devient une invitation.",
+ "empty": "Aucun membre pour le moment",
"messages": {
- "created": "Établissement créé",
- "deleted": "Établissement supprimé",
- "updated": "Établissement mis à jour"
+ "added": "Membre ajouté",
+ "removed": "Membre retiré"
},
- "shipping_address": "Adresse de livraison",
- "shipping_same_as_billing": "L'adresse de livraison est identique à celle de facturation",
- "title": "Établissements"
+ "remove_action": "Retirer le membre",
+ "remove_confirm": {
+ "message": "{{email}} ne pourra plus acheter pour cette entreprise. Son compte client n’est pas affecté.",
+ "title": "Retirer ce membre ?"
+ },
+ "roles_enterprise_help": "Les membres ajoutés ici peuvent acheter pour cette entreprise et gérer son annuaire. Rôles, circuits de validation et plafonds de dépense arrivent avec Spree Enterprise.",
+ "roles_enterprise_title": "Les rôles et validations sont une fonctionnalité Enterprise",
+ "title": "Membres"
},
"components": {
"adjustment_action_editor": {
@@ -770,6 +871,17 @@
"label": "Portées"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "Grossiste"
+ },
+ "price_list": {
+ "empty": "Aucune liste de prix trouvée",
+ "help": "Optionnel. Sans liste, le catalogue ne restreint que l’assortiment et les prix de base s’appliquent.",
+ "label": "Liste de prix",
+ "placeholder": "Prix de base"
+ }
+ },
"certificate_document": {
"help": "PDF ou image, jusqu'à 10 Mo. Seul le personnel peut le télécharger.",
"label": "Document"
@@ -890,21 +1002,30 @@
"help": "Votre propre référence pour cette entreprise, unique dans la boutique.",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "Une entreprise est une entité juridique pouvant détenir des immatriculations fiscales. Une division utilise celles de son entité juridique.",
+ "label": "Type"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "Rôle"
+ "company_address": {
+ "label": {
+ "help": "Comment ce site est désigné — « Siège social », « Quai usine 2 ».",
+ "label": "Libellé",
+ "placeholder": "Siège social"
}
},
"company_location": {
"external_id": {
"help": "Votre propre référence pour cet établissement."
- },
- "name": {
- "placeholder": "Siège social"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "Un client existant rejoint immédiatement ; les autres reçoivent une invitation par e-mail.",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2162,6 +2283,7 @@
},
"nav": {
"account": "Compte",
+ "catalogs": "Catalogues",
"categories": "Catégories",
"claims": "Réclamations",
"collections": "Collections",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 2bc5202a89..da355ff1ec 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -89,6 +89,79 @@
"tiered_flat_rate": "Progowa stawka ryczałtowa",
"tiered_percent": "Procent progowy"
},
+ "catalogs": {
+ "add_cta": "Dodaj katalog",
+ "add_sheet_title": "Nowy katalog",
+ "assignable_types": {
+ "channel": "Kanał",
+ "company": "Firma",
+ "customer_group": "Grupa klientów",
+ "market": "Rynek"
+ },
+ "assignments": {
+ "add_cta": "Przypisz",
+ "add_title": "Przypisz ten katalog",
+ "audience_empty": "Nic nie znaleziono",
+ "audience_label": "Odbiorca",
+ "audience_placeholder": "Szukaj…",
+ "company_subtree_help": "Przypisanie do firmy obejmuje całe jej poddrzewo.",
+ "dialog_description": "Kto widzi ten katalog. Przypisanie do firmy obejmuje węzeł i wszystko poniżej.",
+ "empty": "Nie przypisano do żadnego odbiorcy — nikt nie widzi tego katalogu.",
+ "remove_confirm": {
+ "message": "{{name}} przestanie widzieć ten katalog.",
+ "title": "Usunąć to przypisanie?"
+ },
+ "title": "Odbiorcy",
+ "type_label": "Typ odbiorcy"
+ },
+ "create_description": "Katalog zawęża, co widzi dana grupa odbiorców, a poprzez cennik — ile płaci. Produkty i odbiorców dodasz później.",
+ "create_label": "Utwórz katalog",
+ "delete_confirm": {
+ "message": "To usunie {{name}} wraz z przypisaniami. Produkty i cenniki pozostaną nietknięte.",
+ "title": "Usunąć katalog?"
+ },
+ "detail": {
+ "delete_label": "Usuń katalog",
+ "load_error": "Nie udało się wczytać tego katalogu",
+ "settings": "Katalog"
+ },
+ "empty": "Brak katalogów",
+ "messages": {
+ "assigned": "Katalog przypisany",
+ "created": "Katalog utworzony",
+ "deleted": "Katalog usunięty",
+ "product_removed": "Produkt usunięty",
+ "products_added": "Produkty dodane",
+ "products_removed": "Produkty usunięte",
+ "unassigned": "Przypisanie usunięte",
+ "updated": "Katalog zaktualizowany"
+ },
+ "products": {
+ "add_cta": "Dodaj produkty",
+ "column_product": "Produkt",
+ "empty": "Brak produktów w tym katalogu.",
+ "filter_placeholder": "Filtruj produkty…",
+ "no_matches": "Żaden produkt nie pasuje do filtra.",
+ "picker_description": "Wyszukaj i wybierz produkty do dodania do tego katalogu.",
+ "picker_title": "Dodaj produkty do katalogu",
+ "remove": "Usuń z katalogu",
+ "remove_confirm": {
+ "message_few": "Usunąć {{count}} produkty z tego katalogu? Zmiana działa natychmiast. Produkty pozostają w sklepie.",
+ "message_many": "Usunąć {{count}} produktów z tego katalogu? Zmiana działa natychmiast. Produkty pozostają w sklepie.",
+ "message_named": "Usunąć „{{name}}\" z tego katalogu? Zmiana działa natychmiast. Produkt pozostaje w sklepie.",
+ "message_one": "Usunąć {{count}} produkt z tego katalogu? Zmiana działa natychmiast. Produkty pozostają w sklepie.",
+ "message_other": "Usunąć {{count}} produktów z tego katalogu? Zmiana działa natychmiast. Produkty pozostają w sklepie.",
+ "title": "Usuń z katalogu"
+ },
+ "remove_selected": "Usuń",
+ "search_placeholder": "Szukaj produktów…",
+ "select_all": "Zaznacz wszystko",
+ "select_row": "Zaznacz produkt",
+ "title": "Produkty"
+ },
+ "products_column": "Produkty",
+ "search_placeholder": "Szukaj katalogów"
+ },
"categories": {
"add_cta": "Nowa kategoria",
"collapse": "Zwiń",
@@ -321,68 +394,98 @@
"companies": {
"add_cta": "Dodaj firmę",
"add_sheet_title": "Nowa firma",
- "create_description": "Klienci biznesowi kupują przez oddziały. Oddziały, numer podatkowy i certyfikaty zwolnienia dodasz po utworzeniu firmy.",
+ "collapse_node": "Zwiń",
+ "create_description": "Firma jest korzeniem drzewa organizacji. Jednostki podrzędne, członków, adresy, rejestracje podatkowe i certyfikaty zwolnień dodasz później.",
"create_label": "Utwórz firmę",
"delete_confirm": {
- "message": "Spowoduje to usunięcie {{name}} wraz z oddziałami, kupującymi i certyfikatami. Tej operacji nie można cofnąć.",
+ "message": "To usunie {{name}} wraz z całym poddrzewem — jednostkami, członkami, adresami i certyfikatami. Tej operacji nie można cofnąć.",
"title": "Usunąć firmę?"
},
"detail": {
"delete_label": "Usuń firmę",
+ "division_tax_pointer": "Oddział nie posiada własnych rejestracji podatkowych. Jego zakupy są opodatkowane przez jego podmiot prawny:",
"load_error": "Nie udało się wczytać tej firmy",
"profile": "Firma"
},
- "empty": "Nie ma jeszcze żadnych firm",
- "locations_column": "Oddziały",
+ "empty": "Brak firm",
+ "expand_node": "Rozwiń",
+ "kind": {
+ "company": "Firma",
+ "division": "Oddział"
+ },
+ "load_more": "Pokaż więcej…",
+ "members_count_few": "{{count}} członków",
+ "members_count_many": "{{count}} członków",
+ "members_count_one": "{{count}} członek",
+ "members_count_other": "{{count}} członków",
"messages": {
"created": "Firma utworzona",
"deleted": "Firma usunięta",
"updated": "Firma zaktualizowana"
},
- "search_placeholder": "Szukaj firm"
+ "search_empty": "Żadna firma nie pasuje do wyszukiwania",
+ "search_placeholder": "Szukaj firm",
+ "sub_units": {
+ "add_cta": "Dodaj jednostkę",
+ "add_description": "Oddział to jednostka organizacyjna dzieląca tożsamość podatkową swojego podmiotu prawnego. Firma to osobny podmiot prawny z własnymi rejestracjami.",
+ "add_title": "Nowa jednostka w {{name}}",
+ "empty": "Brak jednostek podrzędnych",
+ "title": "Jednostki podrzędne"
+ }
},
- "company_contacts": {
- "add_cta": "Dodaj kupującego",
- "add_title": "Uprawnij kupującego",
- "dialog_description": "Klient, który kupuje dla tego oddziału. Jeśli kupuje tylko dla jednego oddziału, jego zamówienia trafiają do niego automatycznie.",
- "empty": "Nie uprawniono jeszcze żadnych kupujących",
+ "company_addresses": {
+ "add_cta": "Dodaj adres",
+ "add_sheet_title": "Nowy adres",
+ "address_legend": "Adres",
+ "default_billing": "Domyślny rozliczeniowy",
+ "default_billing_label": "Ustaw jako domyślny adres rozliczeniowy",
+ "default_shipping": "Domyślny dostawy",
+ "default_shipping_label": "Ustaw jako domyślny adres dostawy",
+ "edit_sheet_title": "Edytuj adres",
+ "empty": "Brak adresów",
"messages": {
- "created": "Kupujący dodany",
- "deleted": "Kupujący usunięty"
+ "created": "Adres dodany",
+ "deleted": "Adres usunięty",
+ "updated": "Adres zaktualizowany"
},
- "remove_action": "Usuń kupującego",
"remove_confirm": {
- "message": "{{email}} nie będzie już kupować dla tego oddziału. Konto klienta pozostaje bez zmian.",
- "title": "Usunąć tego kupującego?"
+ "message": "{{label}} zostanie usunięty z książki adresowej. Tej operacji nie można cofnąć.",
+ "title": "Usunąć ten adres?"
},
- "roles_enterprise_help": "Dodani tutaj kupujący mogą składać zamówienia dla tego oddziału. Role, procesy akceptacji i limity wydatków są częścią Spree Enterprise.",
- "roles_enterprise_title": "Role i akceptacje to funkcja Enterprise",
- "title": "Kupujący"
+ "sheet_description": "Nazwany adres dostawy lub rozliczeń tego węzła. Najwyżej jeden domyślny każdego rodzaju; nowy domyślny zastępuje poprzedni.",
+ "title": "Książka adresowa"
},
- "company_locations": {
- "add_cta": "Dodaj oddział",
- "add_title": "Nowy oddział",
- "addresses": "Adresy",
- "billing_address": "Adres rozliczeniowy",
- "contacts_count_few": "{{count}} kupujących",
- "contacts_count_many": "{{count}} kupujących",
- "contacts_count_one": "{{count}} kupujący",
- "contacts_count_other": "{{count}} kupujących",
- "detail": {
- "delete_label": "Usuń oddział",
- "load_error": "Nie udało się wczytać tego oddziału"
+ "company_invitations": {
+ "messages": {
+ "revoked": "Zaproszenie cofnięte"
+ },
+ "pending_title": "Oczekujące zaproszenia",
+ "revoke_action": "Cofnij zaproszenie",
+ "revoke_confirm": {
+ "message": "Zaproszenie wysłane na {{email}} przestanie działać.",
+ "title": "Cofnąć to zaproszenie?"
},
- "dialog_description": "Oddział to miejsce, na które wystawiana jest faktura i pod które trafia dostawa. Adresy są opcjonalne, ale wypełniony adres wymaga imienia, nazwiska i kraju.",
- "edit_title": "Edytuj oddział",
- "empty": "Nie ma jeszcze żadnych oddziałów",
+ "status": {
+ "pending": "Oczekujące"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "Dodaj członka",
+ "add_title": "Dodaj członka",
+ "dialog_description": "Członkowie mogą kupować dla tego węzła i wszystkiego poniżej. E-mail bez konta stanie się zaproszeniem.",
+ "empty": "Brak członków",
"messages": {
- "created": "Oddział utworzony",
- "deleted": "Oddział usunięty",
- "updated": "Oddział zaktualizowany"
+ "added": "Członek dodany",
+ "removed": "Członek usunięty"
},
- "shipping_address": "Adres dostawy",
- "shipping_same_as_billing": "Adres dostawy taki sam jak rozliczeniowy",
- "title": "Oddziały"
+ "remove_action": "Usuń członka",
+ "remove_confirm": {
+ "message": "{{email}} nie będzie już kupować dla tej firmy. Konto klienta pozostaje nietknięte.",
+ "title": "Usunąć tego członka?"
+ },
+ "roles_enterprise_help": "Dodani tu członkowie mogą kupować dla tej firmy i zarządzać jej katalogiem osób. Role, ścieżki akceptacji i limity wydatków są dostępne w Spree Enterprise.",
+ "roles_enterprise_title": "Role i akceptacje to funkcja Enterprise",
+ "title": "Członkowie"
},
"components": {
"adjustment_action_editor": {
@@ -786,6 +889,17 @@
"label": "Zakresy"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "Hurt"
+ },
+ "price_list": {
+ "empty": "Nie znaleziono cenników",
+ "help": "Opcjonalny. Bez cennika katalog zawęża tylko asortyment i obowiązują ceny podstawowe.",
+ "label": "Cennik",
+ "placeholder": "Ceny podstawowe"
+ }
+ },
"certificate_document": {
"help": "PDF lub obraz, do 10 MB. Pobrać go mogą tylko pracownicy.",
"label": "Dokument"
@@ -906,21 +1020,30 @@
"help": "Twój własny identyfikator tej firmy, unikalny w sklepie.",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "Firma to podmiot prawny mogący posiadać rejestracje podatkowe. Oddział korzysta z rejestracji swojego podmiotu prawnego.",
+ "label": "Rodzaj"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "Rola"
+ "company_address": {
+ "label": {
+ "help": "Jak nazywany jest ten adres — „Siedziba główna\", „Rampa zakładu 2\".",
+ "label": "Etykieta",
+ "placeholder": "Siedziba główna"
}
},
"company_location": {
"external_id": {
"help": "Twój własny identyfikator tego oddziału."
- },
- "name": {
- "placeholder": "Siedziba główna"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "Istniejący klient dołącza od razu; pozostali otrzymują zaproszenie e-mailem.",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2182,6 +2305,7 @@
},
"nav": {
"account": "Konto",
+ "catalogs": "Katalogi",
"categories": "Kategorie",
"claims": "Reklamacje",
"collections": "Kolekcje",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index bd938c6de3..c3302033a7 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -87,6 +87,76 @@
"tiered_flat_rate": "阶梯固定费率",
"tiered_percent": "阶梯百分比"
},
+ "catalogs": {
+ "add_cta": "添加目录",
+ "add_sheet_title": "新建目录",
+ "assignable_types": {
+ "channel": "渠道",
+ "company": "公司",
+ "customer_group": "客户组",
+ "market": "市场"
+ },
+ "assignments": {
+ "add_cta": "分配",
+ "add_title": "分配该目录",
+ "audience_empty": "未找到结果",
+ "audience_label": "受众",
+ "audience_placeholder": "搜索…",
+ "company_subtree_help": "分配给公司将覆盖其整个子树。",
+ "dialog_description": "谁能看到该目录。分配给公司将覆盖该节点及其下所有单位。",
+ "empty": "尚未分配给任何受众——没有人能看到该目录。",
+ "remove_confirm": {
+ "message": "{{name}} 将不再看到该目录。",
+ "title": "移除该分配?"
+ },
+ "title": "受众",
+ "type_label": "受众类型"
+ },
+ "create_description": "目录限定某类受众能看到什么,并通过价格表决定其价格。创建后可添加产品和受众。",
+ "create_label": "创建目录",
+ "delete_confirm": {
+ "message": "这将删除 {{name}} 及其分配。产品和价格表不受影响。",
+ "title": "删除目录?"
+ },
+ "detail": {
+ "delete_label": "删除目录",
+ "load_error": "无法加载该目录",
+ "settings": "目录"
+ },
+ "empty": "暂无目录",
+ "messages": {
+ "assigned": "目录已分配",
+ "created": "目录已创建",
+ "deleted": "目录已删除",
+ "product_removed": "产品已移除",
+ "products_added": "产品已添加",
+ "products_removed": "产品已移除",
+ "unassigned": "分配已移除",
+ "updated": "目录已更新"
+ },
+ "products": {
+ "add_cta": "添加产品",
+ "column_product": "产品",
+ "empty": "该目录中暂无产品。",
+ "filter_placeholder": "筛选产品…",
+ "no_matches": "没有匹配筛选条件的产品。",
+ "picker_description": "搜索并选择要添加到该目录的产品。",
+ "picker_title": "向目录添加产品",
+ "remove": "从目录中移除",
+ "remove_confirm": {
+ "message_named": "将“{{name}}”从该目录中移除?立即生效。产品仍保留在您的商店中。",
+ "message_other": "将 {{count}} 个产品从该目录中移除?立即生效。产品仍保留在您的商店中。",
+ "title": "从目录中移除"
+ },
+ "remove_selected": "移除",
+ "search_placeholder": "搜索产品…",
+ "select_all": "全选",
+ "select_row": "选择产品",
+ "title": "产品"
+ },
+ "products_column": "产品",
+ "search_placeholder": "搜索目录"
+ },
"categories": {
"add_cta": "新建分类",
"collapse": "收起",
@@ -313,68 +383,97 @@
"search_placeholder": "按名称搜索…"
},
"companies": {
- "add_cta": "添加企业",
- "add_sheet_title": "新建企业",
- "create_description": "企业客户通过分支机构下单。创建企业后即可添加分支机构、税务登记号和免税证明。",
- "create_label": "创建企业",
+ "add_cta": "添加公司",
+ "add_sheet_title": "新建公司",
+ "collapse_node": "折叠",
+ "create_description": "公司是组织树的根节点。创建后可以添加子单位、成员、地址、税务登记和免税证书。",
+ "create_label": "创建公司",
"delete_confirm": {
- "message": "将删除 {{name}} 及其所有分支机构、采购人和证明。此操作无法撤销。",
- "title": "删除企业?"
+ "message": "这将删除 {{name}} 及其整个子树——子单位、成员、地址和证书。此操作无法撤销。",
+ "title": "删除公司?"
},
"detail": {
- "delete_label": "删除企业",
- "load_error": "无法加载该企业",
- "profile": "企业"
- },
- "empty": "暂无企业",
- "locations_column": "分支机构",
+ "delete_label": "删除公司",
+ "division_tax_pointer": "部门没有自己的税务登记。其采购通过其法律实体计税:",
+ "load_error": "无法加载该公司",
+ "profile": "公司"
+ },
+ "empty": "暂无公司",
+ "expand_node": "展开",
+ "kind": {
+ "company": "公司",
+ "division": "部门"
+ },
+ "load_more": "显示更多…",
+ "members_count_other": "{{count}} 名成员",
"messages": {
- "created": "企业已创建",
- "deleted": "企业已删除",
- "updated": "企业已更新"
- },
- "search_placeholder": "搜索企业"
+ "created": "公司已创建",
+ "deleted": "公司已删除",
+ "updated": "公司已更新"
+ },
+ "search_empty": "没有匹配的公司",
+ "search_placeholder": "搜索公司",
+ "sub_units": {
+ "add_cta": "添加子单位",
+ "add_description": "部门是共享其法律实体税务身份的组织单位。公司则是拥有自己登记的独立法律实体。",
+ "add_title": "在 {{name}} 下新建子单位",
+ "empty": "暂无子单位",
+ "title": "子单位"
+ }
},
- "company_contacts": {
- "add_cta": "添加采购人",
- "add_title": "授权采购人",
- "dialog_description": "为该分支机构下单的客户。若客户只为一个分支机构采购,其订单会自动归属该机构。",
- "empty": "尚未授权任何采购人",
+ "company_addresses": {
+ "add_cta": "添加地址",
+ "add_sheet_title": "新建地址",
+ "address_legend": "地址",
+ "default_billing": "默认账单",
+ "default_billing_label": "设为默认账单地址",
+ "default_shipping": "默认收货",
+ "default_shipping_label": "设为默认收货地址",
+ "edit_sheet_title": "编辑地址",
+ "empty": "暂无地址",
"messages": {
- "created": "采购人已添加",
- "deleted": "采购人已移除"
+ "created": "地址已添加",
+ "deleted": "地址已移除",
+ "updated": "地址已更新"
},
- "remove_action": "移除采购人",
"remove_confirm": {
- "message": "{{email}} 将不再为该分支机构采购。其客户账户不受影响。",
- "title": "移除该采购人?"
+ "message": "{{label}} 将从地址簿中移除。此操作无法撤销。",
+ "title": "删除该地址?"
},
- "roles_enterprise_help": "在此添加的采购人可为该分支机构下单。角色、审批流程和支出限额由 Spree Enterprise 提供。",
- "roles_enterprise_title": "角色与审批为 Enterprise 功能",
- "title": "采购人"
+ "sheet_description": "该节点的具名收货或账单地址。每种默认地址至多一个;设置新的默认地址会替换之前的。",
+ "title": "地址簿"
},
- "company_locations": {
- "add_cta": "添加分支机构",
- "add_title": "新建分支机构",
- "addresses": "地址",
- "billing_address": "账单地址",
- "contacts_count_one": "{{count}} 位采购人",
- "contacts_count_other": "{{count}} 位采购人",
- "detail": {
- "delete_label": "删除分支机构",
- "load_error": "无法加载该分支机构"
+ "company_invitations": {
+ "messages": {
+ "revoked": "邀请已撤销"
+ },
+ "pending_title": "待处理邀请",
+ "revoke_action": "撤销邀请",
+ "revoke_confirm": {
+ "message": "发送给 {{email}} 的邀请将失效。",
+ "title": "撤销该邀请?"
},
- "dialog_description": "分支机构是开具发票和收货的地点。地址为选填,但一旦填写则需要姓名和国家/地区。",
- "edit_title": "编辑分支机构",
- "empty": "暂无分支机构",
+ "status": {
+ "pending": "待处理"
+ }
+ },
+ "company_memberships": {
+ "add_cta": "添加成员",
+ "add_title": "添加成员",
+ "dialog_description": "成员可以为该节点及其下所有单位采购。没有账户的邮箱将收到邀请。",
+ "empty": "暂无成员",
"messages": {
- "created": "分支机构已创建",
- "deleted": "分支机构已删除",
- "updated": "分支机构已更新"
+ "added": "成员已添加",
+ "removed": "成员已移除"
+ },
+ "remove_action": "移除成员",
+ "remove_confirm": {
+ "message": "{{email}} 将不能再为该公司采购。其客户账户不受影响。",
+ "title": "移除该成员?"
},
- "shipping_address": "收货地址",
- "shipping_same_as_billing": "收货地址与账单地址相同",
- "title": "分支机构"
+ "roles_enterprise_help": "在此添加的成员可以为该公司采购并管理其目录。角色、审批流程和支出限额随 Spree Enterprise 提供。",
+ "roles_enterprise_title": "角色与审批是 Enterprise 功能",
+ "title": "成员"
},
"components": {
"adjustment_action_editor": {
@@ -767,6 +866,17 @@
"label": "权限范围"
}
},
+ "catalog": {
+ "name": {
+ "placeholder": "批发"
+ },
+ "price_list": {
+ "empty": "未找到价格表",
+ "help": "可选。不设置价格表时,目录仅限定商品范围,按基础价格计价。",
+ "label": "价格表",
+ "placeholder": "基础价格"
+ }
+ },
"certificate_document": {
"help": "PDF 或图片,最大 10 MB。仅员工可下载。",
"label": "证明文件"
@@ -887,21 +997,30 @@
"help": "您为该企业设定的编号,在本店内唯一。",
"placeholder": "ACME-001"
},
+ "kind": {
+ "help": "公司是可持有税务登记的法律实体。部门使用其法律实体的登记。",
+ "label": "类型"
+ },
"name": {
"placeholder": "Acme Industries"
}
},
- "company_contact": {
- "role": {
- "label": "职务"
+ "company_address": {
+ "label": {
+ "help": "该地点的称呼——“总部”、“2 号厂区装卸口”。",
+ "label": "标签",
+ "placeholder": "总部"
}
},
"company_location": {
"external_id": {
"help": "您为该分支机构设定的编号。"
- },
- "name": {
- "placeholder": "总部"
+ }
+ },
+ "company_membership": {
+ "email": {
+ "help": "已有客户会立即加入;其他人将收到电子邮件邀请。",
+ "placeholder": "[email protected]"
}
},
"country": {
@@ -2157,6 +2276,7 @@
},
"nav": {
"account": "账户",
+ "catalogs": "产品目录",
"categories": "分类",
"claims": "索赔",
"collections": "系列",
diff --git a/packages/dashboard/src/nav/default.ts b/packages/dashboard/src/nav/default.ts
index 9214e4015c..95eb5f71fb 100644
--- a/packages/dashboard/src/nav/default.ts
+++ b/packages/dashboard/src/nav/default.ts
@@ -103,6 +103,13 @@ nav.add({
subject: Subject.PriceList,
position: 100,
},
+ {
+ key: 'products.catalogs',
+ labelKey: 'admin.nav.catalogs',
+ path: '/products/catalogs',
+ subject: Subject.Catalog,
+ position: 200,
+ },
{
key: 'products.categories',
labelKey: 'admin.nav.categories',
diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.ts
index c4d95e4f45..9df97447cb 100644
--- a/packages/dashboard/src/routeTree.gen.ts
+++ b/packages/dashboard/src/routeTree.gen.ts
@@ -69,6 +69,7 @@ import { Route as SettingsDeliveryProfilesIndexRouteImport } from './routes/_aut
import { Route as ProductsPriceListsIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/index'
import { Route as ProductsCollectionsIndexRouteImport } from './routes/_authenticated/$storeId/products/collections/index'
import { Route as ProductsCategoriesIndexRouteImport } from './routes/_authenticated/$storeId/products/categories/index'
+import { Route as ProductsCatalogsIndexRouteImport } from './routes/_authenticated/$storeId/products/catalogs/index'
import { Route as OrdersOrderIdIndexRouteImport } from './routes/_authenticated/$storeId/orders/$orderId/index'
import { Route as SettingsWebhooksWebhookEndpointIdRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'
import { Route as ProductsPriceListsNewRouteImport } from './routes/_authenticated/$storeId/products/price-lists/new'
@@ -76,8 +77,8 @@ import { Route as ProductsCollectionsNewRouteImport } from './routes/_authentica
import { Route as ProductsCollectionsCollectionIdRouteImport } from './routes/_authenticated/$storeId/products/collections/$collectionId'
import { Route as ProductsCategoriesNewRouteImport } from './routes/_authenticated/$storeId/products/categories/new'
import { Route as ProductsCategoriesCategoryIdRouteImport } from './routes/_authenticated/$storeId/products/categories/$categoryId'
+import { Route as ProductsCatalogsCatalogIdRouteImport } from './routes/_authenticated/$storeId/products/catalogs/$catalogId'
import { Route as OrdersOrderIdEditRouteImport } from './routes/_authenticated/$storeId/orders/$orderId/edit'
-import { Route as CompaniesLocationsDotlocationIdRouteImport } from './routes/_authenticated/$storeId/companies/locations.$locationId'
import { Route as SettingsDeliveryProfilesProfileIdIndexRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index'
import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/$priceListId/index'
import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
@@ -387,6 +388,11 @@ const ProductsCategoriesIndexRoute = ProductsCategoriesIndexRouteImport.update({
path: '/products/categories/',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const ProductsCatalogsIndexRoute = ProductsCatalogsIndexRouteImport.update({
+ id: '/products/catalogs/',
+ path: '/products/catalogs/',
+ getParentRoute: () => authenticatedStoreIdRoute,
+} as any)
const OrdersOrderIdIndexRoute = OrdersOrderIdIndexRouteImport.update({
id: '/orders/$orderId/',
path: '/orders/$orderId/',
@@ -425,17 +431,17 @@ const ProductsCategoriesCategoryIdRoute =
path: '/products/categories/$categoryId',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const ProductsCatalogsCatalogIdRoute =
+ ProductsCatalogsCatalogIdRouteImport.update({
+ id: '/products/catalogs/$catalogId',
+ path: '/products/catalogs/$catalogId',
+ getParentRoute: () => authenticatedStoreIdRoute,
+ } as any)
const OrdersOrderIdEditRoute = OrdersOrderIdEditRouteImport.update({
id: '/orders/$orderId/edit',
path: '/orders/$orderId/edit',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
-const CompaniesLocationsDotlocationIdRoute =
- CompaniesLocationsDotlocationIdRouteImport.update({
- id: '/companies/locations/$locationId',
- path: '/companies/locations/$locationId',
- getParentRoute: () => authenticatedStoreIdRoute,
- } as any)
const SettingsDeliveryProfilesProfileIdIndexRoute =
SettingsDeliveryProfilesProfileIdIndexRouteImport.update({
id: '/delivery-profiles/$profileId/',
@@ -515,8 +521,8 @@ export interface FileRoutesByFullPath {
'/$storeId/promotions/': typeof PromotionsIndexRoute
'/$storeId/sellers/': typeof SellersIndexRoute
'/$storeId/settings/': typeof SettingsIndexRoute
- '/$storeId/companies/locations/$locationId': typeof CompaniesLocationsDotlocationIdRoute
'/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute
+ '/$storeId/products/catalogs/$catalogId': typeof ProductsCatalogsCatalogIdRoute
'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute
'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute
'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute
@@ -524,6 +530,7 @@ export interface FileRoutesByFullPath {
'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute
'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute
'/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute
+ '/$storeId/products/catalogs/': typeof ProductsCatalogsIndexRoute
'/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute
'/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute
'/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute
@@ -587,8 +594,8 @@ export interface FileRoutesByTo {
'/$storeId/promotions': typeof PromotionsIndexRoute
'/$storeId/sellers': typeof SellersIndexRoute
'/$storeId/settings': typeof SettingsIndexRoute
- '/$storeId/companies/locations/$locationId': typeof CompaniesLocationsDotlocationIdRoute
'/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute
+ '/$storeId/products/catalogs/$catalogId': typeof ProductsCatalogsCatalogIdRoute
'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute
'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute
'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute
@@ -596,6 +603,7 @@ export interface FileRoutesByTo {
'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute
'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute
'/$storeId/orders/$orderId': typeof OrdersOrderIdIndexRoute
+ '/$storeId/products/catalogs': typeof ProductsCatalogsIndexRoute
'/$storeId/products/categories': typeof ProductsCategoriesIndexRoute
'/$storeId/products/collections': typeof ProductsCollectionsIndexRoute
'/$storeId/products/price-lists': typeof ProductsPriceListsIndexRoute
@@ -663,8 +671,8 @@ export interface FileRoutesById {
'/_authenticated/$storeId/promotions/': typeof PromotionsIndexRoute
'/_authenticated/$storeId/sellers/': typeof SellersIndexRoute
'/_authenticated/$storeId/settings/': typeof SettingsIndexRoute
- '/_authenticated/$storeId/companies/locations/$locationId': typeof CompaniesLocationsDotlocationIdRoute
'/_authenticated/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute
+ '/_authenticated/$storeId/products/catalogs/$catalogId': typeof ProductsCatalogsCatalogIdRoute
'/_authenticated/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute
'/_authenticated/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute
'/_authenticated/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute
@@ -672,6 +680,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute
'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute
'/_authenticated/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute
+ '/_authenticated/$storeId/products/catalogs/': typeof ProductsCatalogsIndexRoute
'/_authenticated/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute
'/_authenticated/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute
'/_authenticated/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute
@@ -739,8 +748,8 @@ export interface FileRouteTypes {
| '/$storeId/promotions/'
| '/$storeId/sellers/'
| '/$storeId/settings/'
- | '/$storeId/companies/locations/$locationId'
| '/$storeId/orders/$orderId/edit'
+ | '/$storeId/products/catalogs/$catalogId'
| '/$storeId/products/categories/$categoryId'
| '/$storeId/products/categories/new'
| '/$storeId/products/collections/$collectionId'
@@ -748,6 +757,7 @@ export interface FileRouteTypes {
| '/$storeId/products/price-lists/new'
| '/$storeId/settings/webhooks/$webhookEndpointId'
| '/$storeId/orders/$orderId/'
+ | '/$storeId/products/catalogs/'
| '/$storeId/products/categories/'
| '/$storeId/products/collections/'
| '/$storeId/products/price-lists/'
@@ -811,8 +821,8 @@ export interface FileRouteTypes {
| '/$storeId/promotions'
| '/$storeId/sellers'
| '/$storeId/settings'
- | '/$storeId/companies/locations/$locationId'
| '/$storeId/orders/$orderId/edit'
+ | '/$storeId/products/catalogs/$catalogId'
| '/$storeId/products/categories/$categoryId'
| '/$storeId/products/categories/new'
| '/$storeId/products/collections/$collectionId'
@@ -820,6 +830,7 @@ export interface FileRouteTypes {
| '/$storeId/products/price-lists/new'
| '/$storeId/settings/webhooks/$webhookEndpointId'
| '/$storeId/orders/$orderId'
+ | '/$storeId/products/catalogs'
| '/$storeId/products/categories'
| '/$storeId/products/collections'
| '/$storeId/products/price-lists'
@@ -886,8 +897,8 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/promotions/'
| '/_authenticated/$storeId/sellers/'
| '/_authenticated/$storeId/settings/'
- | '/_authenticated/$storeId/companies/locations/$locationId'
| '/_authenticated/$storeId/orders/$orderId/edit'
+ | '/_authenticated/$storeId/products/catalogs/$catalogId'
| '/_authenticated/$storeId/products/categories/$categoryId'
| '/_authenticated/$storeId/products/categories/new'
| '/_authenticated/$storeId/products/collections/$collectionId'
@@ -895,6 +906,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/products/price-lists/new'
| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'
| '/_authenticated/$storeId/orders/$orderId/'
+ | '/_authenticated/$storeId/products/catalogs/'
| '/_authenticated/$storeId/products/categories/'
| '/_authenticated/$storeId/products/collections/'
| '/_authenticated/$storeId/products/price-lists/'
@@ -1338,6 +1350,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProductsCategoriesIndexRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/products/catalogs/': {
+ id: '/_authenticated/$storeId/products/catalogs/'
+ path: '/products/catalogs'
+ fullPath: '/$storeId/products/catalogs/'
+ preLoaderRoute: typeof ProductsCatalogsIndexRouteImport
+ parentRoute: typeof authenticatedStoreIdRoute
+ }
'/_authenticated/$storeId/orders/$orderId/': {
id: '/_authenticated/$storeId/orders/$orderId/'
path: '/orders/$orderId'
@@ -1387,6 +1406,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProductsCategoriesCategoryIdRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/products/catalogs/$catalogId': {
+ id: '/_authenticated/$storeId/products/catalogs/$catalogId'
+ path: '/products/catalogs/$catalogId'
+ fullPath: '/$storeId/products/catalogs/$catalogId'
+ preLoaderRoute: typeof ProductsCatalogsCatalogIdRouteImport
+ parentRoute: typeof authenticatedStoreIdRoute
+ }
'/_authenticated/$storeId/orders/$orderId/edit': {
id: '/_authenticated/$storeId/orders/$orderId/edit'
path: '/orders/$orderId/edit'
@@ -1394,13 +1420,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof OrdersOrderIdEditRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
- '/_authenticated/$storeId/companies/locations/$locationId': {
- id: '/_authenticated/$storeId/companies/locations/$locationId'
- path: '/companies/locations/$locationId'
- fullPath: '/$storeId/companies/locations/$locationId'
- preLoaderRoute: typeof CompaniesLocationsDotlocationIdRouteImport
- parentRoute: typeof authenticatedStoreIdRoute
- }
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': {
id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'
path: '/delivery-profiles/$profileId'
@@ -1526,14 +1545,15 @@ interface authenticatedStoreIdRouteChildren {
ProductsIndexRoute: typeof ProductsIndexRoute
PromotionsIndexRoute: typeof PromotionsIndexRoute
SellersIndexRoute: typeof SellersIndexRoute
- CompaniesLocationsDotlocationIdRoute: typeof CompaniesLocationsDotlocationIdRoute
OrdersOrderIdEditRoute: typeof OrdersOrderIdEditRoute
+ ProductsCatalogsCatalogIdRoute: typeof ProductsCatalogsCatalogIdRoute
ProductsCategoriesCategoryIdRoute: typeof ProductsCategoriesCategoryIdRoute
ProductsCategoriesNewRoute: typeof ProductsCategoriesNewRoute
ProductsCollectionsCollectionIdRoute: typeof ProductsCollectionsCollectionIdRoute
ProductsCollectionsNewRoute: typeof ProductsCollectionsNewRoute
ProductsPriceListsNewRoute: typeof ProductsPriceListsNewRoute
OrdersOrderIdIndexRoute: typeof OrdersOrderIdIndexRoute
+ ProductsCatalogsIndexRoute: typeof ProductsCatalogsIndexRoute
ProductsCategoriesIndexRoute: typeof ProductsCategoriesIndexRoute
ProductsCollectionsIndexRoute: typeof ProductsCollectionsIndexRoute
ProductsPriceListsIndexRoute: typeof ProductsPriceListsIndexRoute
@@ -1568,14 +1588,15 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {
ProductsIndexRoute: ProductsIndexRoute,
PromotionsIndexRoute: PromotionsIndexRoute,
SellersIndexRoute: SellersIndexRoute,
- CompaniesLocationsDotlocationIdRoute: CompaniesLocationsDotlocationIdRoute,
OrdersOrderIdEditRoute: OrdersOrderIdEditRoute,
+ ProductsCatalogsCatalogIdRoute: ProductsCatalogsCatalogIdRoute,
ProductsCategoriesCategoryIdRoute: ProductsCategoriesCategoryIdRoute,
ProductsCategoriesNewRoute: ProductsCategoriesNewRoute,
ProductsCollectionsCollectionIdRoute: ProductsCollectionsCollectionIdRoute,
ProductsCollectionsNewRoute: ProductsCollectionsNewRoute,
ProductsPriceListsNewRoute: ProductsPriceListsNewRoute,
OrdersOrderIdIndexRoute: OrdersOrderIdIndexRoute,
+ ProductsCatalogsIndexRoute: ProductsCatalogsIndexRoute,
ProductsCategoriesIndexRoute: ProductsCategoriesIndexRoute,
ProductsCollectionsIndexRoute: ProductsCollectionsIndexRoute,
ProductsPriceListsIndexRoute: ProductsPriceListsIndexRoute,
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/companies/$companyId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/companies/$companyId.tsx
index e560477a5d..ed8e4264df 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/companies/$companyId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/companies/$companyId.tsx
@@ -1,5 +1,10 @@
import { zodResolver } from '@hookform/resolvers/zod'
-import type { Company, CompanyLocation } from '@spree/admin-sdk'
+import type {
+ Company,
+ CompanyAddress,
+ CompanyInvitation,
+ CompanyMembership,
+} from '@spree/admin-sdk'
import {
adminClient,
mapSpreeErrorsToForm,
@@ -9,6 +14,7 @@ import {
usePermissions,
} from '@spree/dashboard-core'
import {
+ AddressBlock,
Badge,
Button,
Card,
@@ -16,39 +22,71 @@ import {
CardContent,
CardHeader,
CardTitle,
+ Dialog,
+ DialogBody,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
ErrorState,
Field,
+ FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
Input,
Pagination,
ResourceLayout,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ useConfirm,
} from '@spree/dashboard-ui'
import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
-import { PlusIcon } from 'lucide-react'
+import { EllipsisVerticalIcon, PencilIcon, PlusIcon, TrashIcon } from 'lucide-react'
import { useEffect, useState } from 'react'
-import { useForm } from 'react-hook-form'
+import { Controller, useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
-import { CompanyLocationSheet } from '../../../../components/spree/company-location-sheet'
+import { CompanyAddressSheet } from '../../../../components/spree/company-address-sheet'
+import { CompanyKindBadge } from '../../../../components/spree/company-kind-badge'
+import { EnterpriseUpsell } from '../../../../components/spree/enterprise-upsell'
import { ResourceDetailSkeleton } from '../../../../components/spree/route-pending'
import { TaxExemptionCertificatesCard } from '../../../../components/spree/tax-exemption-certificates-card'
import { TaxIdentifiersCard } from '../../../../components/spree/tax-identifiers-card'
import {
+ useAddCompanyMember,
useCompany,
- useCompanyLocations,
+ useCompanyAddresses,
+ useCompanyChildren,
+ useCompanyInvitations,
+ useCompanyMemberships,
useCompanyTaxIdentifiers,
+ useCreateCompany,
useCreateCompanyTaxIdentifier,
useDeleteCompany,
+ useDeleteCompanyAddress,
+ useDeleteCompanyMembership,
useDeleteCompanyTaxIdentifier,
+ useRevokeCompanyInvitation,
useUpdateCompany,
useUpdateCompanyTaxIdentifier,
useValidateCompanyTaxIdentifier,
} from '../../../../hooks/use-companies'
import { spreeJsonLinkResolver } from '../../../../lib/json-link-resolver'
import {
+ COMPANY_CHILD_DEFAULTS,
COMPANY_DEFAULTS,
+ COMPANY_KINDS,
+ type CompanyChildFormValues,
type CompanyFormValues,
+ companyChildFormSchema,
companyFormSchema,
companyValuesToParams,
} from '../../../../schemas/company'
@@ -73,7 +111,7 @@ function CompanyDetailPage() {
)
}
- return <CompanyBody company={company} />
+ return <CompanyBody key={company.id} company={company} />
}
function CompanyBody({ company }: { company: Company }) {
@@ -84,6 +122,12 @@ function CompanyBody({ company }: { company: Company }) {
const deleteMutation = useDeleteCompany()
const canEdit = permissions.can('update', Subject.Company)
+ const isDivision = company.kind === 'division'
+ // The nearest self-or-ancestor legal entity — where a division's tax
+ // registrations actually live. Ancestors arrive root-first.
+ const legalEntity = isDivision
+ ? [...company.ancestors].reverse().find((ancestor) => ancestor.kind === 'company')
+ : undefined
async function handleDelete() {
await deleteMutation.mutateAsync(company.id)
@@ -95,6 +139,8 @@ function CompanyBody({ company }: { company: Company }) {
header={
<PageHeader
title={company.name}
+ subtitle={<AncestorBreadcrumb company={company} />}
+ badges={<CompanyKindBadge kind={company.kind} />}
backTo="companies"
resource={{ id: company.id }}
jsonPreview={{
@@ -109,24 +155,54 @@ function CompanyBody({ company }: { company: Company }) {
}
main={
<>
- <CompanyLocationsCard company={company} canEdit={canEdit} />
- <TaxExemptionCertificatesCard companyId={company.id} canEdit={canEdit} />
+ <SubUnitsCard company={company} canEdit={canEdit} />
+ <MembersCard company={company} canEdit={canEdit} />
+ {!isDivision && <TaxExemptionCertificatesCard companyId={company.id} canEdit={canEdit} />}
{/* Company-wide panels an extension owns: roles, purchase limits,
approval settings (docs: Enterprise b2b-companies plan). */}
- <Slot name="company.form_main" context={{ company, canEdit }} />
+ <Slot name="company.form_main" context={{ company, kind: company.kind, canEdit }} />
</>
}
sidebar={
<>
<CompanyProfileCard company={company} canEdit={canEdit} />
- <CompanyTaxIdentifiersCard companyId={company.id} canEdit={canEdit} />
- <Slot name="company.form_sidebar" context={{ company, canEdit }} />
+ <AddressBookCard company={company} canEdit={canEdit} />
+ {isDivision ? (
+ <DivisionTaxPointerCard legalEntity={legalEntity} />
+ ) : (
+ <CompanyTaxIdentifiersCard companyId={company.id} canEdit={canEdit} />
+ )}
+ <Slot name="company.form_sidebar" context={{ company, kind: company.kind, canEdit }} />
</>
}
/>
)
}
+/** "Acme / EMEA" — the path above this node, each level a link. */
+function AncestorBreadcrumb({ company }: { company: Company }) {
+ const { storeId } = Route.useParams()
+
+ if (company.ancestors.length === 0) return null
+
+ return (
+ <span className="flex flex-wrap items-center gap-1">
+ {company.ancestors.map((ancestor, index) => (
+ <span key={ancestor.id} className="flex items-center gap-1">
+ {index > 0 && <span>/</span>}
+ <Link
+ to={'/$storeId/companies/$companyId' as string}
+ params={{ storeId, companyId: ancestor.id }}
+ className="no-underline hover:underline"
+ >
+ {ancestor.name}
+ </Link>
+ </span>
+ ))}
+ </span>
+ )
+}
+
function CompanyProfileCard({ company, canEdit }: { company: Company; canEdit: boolean }) {
const { t } = useTranslation()
const updateMutation = useUpdateCompany(company.id)
@@ -194,6 +270,34 @@ function CompanyProfileCard({ company, canEdit }: { company: Company; canEdit: b
)
}
+/** Where a division's registrations live: on its legal entity, one click away. */
+function DivisionTaxPointerCard({ legalEntity }: { legalEntity?: { id: string; name: string } }) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('admin.tax_identifiers.title')}</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p className="text-muted-foreground text-sm">
+ {t('admin.companies.detail.division_tax_pointer')}{' '}
+ {legalEntity && (
+ <Link
+ to={'/$storeId/companies/$companyId' as string}
+ params={{ storeId, companyId: legalEntity.id }}
+ className="font-medium text-foreground no-underline hover:underline"
+ >
+ {legalEntity.name}
+ </Link>
+ )}
+ </p>
+ </CardContent>
+ </Card>
+ )
+}
+
function CompanyTaxIdentifiersCard({
companyId,
canEdit,
@@ -223,28 +327,28 @@ function CompanyTaxIdentifiersCard({
)
}
-function CompanyLocationsCard({ company, canEdit }: { company: Company; canEdit: boolean }) {
+function SubUnitsCard({ company, canEdit }: { company: Company; canEdit: boolean }) {
const { t } = useTranslation()
const { storeId } = Route.useParams()
const [page, setPage] = useState(1)
- const { data, isLoading } = useCompanyLocations(company.id, page)
+ const { data, isLoading } = useCompanyChildren(company.id, page)
const [addOpen, setAddOpen] = useState(false)
- const locations = data?.data ?? []
+ const children = data?.data ?? []
const meta = data?.meta
return (
<Card>
<CardHeader>
<CardTitle>
- {t('admin.company_locations.title')}
+ {t('admin.companies.sub_units.title')}
{meta?.count ? <Badge variant="outline">{meta.count}</Badge> : null}
</CardTitle>
{canEdit && (
<CardAction>
<Button size="sm" variant="outline" onClick={() => setAddOpen(true)}>
<PlusIcon className="size-4" />
- {t('admin.company_locations.add_cta')}
+ {t('admin.companies.sub_units.add_cta')}
</Button>
</CardAction>
)}
@@ -254,41 +358,504 @@ function CompanyLocationsCard({ company, canEdit }: { company: Company; canEdit:
<CardContent>
<p className="text-muted-foreground text-sm">{t('admin.common.loading')}</p>
</CardContent>
- ) : locations.length === 0 ? (
+ ) : children.length === 0 ? (
<CardContent>
- <p className="text-muted-foreground text-sm">{t('admin.company_locations.empty')}</p>
+ <p className="text-muted-foreground text-sm">{t('admin.companies.sub_units.empty')}</p>
</CardContent>
) : (
<CardContent className="p-0">
<div className="flex flex-col">
- {locations.map((location: CompanyLocation) => (
+ {children.map((child) => (
<Link
- key={location.id}
- to={'/$storeId/companies/locations/$locationId' as string}
- params={{ storeId, locationId: location.id }}
- className="flex items-start justify-between gap-3 border-b px-6 py-3 no-underline last:border-b-0 hover:bg-muted/50"
+ key={child.id}
+ to={'/$storeId/companies/$companyId' as string}
+ params={{ storeId, companyId: child.id }}
+ className="flex items-center justify-between gap-3 border-b px-6 py-3 no-underline last:border-b-0 hover:bg-muted/50"
>
- <div className="flex min-w-0 flex-col">
- <span className="font-medium text-foreground text-sm">{location.name}</span>
- <span className="text-muted-foreground text-xs">
- {[location.billing_address?.city, location.billing_address?.country_name]
- .filter(Boolean)
- .join(', ')}
- </span>
- </div>
+ <span className="flex min-w-0 items-center gap-2">
+ <span className="truncate font-medium text-foreground text-sm">{child.name}</span>
+ <CompanyKindBadge kind={child.kind} />
+ </span>
<span className="shrink-0 text-muted-foreground text-xs">
- {t('admin.company_locations.contacts_count', {
- count: location.contacts_count,
- })}
+ {t('admin.companies.members_count', { count: child.members_count })}
</span>
</Link>
))}
</div>
- {meta && <Pagination meta={meta} onPageChange={setPage} />}
+ {meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
+ </CardContent>
+ )}
+
+ {addOpen && <AddSubUnitDialog parent={company} open onOpenChange={setAddOpen} />}
+ </Card>
+ )
+}
+
+function AddSubUnitDialog({
+ parent,
+ open,
+ onOpenChange,
+}: {
+ parent: Company
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const createMutation = useCreateCompany()
+
+ const form = useForm<CompanyChildFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(companyChildFormSchema) as any,
+ defaultValues: COMPANY_CHILD_DEFAULTS,
+ })
+
+ const kindOptions = COMPANY_KINDS.map((kind) => ({
+ value: kind,
+ label:
+ kind === 'company' ? t('admin.companies.kind.company') : t('admin.companies.kind.division'),
+ }))
+
+ async function onSubmit(values: CompanyChildFormValues) {
+ try {
+ await createMutation.mutateAsync({ ...values, parent_id: parent.id })
+ form.reset(COMPANY_CHILD_DEFAULTS)
+ onOpenChange(false)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ const { errors } = form.formState
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>
+ {t('admin.companies.sub_units.add_title', { name: parent.name })}
+ </DialogTitle>
+ <DialogDescription>{t('admin.companies.sub_units.add_description')}</DialogDescription>
+ </DialogHeader>
+ <DialogBody>
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-destructive text-sm" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+ <Field>
+ <FieldLabel htmlFor="sub-unit-name">{t('admin.fields.name.label')}</FieldLabel>
+ <Input
+ id="sub-unit-name"
+ autoFocus
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name')}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+ <Field>
+ <FieldLabel htmlFor="sub-unit-kind">
+ {t('admin.fields.company.kind.label')}
+ </FieldLabel>
+ <Controller
+ control={form.control}
+ name="kind"
+ render={({ field }) => (
+ <Select
+ items={kindOptions}
+ value={field.value}
+ onValueChange={(value) => field.onChange(value)}
+ >
+ <SelectTrigger id="sub-unit-kind">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {kindOptions.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
+ />
+ <FieldDescription>{t('admin.fields.company.kind.help')}</FieldDescription>
+ </Field>
+ </FieldGroup>
+ </DialogBody>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button
+ type="button"
+ disabled={form.formState.isSubmitting}
+ onClick={form.handleSubmit(onSubmit)}
+ >
+ {form.formState.isSubmitting ? t('admin.actions.creating') : t('admin.actions.create')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+function AddressBookCard({ company, canEdit }: { company: Company; canEdit: boolean }) {
+ const { t } = useTranslation()
+ const confirm = useConfirm()
+ const [page, setPage] = useState(1)
+ const { data, isLoading } = useCompanyAddresses(company.id, page)
+ const deleteMutation = useDeleteCompanyAddress(company.id)
+ const [editing, setEditing] = useState<CompanyAddress | 'new' | null>(null)
+
+ const entries = data?.data ?? []
+ const meta = data?.meta
+
+ async function handleRemove(entry: CompanyAddress) {
+ const ok = await confirm({
+ title: t('admin.company_addresses.remove_confirm.title'),
+ message: t('admin.company_addresses.remove_confirm.message', {
+ label: entry.label || entry.address?.address1 || '',
+ }),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.delete'),
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(entry.id).catch(() => undefined)
+ }
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ {t('admin.company_addresses.title')}
+ {meta?.count ? <Badge variant="outline">{meta.count}</Badge> : null}
+ </CardTitle>
+ {canEdit && (
+ <CardAction>
+ <Button size="sm" variant="outline" onClick={() => setEditing('new')}>
+ <PlusIcon className="size-4" />
+ {t('admin.company_addresses.add_cta')}
+ </Button>
+ </CardAction>
+ )}
+ </CardHeader>
+
+ {isLoading ? (
+ <CardContent>
+ <p className="text-muted-foreground text-sm">{t('admin.common.loading')}</p>
+ </CardContent>
+ ) : entries.length === 0 ? (
+ <CardContent>
+ <p className="text-muted-foreground text-sm">{t('admin.company_addresses.empty')}</p>
+ </CardContent>
+ ) : (
+ <CardContent className="flex flex-col gap-4">
+ {entries.map((entry) => (
+ <div key={entry.id} className="flex items-start justify-between gap-2">
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="flex items-center gap-2">
+ {entry.label && (
+ <span className="font-medium text-foreground text-sm">{entry.label}</span>
+ )}
+ {entry.default_billing && (
+ <Badge variant="outline">{t('admin.company_addresses.default_billing')}</Badge>
+ )}
+ {entry.default_shipping && (
+ <Badge variant="outline">{t('admin.company_addresses.default_shipping')}</Badge>
+ )}
+ </span>
+ <AddressBlock address={entry.address} />
+ </div>
+ {canEdit && (
+ <span className="flex shrink-0 gap-1">
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => setEditing(entry)}
+ aria-label={t('admin.actions.edit')}
+ >
+ <PencilIcon className="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => handleRemove(entry)}
+ aria-label={t('admin.actions.delete')}
+ >
+ <TrashIcon className="size-4" />
+ </Button>
+ </span>
+ )}
+ </div>
+ ))}
+ {meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
+ </CardContent>
+ )}
+
+ {editing && (
+ <CompanyAddressSheet
+ companyId={company.id}
+ entry={editing === 'new' ? undefined : editing}
+ open
+ onOpenChange={(open) => !open && setEditing(null)}
+ />
+ )}
+ </Card>
+ )
+}
+
+function MembersCard({ company, canEdit }: { company: Company; canEdit: boolean }) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const confirm = useConfirm()
+ const [page, setPage] = useState(1)
+ const { data, isLoading } = useCompanyMemberships(company.id, page)
+ const deleteMutation = useDeleteCompanyMembership(company.id)
+ const [addOpen, setAddOpen] = useState(false)
+
+ const memberships = data?.data ?? []
+ const meta = data?.meta
+
+ async function handleRemove(membership: CompanyMembership) {
+ const ok = await confirm({
+ title: t('admin.company_memberships.remove_confirm.title'),
+ message: t('admin.company_memberships.remove_confirm.message', {
+ email: membership.email ?? membership.customer_id,
+ }),
+ variant: 'destructive',
+ confirmLabel: t('admin.company_memberships.remove_action'),
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(membership.id).catch(() => undefined)
+ }
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ {t('admin.company_memberships.title')}
+ {meta?.count ? <Badge variant="outline">{meta.count}</Badge> : null}
+ </CardTitle>
+ {canEdit && (
+ <CardAction>
+ <Button size="sm" variant="outline" onClick={() => setAddOpen(true)}>
+ <PlusIcon className="size-4" />
+ {t('admin.company_memberships.add_cta')}
+ </Button>
+ </CardAction>
+ )}
+ </CardHeader>
+
+ {isLoading ? (
+ <CardContent>
+ <p className="text-muted-foreground text-sm">{t('admin.common.loading')}</p>
+ </CardContent>
+ ) : memberships.length === 0 ? (
+ <CardContent>
+ <p className="text-muted-foreground text-sm">{t('admin.company_memberships.empty')}</p>
+ </CardContent>
+ ) : (
+ <CardContent className="p-0">
+ <div className="flex flex-col">
+ {memberships.map((membership) => (
+ <div
+ key={membership.id}
+ className="flex items-center justify-between gap-3 border-b px-6 py-3 last:border-b-0"
+ >
+ <div className="flex min-w-0 flex-col">
+ <Link
+ to={'/$storeId/customers/$customerId' as string}
+ params={{ storeId, customerId: membership.customer_id }}
+ className="font-medium text-foreground text-sm no-underline hover:underline"
+ >
+ {membership.email ?? membership.customer_id}
+ </Link>
+ {/* An extension owning roles renders the member's real role
+ here; the fallback is the cosmetic label OSS stores. */}
+ <Slot
+ name="company_membership.row_meta"
+ context={{ membership, companyId: company.id, canEdit }}
+ fallback={
+ membership.role ? (
+ <span className="text-muted-foreground text-xs">{membership.role}</span>
+ ) : null
+ }
+ />
+ </div>
+ {canEdit && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon-xs">
+ <EllipsisVerticalIcon className="size-4" />
+ <span className="sr-only">{t('admin.actions.actions_menu')}</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {/* Above the destructive item, so "change role" never
+ sits next to "remove member". */}
+ <Slot
+ name="company_membership.row_actions"
+ context={{ membership, companyId: company.id }}
+ />
+ <DropdownMenuItem
+ className="text-destructive focus:text-destructive"
+ onClick={() => handleRemove(membership)}
+ >
+ <TrashIcon className="size-4" />
+ {t('admin.company_memberships.remove_action')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+ ))}
+ </div>
+ {meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
</CardContent>
)}
- {addOpen && <CompanyLocationSheet companyId={company.id} open onOpenChange={setAddOpen} />}
+ <PendingInvitations company={company} canEdit={canEdit} />
+
+ {addOpen && <AddMemberDialog companyId={company.id} open onOpenChange={setAddOpen} />}
</Card>
)
}
+
+function PendingInvitations({ company, canEdit }: { company: Company; canEdit: boolean }) {
+ const { t } = useTranslation()
+ const confirm = useConfirm()
+ const [page, setPage] = useState(1)
+ const { data } = useCompanyInvitations(company.id, page)
+ const revokeMutation = useRevokeCompanyInvitation(company.id)
+
+ const pending = (data?.data ?? []).filter((invitation) => invitation.status === 'pending')
+ const meta = data?.meta
+
+ if (pending.length === 0) return null
+
+ async function handleRevoke(invitation: CompanyInvitation) {
+ const ok = await confirm({
+ title: t('admin.company_invitations.revoke_confirm.title'),
+ message: t('admin.company_invitations.revoke_confirm.message', { email: invitation.email }),
+ variant: 'destructive',
+ confirmLabel: t('admin.company_invitations.revoke_action'),
+ })
+ if (!ok) return
+ await revokeMutation.mutateAsync(invitation.id).catch(() => undefined)
+ }
+
+ return (
+ <CardContent className="border-t pt-4">
+ <p className="mb-2 font-medium text-muted-foreground text-xs uppercase">
+ {t('admin.company_invitations.pending_title')}
+ </p>
+ <div className="flex flex-col gap-2">
+ {pending.map((invitation) => (
+ <div key={invitation.id} className="flex items-center justify-between gap-3">
+ <span className="min-w-0 truncate text-foreground text-sm">{invitation.email}</span>
+ <span className="flex shrink-0 items-center gap-2">
+ <Badge variant="secondary">{t('admin.company_invitations.status.pending')}</Badge>
+ {canEdit && (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => handleRevoke(invitation)}
+ aria-label={t('admin.company_invitations.revoke_action')}
+ >
+ <TrashIcon className="size-4" />
+ </Button>
+ )}
+ </span>
+ </div>
+ ))}
+ </div>
+ {meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
+ </CardContent>
+ )
+}
+
+function AddMemberDialog({
+ companyId,
+ open,
+ onOpenChange,
+}: {
+ companyId: string
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const addMutation = useAddCompanyMember(companyId)
+ const [email, setEmail] = useState('')
+ // Written by whatever the `company_membership.form_fields` slot renders (the
+ // Enterprise role picker); merged into the create payload untouched, so core
+ // never needs to know which fields that plugin owns.
+ const [extraParams, setExtraParams] = useState<Record<string, unknown>>({})
+
+ async function handleSubmit() {
+ if (!email) return
+ await addMutation
+ .mutateAsync({ ...extraParams, customer_email: email })
+ .then(() => onOpenChange(false))
+ .catch(() => undefined)
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{t('admin.company_memberships.add_title')}</DialogTitle>
+ <DialogDescription>{t('admin.company_memberships.dialog_description')}</DialogDescription>
+ </DialogHeader>
+ <DialogBody>
+ <FieldGroup>
+ <Field>
+ <FieldLabel htmlFor="member-email">{t('admin.fields.email.label')}</FieldLabel>
+ <Input
+ id="member-email"
+ type="email"
+ autoFocus
+ placeholder={t('admin.fields.company_membership.email.placeholder')}
+ value={email}
+ onChange={(event) => setEmail(event.target.value)}
+ />
+ <FieldDescription>{t('admin.fields.company_membership.email.help')}</FieldDescription>
+ </Field>
+
+ {/* Roles are an Enterprise capability. The slot is where its role
+ picker mounts; with no plugin installed the fallback names the
+ limit rather than leaving a gap. */}
+ <Slot
+ name="company_membership.form_fields"
+ context={{ companyId, onChange: setExtraParams }}
+ fallback={
+ <EnterpriseUpsell
+ title={t('admin.company_memberships.roles_enterprise_title')}
+ description={t('admin.company_memberships.roles_enterprise_help')}
+ />
+ }
+ />
+ </FieldGroup>
+ </DialogBody>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ disabled={addMutation.isPending}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="button" disabled={addMutation.isPending || !email} onClick={handleSubmit}>
+ {addMutation.isPending ? t('admin.actions.saving') : t('admin.actions.add')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/companies/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/companies/index.tsx
index dcd32cdd2e..1b30caa558 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/companies/index.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/companies/index.tsx
@@ -4,43 +4,49 @@ import {
adminClient,
Can,
mapSpreeErrorsToForm,
- ResourceTable,
- resourceSearchSchema,
+ PageHeader,
Subject,
- usePermissions,
+ useResourceKey,
} from '@spree/dashboard-core'
import {
Button,
+ Card,
+ CardContent,
+ cn,
Field,
FieldError,
FieldGroup,
FieldLabel,
Input,
- RowActions,
+ Pagination,
+ SearchInput,
Sheet,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetTitle,
- useConfirm,
+ Skeleton,
} from '@spree/dashboard-ui'
-import { createFileRoute, useNavigate } from '@tanstack/react-router'
-import { PlusIcon } from 'lucide-react'
+import { useQuery } from '@tanstack/react-query'
+import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
+import { Building2Icon, ChevronDownIcon, ChevronRightIcon, PlusIcon } from 'lucide-react'
+import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { z } from 'zod/v4'
-import { useCreateCompany, useDeleteCompany } from '../../../../hooks/use-companies'
+import { CompanyKindBadge } from '../../../../components/spree/company-kind-badge'
+import { useCompanyChildren, useCreateCompany } from '../../../../hooks/use-companies'
import {
COMPANY_DEFAULTS,
type CompanyFormValues,
companyFormSchema,
companyValuesToParams,
} from '../../../../schemas/company'
-import '../../../../tables/companies'
-const companiesSearchSchema = resourceSearchSchema.extend({
+const companiesSearchSchema = z.object({
new: z.coerce.boolean().optional(),
+ q: z.string().optional(),
})
export const Route = createFileRoute('/_authenticated/$storeId/companies/')({
@@ -51,13 +57,10 @@ export const Route = createFileRoute('/_authenticated/$storeId/companies/')({
function CompaniesPage() {
const { t } = useTranslation()
const search = Route.useSearch() as z.infer<typeof companiesSearchSchema>
- const { storeId } = Route.useParams()
const navigate = useNavigate()
- const confirm = useConfirm()
- const deleteMutation = useDeleteCompany()
- const { permissions } = usePermissions()
const isCreating = !!search.new
+ const query = search.q ?? ''
const closeSheet = () =>
navigate({
@@ -70,48 +73,22 @@ function CompaniesPage() {
const openCreate = () =>
navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })
- async function handleDelete(company: Company) {
- const ok = await confirm({
- title: t('admin.companies.delete_confirm.title'),
- message: t('admin.companies.delete_confirm.message', { name: company.name ?? '' }),
- variant: 'destructive',
- confirmLabel: t('admin.actions.delete'),
+ const setQuery = (value: string) =>
+ navigate({
+ search: (prev: Record<string, unknown>) => {
+ const { q: _q, ...rest } = prev
+ return (value ? { ...rest, q: value } : rest) as never
+ },
+ replace: true,
})
- if (!ok) return
- await deleteMutation.mutateAsync(company.id).catch(() => undefined)
- }
return (
- <>
- <ResourceTable<Company>
- tableKey="companies"
- queryKey="companies"
- queryFn={(params) => adminClient.companies.list(params)}
- searchParams={search}
- rowActions={(company) => (
- <RowActions
- actions={[
- {
- key: 'edit',
- onSelect: () =>
- navigate({
- to: '/$storeId/companies/$companyId',
- params: { storeId, companyId: company.id },
- }),
- },
- {
- key: 'delete',
- destructive: true,
- visible: permissions.can('destroy', Subject.Company),
- disabled: deleteMutation.isPending,
- onSelect: () => handleDelete(company),
- },
- ]}
- />
- )}
+ <div className="flex flex-col gap-4">
+ <PageHeader
+ title={t('admin.nav.companies')}
actions={
<Can I="create" a={Subject.Company}>
- <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>
+ <Button size="sm" onClick={openCreate}>
<PlusIcon className="size-4" />
{t('admin.companies.add_cta')}
</Button>
@@ -119,11 +96,182 @@ function CompaniesPage() {
}
/>
+ <SearchInput
+ value={query}
+ onValueChange={setQuery}
+ placeholder={t('admin.companies.search_placeholder')}
+ />
+
+ <Card>
+ <CardContent className="p-0">
+ {query ? <CompanySearchResults query={query} /> : <CompanyTreeLevel depth={0} />}
+ </CardContent>
+ </Card>
+
{isCreating && <CreateCompanySheet open onOpenChange={(o) => !o && closeSheet()} />}
+ </div>
+ )
+}
+
+/**
+ * One level of the tree: the roots, or a node's children when `parentId` is
+ * set. Children load lazily on expand (`?q[parent_id_eq]` drives it), so a
+ * large directory never loads whole.
+ */
+function CompanyTreeLevel({ parentId, depth }: { parentId?: string; depth: number }) {
+ const { t } = useTranslation()
+ const [page, setPage] = useState(1)
+ const { data, isLoading } = useCompanyChildren(parentId, page)
+
+ const companies = data?.data ?? []
+ const meta = data?.meta
+
+ if (isLoading && !data) {
+ return (
+ <div className="flex flex-col gap-2 p-4" style={{ paddingLeft: `${depth * 1.5 + 1}rem` }}>
+ <Skeleton className="h-5 w-1/2" />
+ <Skeleton className="h-5 w-1/3" />
+ </div>
+ )
+ }
+
+ if (companies.length === 0 && depth === 0) {
+ return (
+ <div className="flex flex-col items-center gap-2 p-10 text-center">
+ <Building2Icon className="size-8 text-muted-foreground" />
+ <p className="text-muted-foreground text-sm">{t('admin.companies.empty')}</p>
+ </div>
+ )
+ }
+
+ return (
+ <div className="flex flex-col">
+ {companies.map((company) => (
+ <CompanyTreeRow key={company.id} company={company} depth={depth} />
+ ))}
+ {depth === 0 && meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
+ {depth > 0 && meta && meta.pages > 1 && page < meta.pages && (
+ <button
+ type="button"
+ className="px-6 py-2 text-left text-muted-foreground text-xs hover:text-foreground"
+ style={{ paddingLeft: `${depth * 1.5 + 1.5}rem` }}
+ onClick={() => setPage(page + 1)}
+ >
+ {t('admin.companies.load_more')}
+ </button>
+ )}
+ </div>
+ )
+}
+
+function CompanyTreeRow({ company, depth }: { company: Company; depth: number }) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const [expanded, setExpanded] = useState(false)
+ const hasChildren = company.children_count > 0
+
+ return (
+ <>
+ <div
+ className="flex items-center gap-2 border-b px-4 py-2.5 last:border-b-0 hover:bg-muted/50"
+ style={{ paddingLeft: `${depth * 1.5 + 1}rem` }}
+ >
+ <button
+ type="button"
+ onClick={() => setExpanded((prev) => !prev)}
+ disabled={!hasChildren}
+ aria-label={
+ expanded ? t('admin.companies.collapse_node') : t('admin.companies.expand_node')
+ }
+ aria-expanded={hasChildren ? expanded : undefined}
+ className={cn(
+ 'flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground',
+ hasChildren ? 'hover:bg-muted hover:text-foreground' : 'opacity-0',
+ )}
+ >
+ {expanded ? (
+ <ChevronDownIcon className="size-4" />
+ ) : (
+ <ChevronRightIcon className="size-4" />
+ )}
+ </button>
+
+ <Link
+ to={'/$storeId/companies/$companyId' as string}
+ params={{ storeId, companyId: company.id }}
+ className="flex min-w-0 flex-1 items-center gap-2 no-underline"
+ >
+ <span className="truncate font-medium text-foreground text-sm">{company.name}</span>
+ <CompanyKindBadge kind={company.kind} />
+ </Link>
+
+ <span className="shrink-0 text-muted-foreground text-xs">
+ {t('admin.companies.members_count', { count: company.members_count })}
+ </span>
+ </div>
+ {expanded && <CompanyTreeLevel parentId={company.id} depth={depth + 1} />}
</>
)
}
+/** Flat, path-annotated results — the tree does not compose with search. */
+function CompanySearchResults({ query }: { query: string }) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const [page, setPage] = useState(1)
+ const { data, isLoading } = useQuery({
+ queryKey: useResourceKey('companies', 'search', `${query}:${page}`),
+ queryFn: () => adminClient.companies.list({ page, limit: 25, name_cont: query, sort: 'name' }),
+ placeholderData: (previous) => previous,
+ })
+
+ const companies = data?.data ?? []
+ const meta = data?.meta
+
+ if (isLoading && !data) {
+ return (
+ <div className="flex flex-col gap-2 p-4">
+ <Skeleton className="h-5 w-1/2" />
+ </div>
+ )
+ }
+
+ if (companies.length === 0) {
+ return (
+ <div className="flex flex-col items-center gap-2 p-10 text-center">
+ <Building2Icon className="size-8 text-muted-foreground" />
+ <p className="text-muted-foreground text-sm">{t('admin.companies.search_empty')}</p>
+ </div>
+ )
+ }
+
+ return (
+ <div className="flex flex-col">
+ {companies.map((company) => (
+ <Link
+ key={company.id}
+ to={'/$storeId/companies/$companyId' as string}
+ params={{ storeId, companyId: company.id }}
+ className="flex items-center gap-2 border-b px-6 py-2.5 no-underline last:border-b-0 hover:bg-muted/50"
+ >
+ <span className="min-w-0 flex-col">
+ <span className="flex items-center gap-2">
+ <span className="truncate font-medium text-foreground text-sm">{company.name}</span>
+ <CompanyKindBadge kind={company.kind} />
+ </span>
+ {company.ancestors.length > 0 && (
+ <span className="block truncate text-muted-foreground text-xs">
+ {company.ancestors.map((ancestor) => ancestor.name).join(' / ')}
+ </span>
+ )}
+ </span>
+ </Link>
+ ))}
+ {meta && meta.pages > 1 && <Pagination meta={meta} onPageChange={setPage} />}
+ </div>
+ )
+}
+
function CreateCompanySheet({
open,
onOpenChange,
@@ -141,8 +289,8 @@ function CreateCompanySheet({
defaultValues: COMPANY_DEFAULTS,
})
- // A new company has no branches, registration or certificates yet, and all
- // three live on its detail page — so that is where the merchant is headed.
+ // A new root is always a legal entity; sub-units are added from the node
+ // page, where the parent is unambiguous.
async function onSubmit(values: CompanyFormValues) {
try {
const company = await createMutation.mutateAsync(companyValuesToParams(values))
@@ -176,7 +324,7 @@ function CreateCompanySheet({
<div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
<FieldGroup>
{errors.root?.message && (
- <p className="text-sm text-destructive" role="alert">
+ <p className="text-destructive text-sm" role="alert">
{errors.root.message}
</p>
)}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/companies/locations.$locationId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/companies/locations.$locationId.tsx
deleted file mode 100644
index d8d27689de..0000000000
--- a/packages/dashboard/src/routes/_authenticated/$storeId/companies/locations.$locationId.tsx
+++ /dev/null
@@ -1,376 +0,0 @@
-import type {
- CompanyContact,
- CompanyContactParams,
- CompanyLocation,
- Customer,
-} from '@spree/admin-sdk'
-import {
- adminClient,
- PageHeader,
- ResourceCombobox,
- Slot,
- Subject,
- usePermissions,
-} from '@spree/dashboard-core'
-import {
- AddressBlock,
- Badge,
- Button,
- Card,
- CardAction,
- CardContent,
- CardHeader,
- CardTitle,
- Dialog,
- DialogBody,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- ErrorState,
- Field,
- FieldGroup,
- FieldLabel,
- Pagination,
- ResourceLayout,
- useConfirm,
-} from '@spree/dashboard-ui'
-import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
-import { EllipsisVerticalIcon, PencilIcon, PlusIcon, TrashIcon } from 'lucide-react'
-import { useState } from 'react'
-import { useTranslation } from 'react-i18next'
-import { CompanyLocationSheet } from '../../../../components/spree/company-location-sheet'
-import { EnterpriseUpsell } from '../../../../components/spree/enterprise-upsell'
-import { ResourceDetailSkeleton } from '../../../../components/spree/route-pending'
-import {
- useCompanyLocation,
- useCompanyLocationContacts,
- useCreateCompanyContact,
- useDeleteCompanyContact,
- useDeleteCompanyLocation,
-} from '../../../../hooks/use-companies'
-import { customerAutocompleteProps } from '../../../../hooks/use-customers'
-import { spreeJsonLinkResolver } from '../../../../lib/json-link-resolver'
-
-export const Route = createFileRoute('/_authenticated/$storeId/companies/locations/$locationId')({
- component: CompanyLocationDetailPage,
-})
-
-function CompanyLocationDetailPage() {
- const { t } = useTranslation()
- const { locationId } = Route.useParams()
- const { data: location, isLoading, error, refetch } = useCompanyLocation(locationId)
-
- if (isLoading) return <ResourceDetailSkeleton />
- if (error || !location) {
- return (
- <ErrorState
- title={t('admin.company_locations.detail.load_error')}
- error={error as Error | undefined}
- onRetry={() => refetch()}
- />
- )
- }
-
- return <CompanyLocationBody location={location} />
-}
-
-function CompanyLocationBody({ location }: { location: CompanyLocation }) {
- const { t } = useTranslation()
- const { storeId } = Route.useParams()
- const navigate = useNavigate()
- const { permissions } = usePermissions()
- const deleteMutation = useDeleteCompanyLocation(location.company_id)
- const [editOpen, setEditOpen] = useState(false)
-
- const canEdit = permissions.can('update', Subject.CompanyLocation)
-
- async function handleDelete() {
- await deleteMutation.mutateAsync(location.id)
- navigate({
- to: '/$storeId/companies/$companyId',
- params: { storeId, companyId: location.company_id },
- })
- }
-
- return (
- <>
- <ResourceLayout
- header={
- <PageHeader
- title={location.name}
- backTo={`companies/${location.company_id}`}
- resource={{ id: location.id }}
- jsonPreview={{
- title: `Location ${location.name}`,
- fetch: () => adminClient.companyLocations.get(location.id),
- endpoint: `/api/v3/admin/company_locations/${location.id}`,
- resolveLink: spreeJsonLinkResolver(storeId),
- }}
- actions={
- canEdit ? (
- <Button
- variant="ghost"
- size="icon-sm"
- onClick={() => setEditOpen(true)}
- aria-label={t('admin.actions.edit')}
- >
- <PencilIcon className="size-4" />
- </Button>
- ) : undefined
- }
- onDelete={
- permissions.can('destroy', Subject.CompanyLocation) ? handleDelete : undefined
- }
- deleteLabel={t('admin.company_locations.detail.delete_label')}
- />
- }
- main={
- <>
- <ContactsCard location={location} canEdit={canEdit} />
- {/* Per-branch panels an extension owns: approval rules, spending
- limits (docs: Enterprise b2b-companies plan). */}
- <Slot name="company_location.form_main" context={{ location, canEdit }} />
- </>
- }
- sidebar={
- <>
- <AddressesCard location={location} />
- <Slot name="company_location.form_sidebar" context={{ location, canEdit }} />
- </>
- }
- />
-
- {editOpen && (
- <CompanyLocationSheet
- companyId={location.company_id}
- location={location}
- open
- onOpenChange={setEditOpen}
- />
- )}
- </>
- )
-}
-
-function AddressesCard({ location }: { location: CompanyLocation }) {
- const { t } = useTranslation()
-
- return (
- <Card>
- <CardHeader>
- <CardTitle>{t('admin.company_locations.addresses')}</CardTitle>
- </CardHeader>
- <CardContent className="flex flex-col gap-4">
- <AddressBlock
- title={t('admin.company_locations.billing_address')}
- address={location.billing_address}
- />
- <AddressBlock
- title={t('admin.company_locations.shipping_address')}
- address={location.shipping_address}
- />
- </CardContent>
- </Card>
- )
-}
-
-function ContactsCard({ location, canEdit }: { location: CompanyLocation; canEdit: boolean }) {
- const { t } = useTranslation()
- const { storeId } = Route.useParams()
- const confirm = useConfirm()
- const [page, setPage] = useState(1)
- const { data, isLoading } = useCompanyLocationContacts(location.id, page)
- const deleteMutation = useDeleteCompanyContact(location.id)
- const [addOpen, setAddOpen] = useState(false)
-
- const contacts = data?.data ?? []
- const meta = data?.meta
-
- async function handleRemove(contact: CompanyContact) {
- const ok = await confirm({
- title: t('admin.company_contacts.remove_confirm.title'),
- message: t('admin.company_contacts.remove_confirm.message', {
- email: contact.email ?? contact.customer_id,
- }),
- variant: 'destructive',
- confirmLabel: t('admin.company_contacts.remove_action'),
- })
- if (!ok) return
- await deleteMutation.mutateAsync(contact.id).catch(() => undefined)
- }
-
- return (
- <Card>
- <CardHeader>
- <CardTitle>
- {t('admin.company_contacts.title')}
- {meta?.count ? <Badge variant="outline">{meta.count}</Badge> : null}
- </CardTitle>
- {canEdit && (
- <CardAction>
- <Button size="sm" variant="outline" onClick={() => setAddOpen(true)}>
- <PlusIcon className="size-4" />
- {t('admin.company_contacts.add_cta')}
- </Button>
- </CardAction>
- )}
- </CardHeader>
-
- {isLoading ? (
- <CardContent>
- <p className="text-muted-foreground text-sm">{t('admin.common.loading')}</p>
- </CardContent>
- ) : contacts.length === 0 ? (
- <CardContent>
- <p className="text-muted-foreground text-sm">{t('admin.company_contacts.empty')}</p>
- </CardContent>
- ) : (
- <CardContent className="p-0">
- <div className="flex flex-col">
- {contacts.map((contact) => (
- <div
- key={contact.id}
- className="flex items-center justify-between gap-3 border-b px-6 py-3 last:border-b-0"
- >
- <div className="flex min-w-0 flex-col">
- <Link
- to={'/$storeId/customers/$customerId' as string}
- params={{ storeId, customerId: contact.customer_id }}
- className="font-medium text-foreground text-sm no-underline hover:underline"
- >
- {contact.email ?? contact.customer_id}
- </Link>
- {/* An extension owning roles renders the buyer's real role
- here; the fallback is the cosmetic label OSS stores. */}
- <Slot
- name="company_contact.row_meta"
- context={{ contact, locationId: location.id, canEdit }}
- fallback={
- contact.role ? (
- <span className="text-muted-foreground text-xs">{contact.role}</span>
- ) : null
- }
- />
- </div>
- {canEdit && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon-xs">
- <EllipsisVerticalIcon className="size-4" />
- <span className="sr-only">{t('admin.actions.actions_menu')}</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {/* Above the destructive item, so "change role" never
- sits next to "remove buyer". */}
- <Slot
- name="company_contact.row_actions"
- context={{ contact, locationId: location.id }}
- />
- <DropdownMenuItem
- className="text-destructive focus:text-destructive"
- onClick={() => handleRemove(contact)}
- >
- <TrashIcon className="size-4" />
- {t('admin.company_contacts.remove_action')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </div>
- ))}
- </div>
- {meta && <Pagination meta={meta} onPageChange={setPage} />}
- </CardContent>
- )}
-
- {addOpen && <AddContactDialog locationId={location.id} open onOpenChange={setAddOpen} />}
- </Card>
- )
-}
-
-function AddContactDialog({
- locationId,
- open,
- onOpenChange,
-}: {
- locationId: string
- open: boolean
- onOpenChange: (open: boolean) => void
-}) {
- const { t } = useTranslation()
- const createMutation = useCreateCompanyContact(locationId)
- const [customerId, setCustomerId] = useState('')
- // Written by whatever the `company_contact.form_fields` slot renders (the
- // Enterprise role picker); merged into the create payload untouched, so core
- // never needs to know which fields that plugin owns.
- const [extraParams, setExtraParams] = useState<CompanyContactParams>({})
-
- async function handleSubmit() {
- if (!customerId) return
- await createMutation
- .mutateAsync({ ...extraParams, customer_id: customerId })
- .then(() => onOpenChange(false))
- .catch(() => undefined)
- }
-
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent>
- <DialogHeader>
- <DialogTitle>{t('admin.company_contacts.add_title')}</DialogTitle>
- <DialogDescription>{t('admin.company_contacts.dialog_description')}</DialogDescription>
- </DialogHeader>
- <DialogBody>
- <FieldGroup>
- <Field>
- <FieldLabel>{t('admin.fields.customer.label')}</FieldLabel>
- <ResourceCombobox<Customer>
- {...customerAutocompleteProps('company-contact-customers')}
- value={customerId || undefined}
- onChange={(id) => setCustomerId(id ?? '')}
- />
- </Field>
-
- {/* Roles are an Enterprise capability. The slot is where its role
- picker mounts; with no plugin installed the fallback names the
- limit rather than leaving a gap. */}
- <Slot
- name="company_contact.form_fields"
- context={{ locationId, onChange: setExtraParams }}
- fallback={
- <EnterpriseUpsell
- title={t('admin.company_contacts.roles_enterprise_title')}
- description={t('admin.company_contacts.roles_enterprise_help')}
- />
- }
- />
- </FieldGroup>
- </DialogBody>
- <DialogFooter>
- <Button
- type="button"
- variant="outline"
- onClick={() => onOpenChange(false)}
- disabled={createMutation.isPending}
- >
- {t('admin.actions.cancel')}
- </Button>
- <Button
- type="button"
- disabled={createMutation.isPending || !customerId}
- onClick={handleSubmit}
- >
- {createMutation.isPending ? t('admin.actions.saving') : t('admin.actions.add')}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )
-}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
new file mode 100644
index 0000000000..3a30d1bab5
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
@@ -0,0 +1,491 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import type { Catalog, CatalogAssignment, PriceList } from '@spree/admin-sdk'
+import {
+ adminClient,
+ mapSpreeErrorsToForm,
+ PageHeader,
+ ResourceCombobox,
+ Subject,
+ usePermissions,
+} from '@spree/dashboard-core'
+import {
+ Badge,
+ Button,
+ Card,
+ CardAction,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Checkbox,
+ Dialog,
+ DialogBody,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ ErrorState,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ ResourceLayout,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ useConfirm,
+} from '@spree/dashboard-ui'
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+import { PlusIcon, TrashIcon } from 'lucide-react'
+import { useEffect, useState } from 'react'
+import { Controller, useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import { ProductMembershipCard } from '../../../../../components/spree/product-membership-card'
+import { ResourceDetailSkeleton } from '../../../../../components/spree/route-pending'
+import {
+ useAddCatalogProducts,
+ useAssignCatalog,
+ useCatalog,
+ useCatalogProducts,
+ useDeleteCatalog,
+ useRemoveCatalogProduct,
+ useRemoveCatalogProducts,
+ useRepositionCatalogProduct,
+ useUnassignCatalog,
+ useUpdateCatalog,
+} from '../../../../../hooks/use-catalogs'
+import { spreeJsonLinkResolver } from '../../../../../lib/json-link-resolver'
+import {
+ CATALOG_DEFAULTS,
+ type CatalogFormValues,
+ catalogFormSchema,
+ catalogValuesToParams,
+} from '../../../../../schemas/catalog'
+
+export const Route = createFileRoute('/_authenticated/$storeId/products/catalogs/$catalogId')({
+ component: CatalogDetailPage,
+})
+
+function CatalogDetailPage() {
+ const { t } = useTranslation()
+ const { catalogId } = Route.useParams()
+ const { data: catalog, isLoading, error, refetch } = useCatalog(catalogId)
+
+ if (isLoading) return <ResourceDetailSkeleton />
+ if (error || !catalog) {
+ return (
+ <ErrorState
+ title={t('admin.catalogs.detail.load_error')}
+ error={error as Error | undefined}
+ onRetry={() => refetch()}
+ />
+ )
+ }
+
+ return <CatalogBody key={catalog.id} catalog={catalog} />
+}
+
+function CatalogBody({ catalog }: { catalog: Catalog }) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const navigate = useNavigate()
+ const { permissions } = usePermissions()
+ const deleteMutation = useDeleteCatalog()
+
+ const canEdit = permissions.can('update', Subject.Catalog)
+
+ async function handleDelete() {
+ await deleteMutation.mutateAsync(catalog.id)
+ navigate({ to: '/$storeId/products/catalogs', params: { storeId } })
+ }
+
+ return (
+ <ResourceLayout
+ header={
+ <PageHeader
+ title={catalog.name}
+ badges={
+ catalog.active ? undefined : (
+ <Badge variant="secondary">{t('admin.common.inactive')}</Badge>
+ )
+ }
+ backTo="products/catalogs"
+ resource={{ id: catalog.id }}
+ jsonPreview={{
+ title: `Catalog ${catalog.name}`,
+ fetch: () => adminClient.catalogs.get(catalog.id, { expand: ['assignments'] }),
+ endpoint: `/api/v3/admin/catalogs/${catalog.id}`,
+ resolveLink: spreeJsonLinkResolver(storeId),
+ }}
+ onDelete={permissions.can('destroy', Subject.Catalog) ? handleDelete : undefined}
+ deleteLabel={t('admin.catalogs.detail.delete_label')}
+ />
+ }
+ main={<CatalogProductsCard catalog={catalog} canEdit={canEdit} />}
+ sidebar={
+ <>
+ <CatalogSettingsCard catalog={catalog} canEdit={canEdit} />
+ <CatalogAssignmentsCard catalog={catalog} canEdit={canEdit} />
+ </>
+ }
+ />
+ )
+}
+
+// Adapters shaping the catalog mutations to the ProductMembershipHooks
+// contract — custom hooks, so the rules of hooks stay satisfied.
+function useRemoveOneCatalogProductAdapter(catalogId: string) {
+ const mutation = useRemoveCatalogProduct(catalogId)
+ return { mutate: (productId: string) => mutation.mutate(productId) }
+}
+
+function useRepositionCatalogProductAdapter(catalogId: string) {
+ const mutation = useRepositionCatalogProduct(catalogId)
+ return {
+ mutate: (vars: { productId: string; new_position: number }, opts?: { onError?: () => void }) =>
+ mutation.mutate(vars, opts),
+ }
+}
+
+function CatalogProductsCard({ catalog, canEdit }: { catalog: Catalog; canEdit: boolean }) {
+ const { storeId } = Route.useParams()
+
+ return (
+ <ProductMembershipCard
+ parentId={catalog.id}
+ storeId={storeId}
+ translationNamespace="admin.catalogs"
+ readOnly={!canEdit}
+ hooks={{
+ useProducts: useCatalogProducts,
+ useAdd: useAddCatalogProducts,
+ useRemoveOne: useRemoveOneCatalogProductAdapter,
+ useRemoveMany: useRemoveCatalogProducts,
+ useReposition: useRepositionCatalogProductAdapter,
+ }}
+ />
+ )
+}
+
+function CatalogSettingsCard({ catalog, canEdit }: { catalog: Catalog; canEdit: boolean }) {
+ const { t } = useTranslation()
+ const updateMutation = useUpdateCatalog(catalog.id)
+
+ const form = useForm<CatalogFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(catalogFormSchema) as any,
+ defaultValues: CATALOG_DEFAULTS,
+ })
+
+ useEffect(() => {
+ form.reset({
+ name: catalog.name,
+ active: catalog.active,
+ price_list_id: catalog.price_list_id ?? '',
+ })
+ }, [catalog, form])
+
+ async function onSubmit(values: CatalogFormValues) {
+ try {
+ await updateMutation.mutateAsync(catalogValuesToParams(values))
+ form.reset(values)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ const { errors } = form.formState
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('admin.catalogs.detail.settings')}</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-destructive text-sm" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+ <Field>
+ <FieldLabel htmlFor="catalog-name">{t('admin.fields.name.label')}</FieldLabel>
+ <Input
+ id="catalog-name"
+ disabled={!canEdit}
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name')}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>{t('admin.fields.catalog.price_list.label')}</FieldLabel>
+ <Controller
+ control={form.control}
+ name="price_list_id"
+ render={({ field }) => (
+ <ResourceCombobox<PriceList>
+ queryKey="catalog-price-lists"
+ search={(q) => adminClient.priceLists.list({ name_cont: q, limit: 10 })}
+ hydrate={(ids) => adminClient.priceLists.list({ id_in: ids, limit: ids.length })}
+ getOptionLabel={(list) => list.name}
+ placeholder={t('admin.fields.catalog.price_list.placeholder')}
+ emptyText={t('admin.fields.catalog.price_list.empty')}
+ disabled={!canEdit}
+ value={field.value || undefined}
+ onChange={(id) => field.onChange(id ?? '')}
+ />
+ )}
+ />
+ <FieldDescription>{t('admin.fields.catalog.price_list.help')}</FieldDescription>
+ </Field>
+
+ <Controller
+ control={form.control}
+ name="active"
+ render={({ field }) => (
+ <label htmlFor="catalog-active" className="flex items-center gap-2 text-sm">
+ <Checkbox
+ id="catalog-active"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={!canEdit}
+ />
+ {t('admin.fields.active.label')}
+ </label>
+ )}
+ />
+
+ {canEdit && (
+ <div className="flex justify-end">
+ <Button
+ type="button"
+ size="sm"
+ disabled={form.formState.isSubmitting || !form.formState.isDirty}
+ onClick={form.handleSubmit(onSubmit)}
+ >
+ {form.formState.isSubmitting ? t('admin.actions.saving') : t('admin.actions.save')}
+ </Button>
+ </div>
+ )}
+ </FieldGroup>
+ </CardContent>
+ </Card>
+ )
+}
+
+const ASSIGNABLE_TYPES = ['company', 'customer_group', 'market', 'channel'] as const
+type AssignableType = (typeof ASSIGNABLE_TYPES)[number]
+
+function CatalogAssignmentsCard({ catalog, canEdit }: { catalog: Catalog; canEdit: boolean }) {
+ const { t } = useTranslation()
+ const confirm = useConfirm()
+ const unassignMutation = useUnassignCatalog(catalog.id)
+ const [addOpen, setAddOpen] = useState(false)
+
+ const assignments = catalog.assignments ?? []
+
+ async function handleUnassign(assignment: CatalogAssignment) {
+ const ok = await confirm({
+ title: t('admin.catalogs.assignments.remove_confirm.title'),
+ message: t('admin.catalogs.assignments.remove_confirm.message', {
+ name: assignment.assignable_name ?? assignment.assignable_id,
+ }),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.delete'),
+ })
+ if (!ok) return
+ await unassignMutation.mutateAsync(assignment.id).catch(() => undefined)
+ }
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('admin.catalogs.assignments.title')}</CardTitle>
+ {canEdit && (
+ <CardAction>
+ <Button size="sm" variant="outline" onClick={() => setAddOpen(true)}>
+ <PlusIcon className="size-4" />
+ {t('admin.catalogs.assignments.add_cta')}
+ </Button>
+ </CardAction>
+ )}
+ </CardHeader>
+ <CardContent>
+ {assignments.length === 0 ? (
+ <p className="text-muted-foreground text-sm">{t('admin.catalogs.assignments.empty')}</p>
+ ) : (
+ <div className="flex flex-col gap-2">
+ {assignments.map((assignment) => (
+ <div key={assignment.id} className="flex items-center justify-between gap-2">
+ <span className="flex min-w-0 items-center gap-2">
+ <Badge variant="outline">
+ {t(`admin.catalogs.assignable_types.${assignment.assignable_type}`)}
+ </Badge>
+ <span className="truncate text-foreground text-sm">
+ {assignment.assignable_name ?? assignment.assignable_id}
+ </span>
+ </span>
+ {canEdit && (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => handleUnassign(assignment)}
+ aria-label={t('admin.actions.delete')}
+ >
+ <TrashIcon className="size-4" />
+ </Button>
+ )}
+ </div>
+ ))}
+ </div>
+ )}
+ </CardContent>
+
+ {addOpen && <AssignCatalogDialog catalogId={catalog.id} open onOpenChange={setAddOpen} />}
+ </Card>
+ )
+}
+
+interface AssignableOption {
+ id: string
+ name?: string | null
+ email?: string | null
+}
+
+function assignableSearch(type: AssignableType) {
+ switch (type) {
+ case 'company':
+ return {
+ search: (q: string) => adminClient.companies.list({ name_cont: q, limit: 10 }),
+ hydrate: (ids: string[]) => adminClient.companies.list({ id_in: ids, limit: ids.length }),
+ }
+ case 'customer_group':
+ return {
+ search: (q: string) => adminClient.customerGroups.list({ name_cont: q, limit: 10 }),
+ hydrate: (ids: string[]) =>
+ adminClient.customerGroups.list({ id_in: ids, limit: ids.length }),
+ }
+ case 'market':
+ return {
+ search: (q: string) => adminClient.markets.list({ name_cont: q, limit: 10 }),
+ hydrate: (ids: string[]) => adminClient.markets.list({ id_in: ids, limit: ids.length }),
+ }
+ case 'channel':
+ return {
+ search: (q: string) => adminClient.channels.list({ name_cont: q, limit: 10 }),
+ hydrate: (ids: string[]) => adminClient.channels.list({ id_in: ids, limit: ids.length }),
+ }
+ }
+}
+
+function AssignCatalogDialog({
+ catalogId,
+ open,
+ onOpenChange,
+}: {
+ catalogId: string
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const assignMutation = useAssignCatalog(catalogId)
+ const [assignableType, setAssignableType] = useState<AssignableType>('company')
+ const [assignableId, setAssignableId] = useState('')
+
+ const typeOptions = ASSIGNABLE_TYPES.map((type) => ({
+ value: type,
+ label: t(`admin.catalogs.assignable_types.${type}`),
+ }))
+
+ const { search, hydrate } = assignableSearch(assignableType)
+
+ async function handleSubmit() {
+ if (!assignableId) return
+ await assignMutation
+ .mutateAsync({ assignable_type: assignableType, assignable_id: assignableId })
+ .then(() => onOpenChange(false))
+ .catch(() => undefined)
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{t('admin.catalogs.assignments.add_title')}</DialogTitle>
+ <DialogDescription>
+ {t('admin.catalogs.assignments.dialog_description')}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogBody>
+ <FieldGroup>
+ <Field>
+ <FieldLabel>{t('admin.catalogs.assignments.type_label')}</FieldLabel>
+ <Select
+ items={typeOptions}
+ value={assignableType}
+ onValueChange={(value) => {
+ setAssignableType(value as AssignableType)
+ setAssignableId('')
+ }}
+ >
+ <SelectTrigger>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {typeOptions.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Field>
+
+ <Field>
+ <FieldLabel>{t('admin.catalogs.assignments.audience_label')}</FieldLabel>
+ <ResourceCombobox<AssignableOption>
+ key={assignableType}
+ queryKey={`catalog-assignables-${assignableType}`}
+ search={search}
+ hydrate={hydrate}
+ getOptionLabel={(option) => option.name ?? option.email ?? option.id}
+ placeholder={t('admin.catalogs.assignments.audience_placeholder')}
+ emptyText={t('admin.catalogs.assignments.audience_empty')}
+ value={assignableId || undefined}
+ onChange={(id) => setAssignableId(id ?? '')}
+ />
+ {assignableType === 'company' && (
+ <FieldDescription>
+ {t('admin.catalogs.assignments.company_subtree_help')}
+ </FieldDescription>
+ )}
+ </Field>
+ </FieldGroup>
+ </DialogBody>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ disabled={assignMutation.isPending}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button
+ type="button"
+ disabled={assignMutation.isPending || !assignableId}
+ onClick={handleSubmit}
+ >
+ {assignMutation.isPending ? t('admin.actions.saving') : t('admin.actions.add')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/index.tsx
new file mode 100644
index 0000000000..2cebf7b9bd
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/index.tsx
@@ -0,0 +1,223 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import type { Catalog } from '@spree/admin-sdk'
+import {
+ adminClient,
+ Can,
+ mapSpreeErrorsToForm,
+ ResourceTable,
+ resourceSearchSchema,
+ Subject,
+ usePermissions,
+} from '@spree/dashboard-core'
+import {
+ Button,
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ RowActions,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+ useConfirm,
+ useRowClickBridge,
+} from '@spree/dashboard-ui'
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+import { PlusIcon } from 'lucide-react'
+import { useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import { z } from 'zod/v4'
+import { useCreateCatalog, useDeleteCatalog } from '../../../../../hooks/use-catalogs'
+import {
+ CATALOG_DEFAULTS,
+ type CatalogFormValues,
+ catalogFormSchema,
+ catalogValuesToParams,
+} from '../../../../../schemas/catalog'
+import '../../../../../tables/catalogs'
+
+const catalogsSearchSchema = resourceSearchSchema.extend({
+ new: z.coerce.boolean().optional(),
+})
+
+export const Route = createFileRoute('/_authenticated/$storeId/products/catalogs/')({
+ validateSearch: catalogsSearchSchema,
+ component: CatalogsPage,
+})
+
+function CatalogsPage() {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const search = Route.useSearch() as z.infer<typeof catalogsSearchSchema>
+ const navigate = useNavigate()
+ const confirm = useConfirm()
+ const deleteMutation = useDeleteCatalog()
+ const { permissions } = usePermissions()
+
+ const isCreating = !!search.new
+
+ function openEdit(id: string) {
+ navigate({
+ to: '/$storeId/products/catalogs/$catalogId',
+ params: { storeId, catalogId: id },
+ })
+ }
+
+ const closeSheet = () =>
+ navigate({
+ search: (prev: Record<string, unknown>) => {
+ const { new: _n, ...rest } = prev
+ return rest as never
+ },
+ })
+
+ const openCreate = () =>
+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })
+
+ useRowClickBridge('data-catalog-id', openEdit)
+
+ async function handleDelete(catalog: Catalog) {
+ const ok = await confirm({
+ title: t('admin.catalogs.delete_confirm.title'),
+ message: t('admin.catalogs.delete_confirm.message', { name: catalog.name }),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.delete'),
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(catalog.id).catch(() => undefined)
+ }
+
+ return (
+ <>
+ <ResourceTable<Catalog>
+ tableKey="catalogs"
+ queryKey="catalogs"
+ queryFn={(params) => adminClient.catalogs.list(params)}
+ searchParams={search}
+ rowActions={(catalog) => (
+ <RowActions
+ actions={[
+ { key: 'edit', onSelect: () => openEdit(catalog.id) },
+ {
+ key: 'delete',
+ destructive: true,
+ visible: permissions.can('destroy', Subject.Catalog),
+ disabled: deleteMutation.isPending,
+ onSelect: () => handleDelete(catalog),
+ },
+ ]}
+ />
+ )}
+ actions={
+ <Can I="create" a={Subject.Catalog}>
+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>
+ <PlusIcon className="size-4" />
+ {t('admin.catalogs.add_cta')}
+ </Button>
+ </Can>
+ }
+ reorder={{
+ onReorder: async (id, position) => {
+ await adminClient.catalogs.update(id, { position })
+ },
+ }}
+ />
+
+ {isCreating && <CreateCatalogSheet open onOpenChange={(o) => !o && closeSheet()} />}
+ </>
+ )
+}
+
+function CreateCatalogSheet({
+ open,
+ onOpenChange,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ const navigate = useNavigate()
+ const createMutation = useCreateCatalog()
+ const form = useForm<CatalogFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(catalogFormSchema) as any,
+ defaultValues: CATALOG_DEFAULTS,
+ })
+
+ // A new catalog has no assortment or audience yet, and both live on its
+ // detail page — so that is where the merchant is headed.
+ async function onSubmit(values: CatalogFormValues) {
+ try {
+ const catalog = await createMutation.mutateAsync(catalogValuesToParams(values))
+ form.reset(CATALOG_DEFAULTS)
+ onOpenChange(false)
+ navigate({
+ to: '/$storeId/products/catalogs/$catalogId',
+ params: { storeId, catalogId: catalog.id },
+ })
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ const { errors } = form.formState
+
+ return (
+ <Sheet
+ open={open}
+ onOpenChange={(next) => {
+ if (!next) form.reset(CATALOG_DEFAULTS)
+ onOpenChange(next)
+ }}
+ >
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('admin.catalogs.add_sheet_title')}</SheetTitle>
+ <SheetDescription>{t('admin.catalogs.create_description')}</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">
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-destructive text-sm" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+ <Field>
+ <FieldLabel htmlFor="catalog-name">{t('admin.fields.name.label')}</FieldLabel>
+ <Input
+ id="catalog-name"
+ autoFocus
+ placeholder={t('admin.fields.catalog.name.placeholder')}
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name')}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+ </FieldGroup>
+ </div>
+ <SheetFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" disabled={form.formState.isSubmitting}>
+ {form.formState.isSubmitting
+ ? t('admin.actions.creating')
+ : t('admin.catalogs.create_label')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
diff --git a/packages/dashboard/src/schemas/catalog.ts b/packages/dashboard/src/schemas/catalog.ts
new file mode 100644
index 0000000000..98164b3b19
--- /dev/null
+++ b/packages/dashboard/src/schemas/catalog.ts
@@ -0,0 +1,23 @@
+import type { CatalogParams } from '@spree/admin-sdk'
+import { blankToNull } from '@spree/dashboard-core'
+import { requiredMessage } from '@spree/dashboard-ui'
+import { z } from 'zod/v4'
+
+export const catalogFormSchema = z.object({
+ name: z.string().min(1, { error: requiredMessage('name') }),
+ active: z.boolean(),
+ // Empty string = assortment-only (base prices).
+ price_list_id: z.string().optional(),
+})
+
+export type CatalogFormValues = z.infer<typeof catalogFormSchema>
+
+export const CATALOG_DEFAULTS: CatalogFormValues = { name: '', active: true, price_list_id: '' }
+
+export function catalogValuesToParams(values: CatalogFormValues): CatalogParams {
+ return {
+ name: values.name,
+ active: values.active,
+ price_list_id: blankToNull(values.price_list_id),
+ }
+}
diff --git a/packages/dashboard/src/schemas/company.ts b/packages/dashboard/src/schemas/company.ts
index 36a36893a6..fe2fbf8d04 100644
--- a/packages/dashboard/src/schemas/company.ts
+++ b/packages/dashboard/src/schemas/company.ts
@@ -1,5 +1,5 @@
import type {
- CompanyLocationParams,
+ CompanyAddressParams,
CompanyParams,
TaxExemptionCertificateParams,
TaxIdentifierParams,
@@ -8,6 +8,8 @@ import { blankToNull } from '@spree/dashboard-core'
import { requiredMessage } from '@spree/dashboard-ui'
import { z } from 'zod/v4'
+export const COMPANY_KINDS = ['company', 'division'] as const
+
export const companyFormSchema = z.object({
name: z.string().min(1, { error: requiredMessage('name') }),
})
@@ -22,7 +24,18 @@ export function companyValuesToParams(values: CompanyFormValues): CompanyParams
}
}
-const addressSchema = z.object({
+// A sub-unit is created in place under its parent: name + kind only — the
+// rest lives on its own page.
+export const companyChildFormSchema = z.object({
+ name: z.string().min(1, { error: requiredMessage('name') }),
+ kind: z.enum(COMPANY_KINDS),
+})
+
+export type CompanyChildFormValues = z.infer<typeof companyChildFormSchema>
+
+export const COMPANY_CHILD_DEFAULTS: CompanyChildFormValues = { name: '', kind: 'division' }
+
+const addressFieldsSchema = z.object({
first_name: z.string().optional(),
last_name: z.string().optional(),
company: z.string().optional(),
@@ -33,87 +46,50 @@ const addressSchema = z.object({
phone: z.string().optional(),
country_code: z.string().optional(),
state_code: z.string().optional(),
+ state_name: z.string().optional(),
})
-export const companyLocationFormSchema = z.object({
- name: z.string().min(1, { error: requiredMessage('name') }),
- billing_address: addressSchema,
- // Kept separate from billing rather than merged on submit, so a branch that
- // ships somewhere other than it is invoiced stays expressible.
- shipping_address: addressSchema,
- // Form-only: when set, the billing address is copied over the shipping one
- // on submit. Never sent to the API, which always takes both addresses.
- shipping_same_as_billing: z.boolean(),
+export const companyAddressFormSchema = z.object({
+ label: z.string().optional(),
+ default_billing: z.boolean(),
+ default_shipping: z.boolean(),
+ address: addressFieldsSchema,
})
-export type CompanyLocationFormValues = z.infer<typeof companyLocationFormSchema>
-
-const EMPTY_ADDRESS = {
- first_name: '',
- last_name: '',
- company: '',
- address1: '',
- address2: '',
- city: '',
- postal_code: '',
- phone: '',
- country_code: '',
- state_code: '',
-}
-
-export const COMPANY_LOCATION_DEFAULTS: CompanyLocationFormValues = {
- name: '',
- billing_address: { ...EMPTY_ADDRESS },
- shipping_address: { ...EMPTY_ADDRESS },
- shipping_same_as_billing: true,
+export type CompanyAddressFormValues = z.infer<typeof companyAddressFormSchema>
+
+export const COMPANY_ADDRESS_DEFAULTS: CompanyAddressFormValues = {
+ label: '',
+ default_billing: false,
+ default_shipping: false,
+ address: {
+ first_name: '',
+ last_name: '',
+ company: '',
+ address1: '',
+ address2: '',
+ city: '',
+ postal_code: '',
+ phone: '',
+ country_code: '',
+ state_code: '',
+ state_name: '',
+ },
}
-export function companyLocationValuesToParams(
- values: CompanyLocationFormValues,
-): CompanyLocationParams {
- const billing = values.billing_address
- const shipping = values.shipping_same_as_billing ? { ...billing } : values.shipping_address
-
+export function companyAddressValuesToParams(
+ values: CompanyAddressFormValues,
+): CompanyAddressParams {
return {
- name: values.name,
- // A branch may have no address at all, but an address that exists must be
- // complete — so an untouched fieldset is omitted rather than sent empty,
- // which would fail the address record's own validations.
- ...(isAddressBlank(billing) ? {} : { billing_address: billing }),
- ...(isAddressBlank(shipping) ? {} : { shipping_address: shipping }),
+ label: blankToNull(values.label),
+ default_billing: values.default_billing,
+ default_shipping: values.default_shipping,
+ address: Object.fromEntries(
+ Object.entries(values.address).filter(([, value]) => value !== undefined),
+ ),
}
}
-function isAddressBlank(address: Record<string, string | undefined>): boolean {
- return Object.values(address).every((value) => !value?.trim())
-}
-
-/**
- * Whether a saved branch's two addresses are the same, deciding how the edit
- * form opens. Compared field by field because they are separate records.
- */
-export function addressesMatch(
- billing: Record<string, unknown> | null | undefined,
- shipping: Record<string, unknown> | null | undefined,
-): boolean {
- if (!billing || !shipping) return false
-
- return ADDRESS_COMPARISON_KEYS.every((key) => (billing[key] ?? '') === (shipping[key] ?? ''))
-}
-
-const ADDRESS_COMPARISON_KEYS = [
- 'first_name',
- 'last_name',
- 'company',
- 'address1',
- 'address2',
- 'city',
- 'postal_code',
- 'phone',
- 'country_code',
- 'state_code',
-] as const
-
export const taxIdentifierFormSchema = z.object({
kind: z.string().min(1, { error: requiredMessage('tax_identifier.kind') }),
value: z.string().min(1, { error: requiredMessage('tax_identifier.value') }),
diff --git a/packages/dashboard/src/search/create-actions.ts b/packages/dashboard/src/search/create-actions.ts
index 9bb446a44c..9318b2931a 100644
--- a/packages/dashboard/src/search/create-actions.ts
+++ b/packages/dashboard/src/search/create-actions.ts
@@ -1,5 +1,6 @@
import { createActionRegistry, Subject } from '@spree/dashboard-core'
import {
+ BookOpenIcon,
BoxesIcon,
Building2Icon,
FolderTreeIcon,
@@ -104,6 +105,16 @@ createActionRegistry.add({
getRoute: (storeId) => ({ to: `/${storeId}/companies`, search: { new: true } }),
})
+createActionRegistry.add({
+ key: 'catalog',
+ labelKey: noun('catalog'),
+ aliasKeys: [noun('catalog_plural')],
+ icon: BookOpenIcon,
+ subject: Subject.Catalog,
+ position: 325,
+ getRoute: (storeId) => ({ to: `/${storeId}/products/catalogs`, search: { new: true } }),
+})
+
createActionRegistry.add({
key: 'seller',
labelKey: noun('seller'),
diff --git a/packages/dashboard/src/tables/catalogs.tsx b/packages/dashboard/src/tables/catalogs.tsx
new file mode 100644
index 0000000000..2ee6c8e985
--- /dev/null
+++ b/packages/dashboard/src/tables/catalogs.tsx
@@ -0,0 +1,50 @@
+import type { Catalog } from '@spree/admin-sdk'
+import { defineTable } from '@spree/dashboard-core'
+import { Badge, RelativeTime, ResourceNameCell } from '@spree/dashboard-ui'
+import i18n from 'i18next'
+import { BookOpenIcon } from 'lucide-react'
+
+defineTable<Catalog>('catalogs', {
+ title: i18n.t('admin.nav.catalogs'),
+ searchParam: 'name_cont',
+ searchPlaceholder: i18n.t('admin.catalogs.search_placeholder'),
+ defaultSort: { field: 'position', direction: 'asc' },
+ emptyIcon: <BookOpenIcon className="size-8 text-muted-foreground" />,
+ emptyMessage: i18n.t('admin.catalogs.empty'),
+ columns: [
+ {
+ key: 'name',
+ label: i18n.t('admin.fields.name.label'),
+ sortable: true,
+ filterable: true,
+ default: true,
+ render: (catalog) => (
+ <ResourceNameCell id={catalog.id} dataAttr="data-catalog-id" name={catalog.name} />
+ ),
+ },
+ {
+ key: 'active',
+ label: i18n.t('admin.fields.active.label'),
+ default: true,
+ render: (catalog) =>
+ catalog.active ? (
+ <Badge variant="outline">{i18n.t('admin.common.active')}</Badge>
+ ) : (
+ <Badge variant="secondary">{i18n.t('admin.common.inactive')}</Badge>
+ ),
+ },
+ {
+ key: 'products_count',
+ label: i18n.t('admin.catalogs.products_column'),
+ default: true,
+ render: (catalog) => catalog.products_count,
+ },
+ {
+ key: 'created_at',
+ label: i18n.t('admin.fields.created_at.label'),
+ sortable: true,
+ default: true,
+ render: (catalog) => <RelativeTime iso={catalog.created_at} />,
+ },
+ ],
+})
diff --git a/packages/dashboard/src/tables/companies.tsx b/packages/dashboard/src/tables/companies.tsx
deleted file mode 100644
index da27313614..0000000000
--- a/packages/dashboard/src/tables/companies.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import type { Company } from '@spree/admin-sdk'
-import { defineTable } from '@spree/dashboard-core'
-import { RelativeTime } from '@spree/dashboard-ui'
-import { Link } from '@tanstack/react-router'
-import i18n from 'i18next'
-import { Building2Icon } from 'lucide-react'
-
-defineTable<Company>('companies', {
- title: i18n.t('admin.nav.companies'),
- searchParam: 'name_cont',
- searchPlaceholder: i18n.t('admin.companies.search_placeholder'),
- defaultSort: { field: 'name', direction: 'asc' },
- emptyIcon: <Building2Icon className="size-8 text-muted-foreground" />,
- emptyMessage: i18n.t('admin.companies.empty'),
- columns: [
- {
- key: 'name',
- label: i18n.t('admin.fields.name.label'),
- sortable: true,
- filterable: true,
- default: true,
- render: (company) => (
- <Link
- to={'/$storeId/companies/$companyId' as string}
- params={{ companyId: company.id }}
- className="font-medium text-foreground no-underline"
- >
- {company.name}
- </Link>
- ),
- },
- {
- key: 'locations_count',
- label: i18n.t('admin.companies.locations_column'),
- default: true,
- render: (company) => company.locations_count,
- },
- {
- // Off by default: only a merchant reconciling against an ERP or PIM
- // wants a column of foreign keys, and they can switch it on.
- key: 'external_references',
- label: i18n.t('admin.fields.external_references.label'),
- filterable: true,
- default: false,
- render: (company) => Object.values(company.external_references ?? {}).join(', ') || '—',
- },
- {
- key: 'created_at',
- label: i18n.t('admin.fields.created_at.label'),
- sortable: true,
- default: true,
- render: (company) => <RelativeTime iso={company.created_at} />,
- },
- ],
-})