Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import { SELLER_PAYOUT_STATUSES } from '@spree/core'
import { defineTable, formatMoney, formatStoreDateTime } from '@spree/dashboard-core'
import { ResourceNameCell, StatusBadge } from '@spree/dashboard-ui'
import { HandCoinsIcon } from '@spree/dashboard-ui/icons'
import type { Payout } from '@spree/seller-sdk'
import i18n from 'i18next'
import { useStoreTimezone } from '../hooks/use-store-timezone'
/**
* A ledger row's date in the marketplace's timezone.
*
* Its own component because a table definition is module-level and has no
* access to hooks, while `render` is called inside the table's JSX — so a
* cell may use them like any other component.
*/
function LedgerDate({ iso }: { iso: string }) {
const timezone = useStoreTimezone()
return <>{formatStoreDateTime(iso, timezone)}</>
}
defineTable<Payout>('seller-payouts', {
title: i18n.t('payouts.title'),
searchParam: 'search',
searchPlaceholder: i18n.t('payouts.search_placeholder'),
defaultSort: { field: 'created_at', direction: 'desc' },
emptyIcon: <HandCoinsIcon className="size-8 text-muted-foreground" />,
emptyMessage: i18n.t('payouts.empty'),
columns: [
{
key: 'created_at',
label: i18n.t('payouts.columns.date'),
sortable: true,
filterable: true,
filterType: 'date',
quickFilter: true,
default: true,
render: (payout) => (
<ResourceNameCell
id={payout.id}
dataAttr="data-payout-id"
name={<LedgerDate iso={payout.created_at} />}
/>
),
},
{
key: 'status',
label: i18n.t('payouts.columns.status'),
sortable: true,
filterable: true,
filterType: 'enum',
filterOptions: SELLER_PAYOUT_STATUSES.map((status) => ({
value: status,
label: i18n.t(`earnings.statuses.${status}`),
})),
quickFilter: true,
default: true,
render: (payout) => (
<StatusBadge
status={payout.status}
label={i18n.t(`earnings.statuses.${payout.status}`, { defaultValue: payout.status })}
/>
),
},
{
key: 'transfers_count',
label: i18n.t('payouts.columns.earnings'),
default: true,
render: (payout) => payout.transfers_count,
},
{
key: 'reference',
label: i18n.t('payouts.columns.reference'),
default: true,
render: (payout) => payout.reference ?? '—',
},
{
key: 'amount',
label: i18n.t('payouts.columns.amount'),
sortable: true,
default: true,
className: 'text-right tabular-nums',
render: (payout) => formatMoney(payout.amount, payout.currency, i18n.language),
},
],
})