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
Added Earnings and Payouts to the seller panel
Damian Legawiec471d9d10d8e1
diff --git a/packages/seller-dashboard-starter/src/routeTree.gen.ts b/packages/seller-dashboard-starter/src/routeTree.gen.tsindex defb90a8bf..acf4378291 100644--- a/packages/seller-dashboard-starter/src/routeTree.gen.ts+++ b/packages/seller-dashboard-starter/src/routeTree.gen.ts@@ -22,7 +22,9 @@ import { Route as ProfileRouteImport } from './../../seller-dashboard/src/routesimport { Route as OnboardingRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/onboarding'import { Route as SettingsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/index'import { Route as ProductsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/index'+import { Route as PayoutsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index'import { Route as OrdersIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/orders/index'+import { Route as EarningsIndexRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index'import { Route as SettingsTeamRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/team'import { Route as SettingsStockLocationsRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/stock-locations'import { Route as SettingsPoliciesRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/policies'@@ -30,6 +32,7 @@ import { Route as SettingsPackageTypesRouteImport } from './../../seller-dashboaimport { Route as SettingsDeliveryMethodsRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/settings/delivery-methods'import { Route as ProductsNewRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/new'import { Route as ProductsProductIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/products/$productId'+import { Route as PayoutsPayoutIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId'import { Route as OrdersOrderIdRouteImport } from './../../seller-dashboard/src/routes/_authenticated/$sellerId/orders/$orderId'const resetPasswordRoute = resetPasswordRouteImport.update({@@ -97,11 +100,21 @@ const ProductsIndexRoute = ProductsIndexRouteImport.update({path: '/products/',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const PayoutsIndexRoute = PayoutsIndexRouteImport.update({+ id: '/payouts/',+ path: '/payouts/',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const OrdersIndexRoute = OrdersIndexRouteImport.update({id: '/orders/',path: '/orders/',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const EarningsIndexRoute = EarningsIndexRouteImport.update({+ id: '/earnings/',+ path: '/earnings/',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const SettingsTeamRoute = SettingsTeamRouteImport.update({id: '/team',path: '/team',@@ -137,6 +150,11 @@ const ProductsProductIdRoute = ProductsProductIdRouteImport.update({path: '/products/$productId',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const PayoutsPayoutIdRoute = PayoutsPayoutIdRouteImport.update({+ id: '/payouts/$payoutId',+ path: '/payouts/$payoutId',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({id: '/orders/$orderId',path: '/orders/$orderId',@@ -155,6 +173,7 @@ export interface FileRoutesByFullPath {'/$sellerId/settings': typeof SettingsRouteWithChildren'/$sellerId/': typeof IndexRoute'/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/$sellerId/products/$productId': typeof ProductsProductIdRoute'/$sellerId/products/new': typeof ProductsNewRoute'/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -162,7 +181,9 @@ export interface FileRoutesByFullPath {'/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$sellerId/settings/team': typeof SettingsTeamRoute+ '/$sellerId/earnings/': typeof EarningsIndexRoute'/$sellerId/orders/': typeof OrdersIndexRoute+ '/$sellerId/payouts/': typeof PayoutsIndexRoute'/$sellerId/products/': typeof ProductsIndexRoute'/$sellerId/settings/': typeof SettingsIndexRoute}@@ -176,6 +197,7 @@ export interface FileRoutesByTo {'/$sellerId/profile': typeof ProfileRoute'/$sellerId': typeof IndexRoute'/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/$sellerId/products/$productId': typeof ProductsProductIdRoute'/$sellerId/products/new': typeof ProductsNewRoute'/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -183,7 +205,9 @@ export interface FileRoutesByTo {'/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$sellerId/settings/team': typeof SettingsTeamRoute+ '/$sellerId/earnings': typeof EarningsIndexRoute'/$sellerId/orders': typeof OrdersIndexRoute+ '/$sellerId/payouts': typeof PayoutsIndexRoute'/$sellerId/products': typeof ProductsIndexRoute'/$sellerId/settings': typeof SettingsIndexRoute}@@ -201,6 +225,7 @@ export interface FileRoutesById {'/_authenticated/$sellerId/settings': typeof SettingsRouteWithChildren'/_authenticated/$sellerId/': typeof IndexRoute'/_authenticated/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/_authenticated/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/_authenticated/$sellerId/products/$productId': typeof ProductsProductIdRoute'/_authenticated/$sellerId/products/new': typeof ProductsNewRoute'/_authenticated/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -208,7 +233,9 @@ export interface FileRoutesById {'/_authenticated/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/_authenticated/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/_authenticated/$sellerId/settings/team': typeof SettingsTeamRoute+ '/_authenticated/$sellerId/earnings/': typeof EarningsIndexRoute'/_authenticated/$sellerId/orders/': typeof OrdersIndexRoute+ '/_authenticated/$sellerId/payouts/': typeof PayoutsIndexRoute'/_authenticated/$sellerId/products/': typeof ProductsIndexRoute'/_authenticated/$sellerId/settings/': typeof SettingsIndexRoute}@@ -226,6 +253,7 @@ export interface FileRouteTypes {| '/$sellerId/settings'| '/$sellerId/'| '/$sellerId/orders/$orderId'+ | '/$sellerId/payouts/$payoutId'| '/$sellerId/products/$productId'| '/$sellerId/products/new'| '/$sellerId/settings/delivery-methods'@@ -233,7 +261,9 @@ export interface FileRouteTypes {| '/$sellerId/settings/policies'| '/$sellerId/settings/stock-locations'| '/$sellerId/settings/team'+ | '/$sellerId/earnings/'| '/$sellerId/orders/'+ | '/$sellerId/payouts/'| '/$sellerId/products/'| '/$sellerId/settings/'fileRoutesByTo: FileRoutesByTo@@ -247,6 +277,7 @@ export interface FileRouteTypes {| '/$sellerId/profile'| '/$sellerId'| '/$sellerId/orders/$orderId'+ | '/$sellerId/payouts/$payoutId'| '/$sellerId/products/$productId'| '/$sellerId/products/new'| '/$sellerId/settings/delivery-methods'@@ -254,7 +285,9 @@ export interface FileRouteTypes {| '/$sellerId/settings/policies'| '/$sellerId/settings/stock-locations'| '/$sellerId/settings/team'+ | '/$sellerId/earnings'| '/$sellerId/orders'+ | '/$sellerId/payouts'| '/$sellerId/products'| '/$sellerId/settings'id:@@ -271,6 +304,7 @@ export interface FileRouteTypes {| '/_authenticated/$sellerId/settings'| '/_authenticated/$sellerId/'| '/_authenticated/$sellerId/orders/$orderId'+ | '/_authenticated/$sellerId/payouts/$payoutId'| '/_authenticated/$sellerId/products/$productId'| '/_authenticated/$sellerId/products/new'| '/_authenticated/$sellerId/settings/delivery-methods'@@ -278,7 +312,9 @@ export interface FileRouteTypes {| '/_authenticated/$sellerId/settings/policies'| '/_authenticated/$sellerId/settings/stock-locations'| '/_authenticated/$sellerId/settings/team'+ | '/_authenticated/$sellerId/earnings/'| '/_authenticated/$sellerId/orders/'+ | '/_authenticated/$sellerId/payouts/'| '/_authenticated/$sellerId/products/'| '/_authenticated/$sellerId/settings/'fileRoutesById: FileRoutesById@@ -384,6 +420,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsIndexRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/payouts/': {+ id: '/_authenticated/$sellerId/payouts/'+ path: '/payouts'+ fullPath: '/$sellerId/payouts/'+ preLoaderRoute: typeof PayoutsIndexRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/orders/': {id: '/_authenticated/$sellerId/orders/'path: '/orders'@@ -391,6 +434,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof OrdersIndexRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/earnings/': {+ id: '/_authenticated/$sellerId/earnings/'+ path: '/earnings'+ fullPath: '/$sellerId/earnings/'+ preLoaderRoute: typeof EarningsIndexRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/settings/team': {id: '/_authenticated/$sellerId/settings/team'path: '/team'@@ -440,6 +490,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsProductIdRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/payouts/$payoutId': {+ id: '/_authenticated/$sellerId/payouts/$payoutId'+ path: '/payouts/$payoutId'+ fullPath: '/$sellerId/payouts/$payoutId'+ preLoaderRoute: typeof PayoutsPayoutIdRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/orders/$orderId': {id: '/_authenticated/$sellerId/orders/$orderId'path: '/orders/$orderId'@@ -478,9 +535,12 @@ interface authenticatedSellerIdRouteChildren {SettingsRoute: typeof SettingsRouteWithChildrenIndexRoute: typeof IndexRouteOrdersOrderIdRoute: typeof OrdersOrderIdRoute+ PayoutsPayoutIdRoute: typeof PayoutsPayoutIdRouteProductsProductIdRoute: typeof ProductsProductIdRouteProductsNewRoute: typeof ProductsNewRoute+ EarningsIndexRoute: typeof EarningsIndexRouteOrdersIndexRoute: typeof OrdersIndexRoute+ PayoutsIndexRoute: typeof PayoutsIndexRouteProductsIndexRoute: typeof ProductsIndexRoute}@@ -490,9 +550,12 @@ const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {SettingsRoute: SettingsRouteWithChildren,IndexRoute: IndexRoute,OrdersOrderIdRoute: OrdersOrderIdRoute,+ PayoutsPayoutIdRoute: PayoutsPayoutIdRoute,ProductsProductIdRoute: ProductsProductIdRoute,ProductsNewRoute: ProductsNewRoute,+ EarningsIndexRoute: EarningsIndexRoute,OrdersIndexRoute: OrdersIndexRoute,+ PayoutsIndexRoute: PayoutsIndexRoute,ProductsIndexRoute: ProductsIndexRoute,}diff --git a/packages/seller-dashboard/src/components/finance/balance-summary.tsx b/packages/seller-dashboard/src/components/finance/balance-summary.tsxnew file mode 100644index 0000000000..d99bbea274--- /dev/null+++ b/packages/seller-dashboard/src/components/finance/balance-summary.tsx@@ -0,0 +1,55 @@+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@spree/dashboard-ui'+import type { Balance } from '@spree/seller-sdk'+import { useTranslation } from 'react-i18next'++/**+ * What the marketplace owes this seller, one card per currency.+ *+ * Nothing is ever converted between currencies, so two currencies are two+ * positions rather than one total. `pending` is money the payout provider has+ * not confirmed yet — shown beside the balance so a seller who has shipped+ * does not read their own order as unpaid.+ */+export function BalanceSummary({ balances }: { balances: Balance[] }) {+ const { t } = useTranslation()++ if (balances.length === 0) {+ return (+ <Card>+ <CardHeader>+ <CardTitle>{t('earnings.balance.title')}</CardTitle>+ <CardDescription>{t('earnings.balance.empty')}</CardDescription>+ </CardHeader>+ </Card>+ )+ }++ return (+ <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">+ {balances.map((balance) => (+ <Card key={balance.currency}>+ <CardHeader>+ <CardTitle>{t('earnings.balance.owed', { currency: balance.currency })}</CardTitle>+ </CardHeader>+ <CardContent className="flex flex-col gap-3">+ <span className="text-2xl font-semibold tabular-nums">{balance.display_balance}</span>+ <dl className="flex flex-col gap-1 text-sm">+ <Figure label={t('earnings.balance.earned')} value={balance.display_earned} />+ <Figure label={t('earnings.balance.paid')} value={balance.display_paid} />+ <Figure label={t('earnings.balance.pending')} value={balance.display_pending} />+ </dl>+ </CardContent>+ </Card>+ ))}+ </div>+ )+}++function Figure({ label, value }: { label: string; value: string }) {+ return (+ <div className="flex items-center justify-between gap-3">+ <dt className="text-muted-foreground">{label}</dt>+ <dd className="tabular-nums">{value}</dd>+ </div>+ )+}diff --git a/packages/seller-dashboard/src/components/orders/order-earnings-card.tsx b/packages/seller-dashboard/src/components/orders/order-earnings-card.tsxnew file mode 100644index 0000000000..f2bf2762e4--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/order-earnings-card.tsx@@ -0,0 +1,92 @@+import {+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ StatusBadge,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@spree/dashboard-ui'+import { BanknoteIcon } from '@spree/dashboard-ui/icons'+import type { Order } from '@spree/seller-sdk'+import { Link, useParams } from '@tanstack/react-router'+import { useTranslation } from 'react-i18next'+import { useTransfers } from '../../hooks/use-ledger'++/**+ * What this order earned the seller: the sale less the marketplace's+ * commission, credited once the goods went out, and a reversal row for+ * anything refunded since.+ *+ * Renders nothing until there is something to show — an order is not earned+ * until it is fulfilled, and an empty card on every open order would only be+ * noise.+ */+export function OrderEarningsCard({ order }: { order: Order }) {+ const { t } = useTranslation()+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })+ const { data } = useTransfers({ order_id_eq: order.id })++ const transfers = data?.data ?? []+ if (transfers.length === 0) return null++ return (+ <Card>+ <CardHeader>+ <CardTitle>+ <BanknoteIcon className="size-4" />+ {t('orders.earnings.title')}+ </CardTitle>+ </CardHeader>++ <CardContent className="p-0">+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('earnings.columns.kind')}</TableHead>+ <TableHead>{t('earnings.columns.status')}</TableHead>+ <TableHead>{t('orders.earnings.payout')}</TableHead>+ <TableHead className="text-right">{t('earnings.columns.amount')}</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {transfers.map((transfer) => (+ <TableRow key={transfer.id}>+ <TableCell>+ {t(`earnings.kinds.${transfer.kind}`, { defaultValue: transfer.kind })}+ </TableCell>+ <TableCell>+ <StatusBadge+ status={transfer.status}+ label={t(`earnings.statuses.${transfer.status}`, {+ defaultValue: transfer.status,+ })}+ />+ </TableCell>+ <TableCell>+ {transfer.payout_id ? (+ <Link+ to="/$sellerId/payouts/$payoutId"+ params={{ sellerId, payoutId: transfer.payout_id }}+ >+ {t('orders.earnings.view_payout')}+ </Link>+ ) : (+ <span className="text-muted-foreground">+ {t('orders.earnings.not_settled')}+ </span>+ )}+ </TableCell>+ <TableCell className="text-right tabular-nums">{transfer.display_amount}</TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </CardContent>+ </Card>+ )+}diff --git a/packages/seller-dashboard/src/components/orders/order-payment-card.tsx b/packages/seller-dashboard/src/components/orders/order-payment-card.tsxnew file mode 100644index 0000000000..08b3a32c9b--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/order-payment-card.tsx@@ -0,0 +1,94 @@+import {+ Card,+ CardAction,+ CardContent,+ CardHeader,+ CardTitle,+ Separator,+ StatusBadge,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@spree/dashboard-ui'+import { CreditCardIcon } from '@spree/dashboard-ui/icons'+import type { Order } from '@spree/seller-sdk'+import { useTranslation } from 'react-i18next'+import { ReadRow } from '../read-row'++/**+ * What the buyer paid for this order.+ *+ * On a marketplace the customer pays once for a basket that may span several+ * sellers, so what this order has is a share of that payment rather than a+ * payment of its own — the shares are what the table lists. How the buyer+ * paid, and to which gateway, is the marketplace's business and is not here.+ *+ * An order placed with this seller alone does not split, so it has no shares+ * and only the totals above are shown.+ */+export function OrderPaymentCard({ order }: { order: Order }) {+ const { t } = useTranslation()+ const splits = order.payment_splits ?? []++ return (+ <Card>+ <CardHeader>+ <CardTitle>+ <CreditCardIcon className="size-4" />+ {t('orders.payment.title')}+ </CardTitle>+ {order.payment_status && (+ <CardAction>+ <StatusBadge+ status={order.payment_status}+ label={t(`orders.payment_statuses.${order.payment_status}`, {+ defaultValue: order.payment_status,+ })}+ />+ </CardAction>+ )}+ </CardHeader>++ <CardContent className="flex flex-col gap-3">+ <ReadRow label={t('orders.summary.payment_total')}>{order.display_payment_total}</ReadRow>+ <ReadRow label={t('orders.summary.outstanding_balance')}>+ {order.display_amount_due}+ </ReadRow>+ </CardContent>++ {splits.length > 0 && (+ <>+ <Separator />+ <p className="px-6 pt-4 text-sm text-muted-foreground">+ {t('orders.payment.share_help')}+ </p>+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('orders.payment.authorized')}</TableHead>+ <TableHead>{t('orders.payment.captured')}</TableHead>+ <TableHead>{t('orders.payment.refunded')}</TableHead>+ <TableHead className="text-right">{t('orders.payment.refundable')}</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {splits.map((split) => (+ <TableRow key={split.id}>+ <TableCell className="tabular-nums">{split.display_authorized_amount}</TableCell>+ <TableCell className="tabular-nums">{split.display_captured_amount}</TableCell>+ <TableCell className="tabular-nums">{split.display_refunded_amount}</TableCell>+ <TableCell className="text-right tabular-nums">+ {split.display_refundable_amount}+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </>+ )}+ </Card>+ )+}diff --git a/packages/seller-dashboard/src/components/read-row.tsx b/packages/seller-dashboard/src/components/read-row.tsxnew file mode 100644index 0000000000..eb143fb850--- /dev/null+++ b/packages/seller-dashboard/src/components/read-row.tsx@@ -0,0 +1,16 @@+import type { ReactNode } from 'react'+import { useTranslation } from 'react-i18next'++/** One labelled value in a read-only card, with a placeholder when unset. */+export function ReadRow({ label, children }: { label: string; children: ReactNode }) {+ const { t } = useTranslation()++ return (+ <div className="flex items-start justify-between gap-3 text-sm">+ <span className="text-muted-foreground">{label}</span>+ <span className="text-right">+ {children ?? <span className="text-muted-foreground">{t('profile.not_provided')}</span>}+ </span>+ </div>+ )+}diff --git a/packages/seller-dashboard/src/hooks/use-ledger.ts b/packages/seller-dashboard/src/hooks/use-ledger.tsnew file mode 100644index 0000000000..3f7284af2a--- /dev/null+++ b/packages/seller-dashboard/src/hooks/use-ledger.ts@@ -0,0 +1,46 @@+import { useResourceKey } from '@spree/dashboard-core'+import { useQuery } from '@tanstack/react-query'+import { sellerClient } from '../api-client'++/**+ * Where this seller stands, one row per currency.+ *+ * Nothing is ever converted between currencies, so a seller trading in two+ * has two positions and the panel shows both rather than a total.+ */+export function useBalances() {+ return useQuery({+ queryKey: useResourceKey('seller-balances'),+ queryFn: () => sellerClient().balances.list(),+ })+}++/** One settlement, for its own page. */+export function usePayout(payoutId: string) {+ return useQuery({+ queryKey: useResourceKey('seller-payout', payoutId),+ queryFn: () => sellerClient().payouts.get(payoutId),+ enabled: !!payoutId,+ })+}++/**+ * The earnings a settlement covers, or the ones an order produced.+ *+ * Both read the same list filtered a different way, so the pages that ask+ * either question share one hook and one query key shape.+ *+ * Paged rather than capped: the server clamps `limit` at 100, and a payout+ * covering more than that must not render one page and call it the whole+ * settlement.+ */+export function useTransfers(filter: { payout_id_eq?: string; order_id_eq?: string }, page = 1) {+ const key = filter.payout_id_eq ?? filter.order_id_eq ?? 'all'++ return useQuery({+ queryKey: useResourceKey('seller-transfers', key, String(page)),+ queryFn: () => sellerClient().transfers.list({ ...filter, limit: 100, page }),+ enabled: !!(filter.payout_id_eq || filter.order_id_eq),+ placeholderData: (previous) => previous,+ })+}diff --git a/packages/seller-dashboard/src/hooks/use-order.ts b/packages/seller-dashboard/src/hooks/use-order.tsindex ad877287dc..642bce597e 100644--- a/packages/seller-dashboard/src/hooks/use-order.ts+++ b/packages/seller-dashboard/src/hooks/use-order.ts@@ -8,7 +8,9 @@ import { sellerClient } from '../api-client'export function useOrder(orderId: string) {return useQuery({queryKey: useResourceKey('seller-order', orderId),- queryFn: () => sellerClient().orders.get(orderId),+ // The shares of the basket's payment are expand-gated, and the payment+ // card is what reads them.+ queryFn: () => sellerClient().orders.get(orderId, { expand: ['payment_splits'] }),enabled: !!orderId,})}diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.jsonindex 6853d3c5fb..9da0a2c75a 100644--- a/packages/seller-dashboard/src/locales/en.json+++ b/packages/seller-dashboard/src/locales/en.json@@ -256,6 +256,41 @@"everywhere": "Everywhere this kind of goods reaches"}},+ "earnings": {+ "balance": {+ "title": "Balance",+ "empty": "Once an order of yours is fulfilled, what it earned shows up here.",+ "owed": "Owed to you ({{currency}})",+ "earned": "Earned",+ "paid": "Paid out",+ "pending": "On its way"+ },+ "columns": {+ "date": "Date",+ "order": "Order",+ "kind": "Type",+ "status": "Status",+ "amount": "Amount"+ },+ "kinds": {+ "earning": "Sale",+ "refund_reversal": "Refund"+ },+ "search_placeholder": "Search by reference",+ "statuses": {+ "pending": "Pending",+ "processing": "Processing",+ "completed": "Completed",+ "failed": "Failed",+ "unresolved": "Needs checking"+ },+ "subtitle": "What your sales have earned, and where you stand with the marketplace.",+ "title": "Earnings",+ "transfers": {+ "title": "Earnings",+ "empty": "No earnings yet."+ }+ },"forgot_password": {"back_to_login": "Back to sign in","email": "Email",@@ -303,7 +338,9 @@"sign_out": "Sign out","team": "Team","delivery_methods": "Delivery methods",- "package_types": "Package types"+ "package_types": "Package types",+ "earnings": "Earnings",+ "payouts": "Payouts"},"onboarding": {"accept_terms": "Accept the terms",@@ -357,6 +394,12 @@"title": "Customer"},"customer_note": "Customer note",+ "earnings": {+ "title": "What you earned",+ "payout": "Payout",+ "view_payout": "View payout",+ "not_settled": "Not paid out yet"+ },"empty": "No orders yet. They appear here as customers buy from you.","fulfill": "Mark as fulfilled","fulfillment_statuses": {@@ -408,6 +451,14 @@},"items": "Items","not_found": "That order could not be found.",+ "payment": {+ "title": "Payment",+ "share_help": "Your share of what the customer paid for this basket.",+ "authorized": "Authorized",+ "captured": "Captured",+ "refunded": "Refunded",+ "refundable": "Refundable"+ },"payment_statuses": {"none": "Unpaid","authorized": "Authorized",@@ -494,6 +545,27 @@"title": "Orders","tracking_label": "Tracking number"},+ "payouts": {+ "columns": {+ "date": "Date",+ "status": "Status",+ "earnings": "Earnings",+ "reference": "Reference",+ "amount": "Amount"+ },+ "detail": {+ "covers_one": "Covers {{count}} earning",+ "covers_other": "Covers {{count}} earnings",+ "covers_empty": "This payout covers no earnings.",+ "settlement": "Payout",+ "period": "Period"+ },+ "empty": "No payouts yet.",+ "not_found": "This payout could not be found.",+ "search_placeholder": "Search by reference",+ "subtitle": "What the marketplace has sent you, and what is on its way.",+ "title": "Payouts"+ },"policies": {"add": "Add policy","columns": {diff --git a/packages/seller-dashboard/src/nav/default.ts b/packages/seller-dashboard/src/nav/default.tsindex db27a0d0fa..1410861760 100644--- a/packages/seller-dashboard/src/nav/default.ts+++ b/packages/seller-dashboard/src/nav/default.ts@@ -1,6 +1,8 @@import { hasVisibleSettingsEntries, i18n, nav } from '@spree/dashboard-core'import {+ BanknoteIcon,ClipboardCheckIcon,+ HandCoinsIcon,HomeIcon,PackageIcon,SettingsIcon,@@ -60,6 +62,28 @@ nav.add({subject: 'Spree::Order',})+// The seller's own books. Two entries rather than one because they answer+// different questions: what an order earned, and whether last week's+// settlement went out. Both gated on the ledger key, so a teammate given+// orders but not money sees neither.+nav.add({+ key: 'earnings',+ label: i18n.t('nav.earnings'),+ path: '/earnings',+ icon: BanknoteIcon,+ position: 130,+ subject: 'seller_earnings',+})++nav.add({+ key: 'payouts',+ label: i18n.t('nav.payouts'),+ path: '/payouts',+ icon: HandCoinsIcon,+ position: 140,+ subject: 'seller_earnings',+})+nav.add({key: 'profile',label: i18n.t('nav.profile'),diff --git a/packages/seller-dashboard/src/pages/earnings.tsx b/packages/seller-dashboard/src/pages/earnings.tsxnew file mode 100644index 0000000000..17591dd756--- /dev/null+++ b/packages/seller-dashboard/src/pages/earnings.tsx@@ -0,0 +1,39 @@+import { PageHeader, type ResourceSearch, ResourceTable } from '@spree/dashboard-core'+import { Skeleton } from '@spree/dashboard-ui'+import type { Transfer } from '@spree/seller-sdk'+import { useTranslation } from 'react-i18next'+import { sellerClient } from '../api-client'+import { BalanceSummary } from '../components/finance/balance-summary'+import { useBalances } from '../hooks/use-ledger'+import '../tables/transfers'++/**+ * What this seller has earned: where they stand overall, then the sale-by-sale+ * rows behind it.+ *+ * Read-only. An earning is written when an order is fulfilled and corrected by+ * a reversal when it is refunded, so there is nothing here to edit.+ */+export function EarningsPage({ search }: { search: ResourceSearch }) {+ const { t } = useTranslation()+ const { data, isLoading } = useBalances()++ return (+ <div className="flex flex-col gap-4">+ <PageHeader title={t('earnings.title')} subtitle={t('earnings.subtitle')} />++ {isLoading ? (+ <Skeleton className="h-36 w-full" />+ ) : (+ <BalanceSummary balances={data?.data ?? []} />+ )}++ <ResourceTable<Transfer>+ tableKey="seller-transfers"+ queryKey="seller-transfers-list"+ queryFn={(params) => sellerClient().transfers.list(params)}+ searchParams={search}+ />+ </div>+ )+}diff --git a/packages/seller-dashboard/src/pages/order.tsx b/packages/seller-dashboard/src/pages/order.tsxindex 28e60a528c..72ce8c8df5 100644--- a/packages/seller-dashboard/src/pages/order.tsx+++ b/packages/seller-dashboard/src/pages/order.tsx@@ -9,7 +9,9 @@ import { CenteredMessage } from '../components/centered-message'import { FulfillmentsCard } from '../components/orders/fulfillments-card'import { OrderCancelDialog } from '../components/orders/order-cancel-dialog'import { OrderCustomerCard, OrderSummaryCard } from '../components/orders/order-cards'+import { OrderEarningsCard } from '../components/orders/order-earnings-card'import { InternalNoteCard, SpecialInstructionsCard } from '../components/orders/order-notes-cards'+import { OrderPaymentCard } from '../components/orders/order-payment-card'import { ClaimsCard, ExchangesCard } from '../components/orders/post-sale-cards'import { ReturnsCard } from '../components/orders/returns-card'import { RetryableError } from '../components/retryable-error'@@ -103,6 +105,12 @@ export function OrderPage() {</>)}<OrderSummaryCard order={order} />+ {placed && (+ <>+ <OrderPaymentCard order={order} />+ <OrderEarningsCard order={order} />+ </>+ )}</>}sidebar={diff --git a/packages/seller-dashboard/src/pages/payout.tsx b/packages/seller-dashboard/src/pages/payout.tsxnew file mode 100644index 0000000000..9d9aab1d43--- /dev/null+++ b/packages/seller-dashboard/src/pages/payout.tsx@@ -0,0 +1,148 @@+import { PageHeader } from '@spree/dashboard-core'+import {+ Card,+ CardHeader,+ CardTitle,+ Pagination,+ ResourceLayout,+ StatusBadge,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@spree/dashboard-ui'+import { HandCoinsIcon } from '@spree/dashboard-ui/icons'+import { Link, useParams } from '@tanstack/react-router'+import i18n from 'i18next'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'+import { CenteredMessage } from '../components/centered-message'+import { ReadRow } from '../components/read-row'+import { RetryableError } from '../components/retryable-error'+import { usePayout, useTransfers } from '../hooks/use-ledger'++/**+ * One settlement, and the earnings it covers.+ *+ * The itemisation is the point: a seller reconciling a deposit against their+ * own books needs to see which sales it paid for, not just a total.+ */+export function PayoutPage() {+ const { t } = useTranslation()+ const { sellerId, payoutId } = useParams({ from: '/_authenticated/$sellerId/payouts/$payoutId' })++ const [page, setPage] = useState(1)++ const { data: payout, isLoading, isError, refetch } = usePayout(payoutId)+ const { data: transfers } = useTransfers({ payout_id_eq: payoutId }, page)++ if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>+ if (isError) return <RetryableError onRetry={() => refetch()} />+ if (!payout) return <CenteredMessage>{t('payouts.not_found')}</CenteredMessage>++ const rows = transfers?.data ?? []++ return (+ <ResourceLayout+ header={+ <PageHeader+ title={payout.display_amount}+ subtitle={formatDate(payout.created_at)}+ backTo="payouts"+ badges={+ <StatusBadge+ status={payout.status}+ label={t(`earnings.statuses.${payout.status}`, { defaultValue: payout.status })}+ />+ }+ resource={{ id: payout.id }}+ />+ }+ main={+ <Card>+ <CardHeader>+ <CardTitle>+ <HandCoinsIcon className="size-4" />+ {/* The settlement's own count, not the rows this page happened+ to load — the list is paged. */}+ {t('payouts.detail.covers', { count: payout.transfers_count })}+ </CardTitle>+ </CardHeader>++ {rows.length === 0 ? (+ <p className="px-6 pb-6 text-sm text-muted-foreground">+ {t('payouts.detail.covers_empty')}+ </p>+ ) : (+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('earnings.columns.date')}</TableHead>+ <TableHead>{t('earnings.columns.order')}</TableHead>+ <TableHead>{t('earnings.columns.kind')}</TableHead>+ <TableHead className="text-right">{t('earnings.columns.amount')}</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {rows.map((transfer) => (+ <TableRow key={transfer.id}>+ <TableCell>{formatDate(transfer.created_at)}</TableCell>+ <TableCell>+ {transfer.order_id ? (+ <Link+ to="/$sellerId/orders/$orderId"+ params={{ sellerId, orderId: transfer.order_id }}+ className="no-underline"+ >+ {transfer.order_number ?? transfer.order_id}+ </Link>+ ) : (+ '—'+ )}+ </TableCell>+ <TableCell className="text-muted-foreground">+ {t(`earnings.kinds.${transfer.kind}`, { defaultValue: transfer.kind })}+ </TableCell>+ <TableCell className="text-right tabular-nums">+ {transfer.display_amount}+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ )}+ {transfers?.meta && transfers.meta.pages > 1 && (+ <Pagination meta={transfers.meta} onPageChange={setPage} />+ )}+ </Card>+ }+ sidebar={+ <Card>+ <CardHeader>+ <CardTitle>{t('payouts.detail.settlement')}</CardTitle>+ </CardHeader>+ <div className="flex flex-col gap-3 px-6 pb-6">+ <ReadRow label={t('payouts.columns.amount')}>{payout.display_amount}</ReadRow>+ <ReadRow label={t('payouts.columns.reference')}>{payout.reference}</ReadRow>+ <ReadRow label={t('payouts.detail.period')}>+ {payout.period_start && payout.period_end+ ? `${formatDate(payout.period_start)} – ${formatDate(payout.period_end)}`+ : null}+ </ReadRow>+ </div>+ </Card>+ }+ />+ )+}++function formatDate(iso: string | null | undefined) {+ if (!iso) return '—'+ return new Date(iso).toLocaleDateString(i18n.language, {+ month: 'short',+ day: 'numeric',+ year: 'numeric',+ })+}diff --git a/packages/seller-dashboard/src/pages/payouts.tsx b/packages/seller-dashboard/src/pages/payouts.tsxnew file mode 100644index 0000000000..7293c916f7--- /dev/null+++ b/packages/seller-dashboard/src/pages/payouts.tsx@@ -0,0 +1,31 @@+import { PageHeader, type ResourceSearch, ResourceTable } from '@spree/dashboard-core'+import { useRowClickBridge } from '@spree/dashboard-ui'+import type { Payout } from '@spree/seller-sdk'+import { useNavigate, useParams } from '@tanstack/react-router'+import { useTranslation } from 'react-i18next'+import { sellerClient } from '../api-client'+import '../tables/payouts'++/** What the marketplace has sent this seller, and what is on its way. */+export function PayoutsPage({ search }: { search: ResourceSearch }) {+ const { t } = useTranslation()+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })+ const navigate = useNavigate()++ useRowClickBridge('data-payout-id', (payoutId: string) =>+ navigate({ to: '/$sellerId/payouts/$payoutId', params: { sellerId, payoutId } }),+ )++ return (+ <div className="flex flex-col gap-4">+ <PageHeader title={t('payouts.title')} subtitle={t('payouts.subtitle')} />++ <ResourceTable<Payout>+ tableKey="seller-payouts"+ queryKey="seller-payouts-list"+ queryFn={(params) => sellerClient().payouts.list(params)}+ searchParams={search}+ />+ </div>+ )+}diff --git a/packages/seller-dashboard/src/pages/profile.tsx b/packages/seller-dashboard/src/pages/profile.tsxindex da6e38d6f1..9280c69a4a 100644--- a/packages/seller-dashboard/src/pages/profile.tsx+++ b/packages/seller-dashboard/src/pages/profile.tsx@@ -26,12 +26,12 @@ import { PackageIcon, PencilIcon, StoreIcon, UsersIcon } from '@spree/dashboard-import type { Profile } from '@spree/seller-sdk'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'import { useParams } from '@tanstack/react-router'-import type { ReactNode } from 'react'import { useEffect, useState } from 'react'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { sellerClient } from '../api-client'import { CenteredMessage } from '../components/centered-message'+import { ReadRow } from '../components/read-row'import { SellerAddressCard } from '../components/seller-address-card'import { SellerBusinessCard } from '../components/seller-business-card'import { SellerReturnsLocationCard } from '../components/seller-returns-location-card'@@ -387,16 +387,3 @@ function EditProfileSheet({</Sheet>)}--function ReadRow({ label, children }: { label: string; children: ReactNode }) {- const { t } = useTranslation()-- return (- <div className="flex items-start justify-between gap-3 text-sm">- <span className="text-muted-foreground">{label}</span>- <span className="text-right">- {children ?? <span className="text-muted-foreground">{t('profile.not_provided')}</span>}- </span>- </div>- )-}diff --git a/packages/seller-dashboard/src/routeTree.gen.ts b/packages/seller-dashboard/src/routeTree.gen.tsindex 7ec2f094d5..71a99970fa 100644--- a/packages/seller-dashboard/src/routeTree.gen.ts+++ b/packages/seller-dashboard/src/routeTree.gen.ts@@ -22,7 +22,9 @@ import { Route as ProfileRouteImport } from './routes/_authenticated/$sellerId/pimport { Route as OnboardingRouteImport } from './routes/_authenticated/$sellerId/onboarding'import { Route as SettingsIndexRouteImport } from './routes/_authenticated/$sellerId/settings/index'import { Route as ProductsIndexRouteImport } from './routes/_authenticated/$sellerId/products/index'+import { Route as PayoutsIndexRouteImport } from './routes/_authenticated/$sellerId/payouts/index'import { Route as OrdersIndexRouteImport } from './routes/_authenticated/$sellerId/orders/index'+import { Route as EarningsIndexRouteImport } from './routes/_authenticated/$sellerId/earnings/index'import { Route as SettingsTeamRouteImport } from './routes/_authenticated/$sellerId/settings/team'import { Route as SettingsStockLocationsRouteImport } from './routes/_authenticated/$sellerId/settings/stock-locations'import { Route as SettingsPoliciesRouteImport } from './routes/_authenticated/$sellerId/settings/policies'@@ -30,6 +32,7 @@ import { Route as SettingsPackageTypesRouteImport } from './routes/_authenticateimport { Route as SettingsDeliveryMethodsRouteImport } from './routes/_authenticated/$sellerId/settings/delivery-methods'import { Route as ProductsNewRouteImport } from './routes/_authenticated/$sellerId/products/new'import { Route as ProductsProductIdRouteImport } from './routes/_authenticated/$sellerId/products/$productId'+import { Route as PayoutsPayoutIdRouteImport } from './routes/_authenticated/$sellerId/payouts/$payoutId'import { Route as OrdersOrderIdRouteImport } from './routes/_authenticated/$sellerId/orders/$orderId'const resetPasswordRoute = resetPasswordRouteImport.update({@@ -97,11 +100,21 @@ const ProductsIndexRoute = ProductsIndexRouteImport.update({path: '/products/',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const PayoutsIndexRoute = PayoutsIndexRouteImport.update({+ id: '/payouts/',+ path: '/payouts/',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const OrdersIndexRoute = OrdersIndexRouteImport.update({id: '/orders/',path: '/orders/',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const EarningsIndexRoute = EarningsIndexRouteImport.update({+ id: '/earnings/',+ path: '/earnings/',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const SettingsTeamRoute = SettingsTeamRouteImport.update({id: '/team',path: '/team',@@ -137,6 +150,11 @@ const ProductsProductIdRoute = ProductsProductIdRouteImport.update({path: '/products/$productId',getParentRoute: () => authenticatedSellerIdRoute,} as any)+const PayoutsPayoutIdRoute = PayoutsPayoutIdRouteImport.update({+ id: '/payouts/$payoutId',+ path: '/payouts/$payoutId',+ getParentRoute: () => authenticatedSellerIdRoute,+} as any)const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({id: '/orders/$orderId',path: '/orders/$orderId',@@ -155,6 +173,7 @@ export interface FileRoutesByFullPath {'/$sellerId/settings': typeof SettingsRouteWithChildren'/$sellerId/': typeof IndexRoute'/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/$sellerId/products/$productId': typeof ProductsProductIdRoute'/$sellerId/products/new': typeof ProductsNewRoute'/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -162,7 +181,9 @@ export interface FileRoutesByFullPath {'/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$sellerId/settings/team': typeof SettingsTeamRoute+ '/$sellerId/earnings/': typeof EarningsIndexRoute'/$sellerId/orders/': typeof OrdersIndexRoute+ '/$sellerId/payouts/': typeof PayoutsIndexRoute'/$sellerId/products/': typeof ProductsIndexRoute'/$sellerId/settings/': typeof SettingsIndexRoute}@@ -176,6 +197,7 @@ export interface FileRoutesByTo {'/$sellerId/profile': typeof ProfileRoute'/$sellerId': typeof IndexRoute'/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/$sellerId/products/$productId': typeof ProductsProductIdRoute'/$sellerId/products/new': typeof ProductsNewRoute'/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -183,7 +205,9 @@ export interface FileRoutesByTo {'/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$sellerId/settings/team': typeof SettingsTeamRoute+ '/$sellerId/earnings': typeof EarningsIndexRoute'/$sellerId/orders': typeof OrdersIndexRoute+ '/$sellerId/payouts': typeof PayoutsIndexRoute'/$sellerId/products': typeof ProductsIndexRoute'/$sellerId/settings': typeof SettingsIndexRoute}@@ -201,6 +225,7 @@ export interface FileRoutesById {'/_authenticated/$sellerId/settings': typeof SettingsRouteWithChildren'/_authenticated/$sellerId/': typeof IndexRoute'/_authenticated/$sellerId/orders/$orderId': typeof OrdersOrderIdRoute+ '/_authenticated/$sellerId/payouts/$payoutId': typeof PayoutsPayoutIdRoute'/_authenticated/$sellerId/products/$productId': typeof ProductsProductIdRoute'/_authenticated/$sellerId/products/new': typeof ProductsNewRoute'/_authenticated/$sellerId/settings/delivery-methods': typeof SettingsDeliveryMethodsRoute@@ -208,7 +233,9 @@ export interface FileRoutesById {'/_authenticated/$sellerId/settings/policies': typeof SettingsPoliciesRoute'/_authenticated/$sellerId/settings/stock-locations': typeof SettingsStockLocationsRoute'/_authenticated/$sellerId/settings/team': typeof SettingsTeamRoute+ '/_authenticated/$sellerId/earnings/': typeof EarningsIndexRoute'/_authenticated/$sellerId/orders/': typeof OrdersIndexRoute+ '/_authenticated/$sellerId/payouts/': typeof PayoutsIndexRoute'/_authenticated/$sellerId/products/': typeof ProductsIndexRoute'/_authenticated/$sellerId/settings/': typeof SettingsIndexRoute}@@ -226,6 +253,7 @@ export interface FileRouteTypes {| '/$sellerId/settings'| '/$sellerId/'| '/$sellerId/orders/$orderId'+ | '/$sellerId/payouts/$payoutId'| '/$sellerId/products/$productId'| '/$sellerId/products/new'| '/$sellerId/settings/delivery-methods'@@ -233,7 +261,9 @@ export interface FileRouteTypes {| '/$sellerId/settings/policies'| '/$sellerId/settings/stock-locations'| '/$sellerId/settings/team'+ | '/$sellerId/earnings/'| '/$sellerId/orders/'+ | '/$sellerId/payouts/'| '/$sellerId/products/'| '/$sellerId/settings/'fileRoutesByTo: FileRoutesByTo@@ -247,6 +277,7 @@ export interface FileRouteTypes {| '/$sellerId/profile'| '/$sellerId'| '/$sellerId/orders/$orderId'+ | '/$sellerId/payouts/$payoutId'| '/$sellerId/products/$productId'| '/$sellerId/products/new'| '/$sellerId/settings/delivery-methods'@@ -254,7 +285,9 @@ export interface FileRouteTypes {| '/$sellerId/settings/policies'| '/$sellerId/settings/stock-locations'| '/$sellerId/settings/team'+ | '/$sellerId/earnings'| '/$sellerId/orders'+ | '/$sellerId/payouts'| '/$sellerId/products'| '/$sellerId/settings'id:@@ -271,6 +304,7 @@ export interface FileRouteTypes {| '/_authenticated/$sellerId/settings'| '/_authenticated/$sellerId/'| '/_authenticated/$sellerId/orders/$orderId'+ | '/_authenticated/$sellerId/payouts/$payoutId'| '/_authenticated/$sellerId/products/$productId'| '/_authenticated/$sellerId/products/new'| '/_authenticated/$sellerId/settings/delivery-methods'@@ -278,7 +312,9 @@ export interface FileRouteTypes {| '/_authenticated/$sellerId/settings/policies'| '/_authenticated/$sellerId/settings/stock-locations'| '/_authenticated/$sellerId/settings/team'+ | '/_authenticated/$sellerId/earnings/'| '/_authenticated/$sellerId/orders/'+ | '/_authenticated/$sellerId/payouts/'| '/_authenticated/$sellerId/products/'| '/_authenticated/$sellerId/settings/'fileRoutesById: FileRoutesById@@ -384,6 +420,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsIndexRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/payouts/': {+ id: '/_authenticated/$sellerId/payouts/'+ path: '/payouts'+ fullPath: '/$sellerId/payouts/'+ preLoaderRoute: typeof PayoutsIndexRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/orders/': {id: '/_authenticated/$sellerId/orders/'path: '/orders'@@ -391,6 +434,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof OrdersIndexRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/earnings/': {+ id: '/_authenticated/$sellerId/earnings/'+ path: '/earnings'+ fullPath: '/$sellerId/earnings/'+ preLoaderRoute: typeof EarningsIndexRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/settings/team': {id: '/_authenticated/$sellerId/settings/team'path: '/team'@@ -440,6 +490,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsProductIdRouteImportparentRoute: typeof authenticatedSellerIdRoute}+ '/_authenticated/$sellerId/payouts/$payoutId': {+ id: '/_authenticated/$sellerId/payouts/$payoutId'+ path: '/payouts/$payoutId'+ fullPath: '/$sellerId/payouts/$payoutId'+ preLoaderRoute: typeof PayoutsPayoutIdRouteImport+ parentRoute: typeof authenticatedSellerIdRoute+ }'/_authenticated/$sellerId/orders/$orderId': {id: '/_authenticated/$sellerId/orders/$orderId'path: '/orders/$orderId'@@ -478,9 +535,12 @@ interface authenticatedSellerIdRouteChildren {SettingsRoute: typeof SettingsRouteWithChildrenIndexRoute: typeof IndexRouteOrdersOrderIdRoute: typeof OrdersOrderIdRoute+ PayoutsPayoutIdRoute: typeof PayoutsPayoutIdRouteProductsProductIdRoute: typeof ProductsProductIdRouteProductsNewRoute: typeof ProductsNewRoute+ EarningsIndexRoute: typeof EarningsIndexRouteOrdersIndexRoute: typeof OrdersIndexRoute+ PayoutsIndexRoute: typeof PayoutsIndexRouteProductsIndexRoute: typeof ProductsIndexRoute}@@ -490,9 +550,12 @@ const authenticatedSellerIdRouteChildren: authenticatedSellerIdRouteChildren = {SettingsRoute: SettingsRouteWithChildren,IndexRoute: IndexRoute,OrdersOrderIdRoute: OrdersOrderIdRoute,+ PayoutsPayoutIdRoute: PayoutsPayoutIdRoute,ProductsProductIdRoute: ProductsProductIdRoute,ProductsNewRoute: ProductsNewRoute,+ EarningsIndexRoute: EarningsIndexRoute,OrdersIndexRoute: OrdersIndexRoute,+ PayoutsIndexRoute: PayoutsIndexRoute,ProductsIndexRoute: ProductsIndexRoute,}diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsxnew file mode 100644index 0000000000..796e4fd8b0--- /dev/null+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx@@ -0,0 +1,14 @@+import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core'+import { createFileRoute } from '@tanstack/react-router'+import { EarningsPage } from '../../../../pages/earnings'++export const Route = createFileRoute('/_authenticated/$sellerId/earnings/')({+ validateSearch: resourceSearchSchema,+ component: EarningsRoute,+})++function EarningsRoute() {+ const search = Route.useSearch() as ResourceSearch++ return <EarningsPage search={search} />+}diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsxnew file mode 100644index 0000000000..2f0d773eec--- /dev/null+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx@@ -0,0 +1,6 @@+import { createFileRoute } from '@tanstack/react-router'+import { PayoutPage } from '../../../../pages/payout'++export const Route = createFileRoute('/_authenticated/$sellerId/payouts/$payoutId')({+ component: PayoutPage,+})diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index.tsxnew file mode 100644index 0000000000..ea60452376--- /dev/null+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index.tsx@@ -0,0 +1,14 @@+import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core'+import { createFileRoute } from '@tanstack/react-router'+import { PayoutsPage } from '../../../../pages/payouts'++export const Route = createFileRoute('/_authenticated/$sellerId/payouts/')({+ validateSearch: resourceSearchSchema,+ component: PayoutsRoute,+})++function PayoutsRoute() {+ const search = Route.useSearch() as ResourceSearch++ return <PayoutsPage search={search} />+}diff --git a/packages/seller-dashboard/src/tables/payouts.tsx b/packages/seller-dashboard/src/tables/payouts.tsxnew file mode 100644index 0000000000..3d3c8394f4--- /dev/null+++ b/packages/seller-dashboard/src/tables/payouts.tsx@@ -0,0 +1,73 @@+import { defineTable } 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'++const STATUSES = ['pending', 'processing', 'completed', 'failed', 'unresolved'] as const++defineTable<Payout>('seller-payouts', {+ title: i18n.t('payouts.title'),+ searchParam: 'reference_cont',+ 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={new Date(payout.created_at).toLocaleDateString(i18n.language)}+ />+ ),+ },+ {+ key: 'status',+ label: i18n.t('payouts.columns.status'),+ sortable: true,+ filterable: true,+ filterType: 'enum',+ filterOptions: 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) => payout.display_amount,+ },+ ],+})diff --git a/packages/seller-dashboard/src/tables/transfers.tsx b/packages/seller-dashboard/src/tables/transfers.tsxnew file mode 100644index 0000000000..be3164e5c3--- /dev/null+++ b/packages/seller-dashboard/src/tables/transfers.tsx@@ -0,0 +1,104 @@+import { defineTable, useTenantId } from '@spree/dashboard-core'+import { StatusBadge } from '@spree/dashboard-ui'+import { BanknoteIcon } from '@spree/dashboard-ui/icons'+import type { Transfer } from '@spree/seller-sdk'+import { Link } from '@tanstack/react-router'+import i18n from 'i18next'++/**+ * The sale behind an earning — what a seller checking a figure wants next.+ *+ * Its own component because a table definition is module-level and holds no+ * router context, while the link needs the seller whose panel this is. That+ * is what `useTenantId` answers, and a cell is rendered inside React like any+ * other component.+ */+function OrderCell({ transfer }: { transfer: Transfer }) {+ const sellerId = useTenantId()++ if (!transfer.order_id) return <>—</>++ return (+ <Link+ to="/$sellerId/orders/$orderId"+ params={{ sellerId, orderId: transfer.order_id }}+ className="no-underline"+ >+ {transfer.order_number ?? transfer.order_id}+ </Link>+ )+}++const STATUSES = ['pending', 'processing', 'completed', 'failed', 'unresolved'] as const+const KINDS = ['earning', 'refund_reversal'] as const++defineTable<Transfer>('seller-transfers', {+ title: i18n.t('earnings.transfers.title'),+ // Without this the toolbar sends `name_cont`, which the ledger does not+ // whitelist — Ransack drops an unknown condition, so the box would look+ // like it worked and return everything.+ searchParam: 'reference_cont',+ searchPlaceholder: i18n.t('earnings.search_placeholder'),+ defaultSort: { field: 'created_at', direction: 'desc' },+ emptyIcon: <BanknoteIcon className="size-8 text-muted-foreground" />,+ emptyMessage: i18n.t('earnings.transfers.empty'),+ columns: [+ {+ key: 'created_at',+ label: i18n.t('earnings.columns.date'),+ sortable: true,+ filterable: true,+ filterType: 'date',+ quickFilter: true,+ default: true,+ render: (transfer) => new Date(transfer.created_at).toLocaleDateString(i18n.language),+ },+ {+ key: 'order_number',+ label: i18n.t('earnings.columns.order'),+ default: true,+ render: (transfer) => <OrderCell transfer={transfer} />,+ },+ {+ key: 'kind',+ label: i18n.t('earnings.columns.kind'),+ filterable: true,+ filterType: 'enum',+ filterOptions: KINDS.map((kind) => ({+ value: kind,+ label: i18n.t(`earnings.kinds.${kind}`),+ })),+ quickFilter: true,+ default: true,+ render: (transfer) =>+ i18n.t(`earnings.kinds.${transfer.kind}`, { defaultValue: transfer.kind }),+ },+ {+ key: 'status',+ label: i18n.t('earnings.columns.status'),+ sortable: true,+ filterable: true,+ filterType: 'enum',+ filterOptions: STATUSES.map((status) => ({+ value: status,+ label: i18n.t(`earnings.statuses.${status}`),+ })),+ quickFilter: true,+ default: true,+ render: (transfer) => (+ <StatusBadge+ status={transfer.status}+ label={i18n.t(`earnings.statuses.${transfer.status}`, { defaultValue: transfer.status })}+ />+ ),+ },+ {+ key: 'amount',+ label: i18n.t('earnings.columns.amount'),+ sortable: true,+ default: true,+ className: 'text-right tabular-nums',+ render: (transfer) => transfer.display_amount,+ },+ ],+})