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.

1.2 KB
Raw Blame
import type { CustomerGroup } from '@spree/admin-sdk'
import { defineTable } from '@spree/dashboard-core'
import { ResourceNameCell } from '@spree/dashboard-ui'
import { UsersRoundIcon } from '@spree/dashboard-ui/icons'
import i18n from 'i18next'

defineTable<CustomerGroup>('customer-groups', {
  title: i18n.t('admin.customers.groups.table.title'),
  description: i18n.t('admin.table_descriptions.customer_groups'),
  docsPath: 'customers/customer-groups',
  searchParam: 'search',
  searchPlaceholder: i18n.t('admin.customers.groups.table.search_placeholder'),
  defaultSort: { field: 'name', direction: 'asc' },
  emptyIcon: <UsersRoundIcon className="size-8 text-muted-foreground" />,
  emptyMessage: i18n.t('admin.customers.groups.table.empty'),
  columns: [
    {
      key: 'name',
      label: i18n.t('admin.fields.name.label'),
      sortable: true,
      default: true,
      render: (g) => (
        <ResourceNameCell
          id={g.id}
          dataAttr="data-customer-group-id"
          name={g.name}
          secondary={g.description ?? undefined}
        />
      ),
    },
    {
      key: 'customers_count',
      label: i18n.t('admin.customers.groups.columns.customers'),
      default: true,
      render: (g) => g.customers_count,
    },
  ],
})