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.

Fixed failed ledger queries reading as empty, and duplicate nav labels

Damian Legawiecf0ee25a35d4b
diff --git a/packages/dashboard/src/components/spree/orders/order-payments-card.tsx b/packages/dashboard/src/components/spree/orders/order-payments-card.tsx
index d74062d4c1..e127d914fa 100644
--- a/packages/dashboard/src/components/spree/orders/order-payments-card.tsx
+++ b/packages/dashboard/src/components/spree/orders/order-payments-card.tsx
@@ -64,7 +64,11 @@ export function PaymentsCard({ order }: { order: Order }) {
// An order from a split checkout has no payments of its own: the customer
// paid once, against the group. Reading `order.payments` there would render
// "no payments" on an order that was paid in full.
- const { data: group, isPending: groupPending } = useOrderGroup(order.order_group_id)
+ const {
+ data: group,
+ isPending: groupPending,
+ isError: groupFailed,
+ } = useOrderGroup(order.order_group_id)
const grouped = !!order.order_group_id
const payments = (grouped ? group?.payments : order.payments) ?? []
// On a grouped order the payments arrive with the group, so until they do
@@ -106,6 +110,15 @@ export function PaymentsCard({ order }: { order: Order }) {
<CardContent>
<Skeleton className="h-24 w-full" />
</CardContent>
+ ) : grouped && groupFailed ? (
+ // Distinct from the empty state below: a request that failed says
+ // nothing about whether this order was paid, and reading "no payments"
+ // off a network error is the misreading this branch exists to prevent.
+ <CardContent>
+ <p className="text-center text-destructive py-8">
+ {t('admin.orders.detail.payments_table.load_error')}
+ </p>
+ </CardContent>
) : payments.length === 0 ? (
<CardContent>
<p className="text-center text-muted-foreground py-8">
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 5ab064c728..df5e824b94 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -2586,7 +2586,7 @@
"reports": "التقارير",
"returns": "المرتجعات",
"seller_payouts": "المدفوعات",
- "seller_transfers": "التحويلات",
+ "seller_transfers": "تحويلات البائعين",
"sellers": "البائعون",
"settings": "الإعدادات",
"transfers": "التحويلات",
@@ -2878,7 +2878,8 @@
"number": "رقم",
"state": "ولاية",
"this_order": "هذا الطلب",
- "shared_help": "دُفعت مرة واحدة لسلة تضم عدة بائعين. هذا الطلب له حصة منها."
+ "shared_help": "دُفعت مرة واحدة لسلة تضم عدة بائعين. هذا الطلب له حصة منها.",
+ "load_error": "تعذر تحميل مدفوعات هذا الطلب."
},
"purchase_order": {
"document": "مستند أمر الشراء",
@@ -5324,7 +5325,8 @@
"covers_other": "يغطي {{count}} ربح",
"covers_empty": "هذه الدفعة لا تغطي أي أرباح.",
"settlement": "الدفعة",
- "period": "الفترة"
+ "period": "الفترة",
+ "covers_error": "تعذر تحميل الأرباح التي تغطيها هذه الدفعة."
},
"order_card": {
"title": "أرباح البائع",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index bd4b1492f7..48e282a185 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -2861,7 +2861,8 @@
"number": "Nummer",
"state": "Status",
"this_order": "Diese Bestellung",
- "shared_help": "Einmal bezahlt für einen Warenkorb mehrerer Verkäufer. Diese Bestellung hat einen Anteil daran."
+ "shared_help": "Einmal bezahlt für einen Warenkorb mehrerer Verkäufer. Diese Bestellung hat einen Anteil daran.",
+ "load_error": "Die Zahlungen für diese Bestellung konnten nicht geladen werden."
},
"purchase_order": {
"document": "Bestelldokument",
@@ -5299,7 +5300,8 @@
"covers_other": "Umfasst {{count}} Einnahmen",
"covers_empty": "Diese Auszahlung umfasst keine Einnahmen.",
"settlement": "Auszahlung",
- "period": "Zeitraum"
+ "period": "Zeitraum",
+ "covers_error": "Die Einnahmen dieser Auszahlung konnten nicht geladen werden."
},
"order_card": {
"title": "Verkäufereinnahmen",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 1ef99cd9a7..4c2e9b7464 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -2568,7 +2568,7 @@
"reports": "Reports",
"returns": "Returns",
"seller_payouts": "Payouts",
- "seller_transfers": "Transfers",
+ "seller_transfers": "Seller transfers",
"sellers": "Sellers",
"settings": "Settings",
"transfers": "Transfers",
@@ -2861,7 +2861,8 @@
"number": "Number",
"state": "State",
"this_order": "This order",
- "shared_help": "Paid once for a basket spanning several sellers. This order has a share of it."
+ "shared_help": "Paid once for a basket spanning several sellers. This order has a share of it.",
+ "load_error": "Could not load the payments for this order."
},
"purchase_order": {
"document": "Purchase order document",
@@ -5299,7 +5300,8 @@
"covers_other": "Covers {{count}} earnings",
"covers_empty": "This payout covers no earnings.",
"settlement": "Payout",
- "period": "Period"
+ "period": "Period",
+ "covers_error": "Could not load the earnings this payout covers."
},
"order_card": {
"title": "Seller earnings",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 2e64e4b0f8..4e8603b3e4 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -2568,7 +2568,7 @@
"reports": "Rapports",
"returns": "Retours",
"seller_payouts": "Versements",
- "seller_transfers": "Transferts",
+ "seller_transfers": "Transferts vendeurs",
"sellers": "Vendeurs",
"settings": "Paramètres",
"transfers": "Transferts",
@@ -2861,7 +2861,8 @@
"number": "Numéro",
"state": "État",
"this_order": "Cette commande",
- "shared_help": "Payé en une fois pour un panier réparti entre plusieurs vendeurs. Cette commande en détient une part."
+ "shared_help": "Payé en une fois pour un panier réparti entre plusieurs vendeurs. Cette commande en détient une part.",
+ "load_error": "Impossible de charger les paiements de cette commande."
},
"purchase_order": {
"document": "Document de bon de commande",
@@ -5299,7 +5300,8 @@
"covers_other": "Couvre {{count}} gains",
"covers_empty": "Ce versement ne couvre aucun gain.",
"settlement": "Versement",
- "period": "Période"
+ "period": "Période",
+ "covers_error": "Impossible de charger les gains couverts par ce versement."
},
"order_card": {
"title": "Gains du vendeur",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 1030da9a86..c48eb715d4 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -2590,7 +2590,7 @@
"reports": "Raporty",
"returns": "Zwroty",
"seller_payouts": "Wypłaty",
- "seller_transfers": "Transfery",
+ "seller_transfers": "Transfery sprzedawców",
"sellers": "Sprzedawcy",
"settings": "Ustawienia",
"transfers": "Transfery",
@@ -2887,7 +2887,8 @@
"number": "Numer",
"state": "Stan",
"this_order": "To zamówienie",
- "shared_help": "Zapłacone raz za koszyk obejmujący kilku sprzedawców. To zamówienie ma w nim udział."
+ "shared_help": "Zapłacone raz za koszyk obejmujący kilku sprzedawców. To zamówienie ma w nim udział.",
+ "load_error": "Nie udało się wczytać płatności tego zamówienia."
},
"purchase_order": {
"document": "Dokument zamówienia zakupu",
@@ -5359,7 +5360,8 @@
"covers_other": "Obejmuje {{count}} zarobków",
"covers_empty": "Ta wypłata nie obejmuje żadnych zarobków.",
"settlement": "Wypłata",
- "period": "Okres"
+ "period": "Okres",
+ "covers_error": "Nie udało się wczytać zarobków objętych tą wypłatą."
},
"order_card": {
"title": "Zarobki sprzedawcy",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index 9d30d9f84e..1a1c65c3c2 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -2851,9 +2851,10 @@
"payments_table": {
"method": "方式",
"number": "编号",
- "state": "州/省",
+ "state": "状态",
"this_order": "本订单",
- "shared_help": "该购物车横跨多个卖家,只支付了一次。本订单占其中一部分。"
+ "shared_help": "该购物车横跨多个卖家,只支付了一次。本订单占其中一部分。",
+ "load_error": "无法加载此订单的付款信息。"
},
"purchase_order": {
"document": "采购订单文件",
@@ -5289,7 +5290,8 @@
"covers_other": "包含 {{count}} 笔收入",
"covers_empty": "此打款不包含任何收入。",
"settlement": "打款",
- "period": "周期"
+ "period": "周期",
+ "covers_error": "无法加载此打款涵盖的收入。"
},
"order_card": {
"title": "卖家收入",
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/sellers/payouts/$payoutId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/sellers/payouts/$payoutId.tsx
index b7f9cb6344..b54efa0ea0 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/sellers/payouts/$payoutId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/sellers/payouts/$payoutId.tsx
@@ -7,6 +7,7 @@ import {
ErrorState,
Pagination,
ResourceLayout,
+ Skeleton,
StatusBadge,
Table,
TableBody,
@@ -46,7 +47,11 @@ function PayoutDetailPage() {
const [page, setPage] = useState(1)
const { data: payout, isLoading, error, refetch } = usePayout(payoutId)
- const { data: transfers } = useSellerTransfers({ payout_id_eq: payoutId }, page)
+ const {
+ data: transfers,
+ isPending: transfersPending,
+ isError: transfersFailed,
+ } = useSellerTransfers({ payout_id_eq: payoutId }, page)
if (isLoading) return <ResourceDetailSkeleton />
if (error || !payout) {
@@ -105,7 +110,17 @@ function PayoutDetailPage() {
</CardTitle>
</CardHeader>
- {rows.length === 0 ? (
+ {/* Only true once the earnings loaded: a pending or failed query
+ says nothing about what this settlement covers. */}
+ {transfersPending ? (
+ <div className="px-6 pb-6">
+ <Skeleton className="h-16 w-full" />
+ </div>
+ ) : transfersFailed ? (
+ <p className="px-6 pb-6 text-sm text-destructive">
+ {t('admin.payouts.detail.covers_error')}
+ </p>
+ ) : rows.length === 0 ? (
<p className="px-6 pb-6 text-sm text-muted-foreground">
{t('admin.payouts.detail.covers_empty')}
</p>
diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.json
index 9da0a2c75a..9e9f913a15 100644
--- a/packages/seller-dashboard/src/locales/en.json
+++ b/packages/seller-dashboard/src/locales/en.json
@@ -258,12 +258,13 @@
},
"earnings": {
"balance": {
- "title": "Balance",
+ "earned": "Earned",
"empty": "Once an order of yours is fulfilled, what it earned shows up here.",
+ "load_error": "Could not load your balance.",
"owed": "Owed to you ({{currency}})",
- "earned": "Earned",
"paid": "Paid out",
- "pending": "On its way"
+ "pending": "On its way",
+ "title": "Balance"
},
"columns": {
"date": "Date",
@@ -554,11 +555,12 @@
"amount": "Amount"
},
"detail": {
+ "covers_empty": "This payout covers no earnings.",
+ "covers_error": "Could not load the earnings this payout covers.",
"covers_one": "Covers {{count}} earning",
"covers_other": "Covers {{count}} earnings",
- "covers_empty": "This payout covers no earnings.",
- "settlement": "Payout",
- "period": "Period"
+ "period": "Period",
+ "settlement": "Payout"
},
"empty": "No payouts yet.",
"not_found": "This payout could not be found.",
diff --git a/packages/seller-dashboard/src/pages/earnings.tsx b/packages/seller-dashboard/src/pages/earnings.tsx
index 17591dd756..b0ddabd547 100644
--- a/packages/seller-dashboard/src/pages/earnings.tsx
+++ b/packages/seller-dashboard/src/pages/earnings.tsx
@@ -1,5 +1,5 @@
import { PageHeader, type ResourceSearch, ResourceTable } from '@spree/dashboard-core'
-import { Skeleton } from '@spree/dashboard-ui'
+import { ErrorState, Skeleton } from '@spree/dashboard-ui'
import type { Transfer } from '@spree/seller-sdk'
import { useTranslation } from 'react-i18next'
import { sellerClient } from '../api-client'
@@ -16,14 +16,18 @@ import '../tables/transfers'
*/
export function EarningsPage({ search }: { search: ResourceSearch }) {
const { t } = useTranslation()
- const { data, isLoading } = useBalances()
+ const { data, isLoading, isError, refetch } = useBalances()
return (
<div className="flex flex-col gap-4">
<PageHeader title={t('earnings.title')} subtitle={t('earnings.subtitle')} />
+ {/* A failed balance request must not fall through to the empty state:
+ "you have earned nothing yet" is the opposite of "we could not ask". */}
{isLoading ? (
<Skeleton className="h-36 w-full" />
+ ) : isError ? (
+ <ErrorState title={t('earnings.balance.load_error')} onRetry={() => void refetch()} />
) : (
<BalanceSummary balances={data?.data ?? []} />
)}
diff --git a/packages/seller-dashboard/src/pages/payout.tsx b/packages/seller-dashboard/src/pages/payout.tsx
index 9d9aab1d43..d96032ebac 100644
--- a/packages/seller-dashboard/src/pages/payout.tsx
+++ b/packages/seller-dashboard/src/pages/payout.tsx
@@ -5,6 +5,7 @@ import {
CardTitle,
Pagination,
ResourceLayout,
+ Skeleton,
StatusBadge,
Table,
TableBody,
@@ -36,7 +37,11 @@ export function PayoutPage() {
const [page, setPage] = useState(1)
const { data: payout, isLoading, isError, refetch } = usePayout(payoutId)
- const { data: transfers } = useTransfers({ payout_id_eq: payoutId }, page)
+ const {
+ data: transfers,
+ isPending: transfersPending,
+ isError: transfersFailed,
+ } = useTransfers({ payout_id_eq: payoutId }, page)
if (isLoading) return <CenteredMessage>{t('common.loading')}</CenteredMessage>
if (isError) return <RetryableError onRetry={() => refetch()} />
@@ -71,7 +76,16 @@ export function PayoutPage() {
</CardTitle>
</CardHeader>
- {rows.length === 0 ? (
+ {/* The empty line is only true once the earnings actually loaded —
+ a pending or failed query says nothing about what this
+ settlement covers. */}
+ {transfersPending ? (
+ <div className="px-6 pb-6">
+ <Skeleton className="h-16 w-full" />
+ </div>
+ ) : transfersFailed ? (
+ <p className="px-6 pb-6 text-sm text-destructive">{t('payouts.detail.covers_error')}</p>
+ ) : rows.length === 0 ? (
<p className="px-6 pb-6 text-sm text-muted-foreground">
{t('payouts.detail.covers_empty')}
</p>
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx
index 796e4fd8b0..7464af1046 100644
--- a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/earnings/index.tsx
@@ -2,6 +2,7 @@ import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core
import { createFileRoute } from '@tanstack/react-router'
import { EarningsPage } from '../../../../pages/earnings'
+/** What this seller has earned: their balance, then the ledger behind it. */
export const Route = createFileRoute('/_authenticated/$sellerId/earnings/')({
validateSearch: resourceSearchSchema,
component: EarningsRoute,
diff --git a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx
index 2f0d773eec..c3bd47ab4a 100644
--- a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/$payoutId.tsx
@@ -1,6 +1,7 @@
import { createFileRoute } from '@tanstack/react-router'
import { PayoutPage } from '../../../../pages/payout'
+/** One settlement, and the earnings it covered. */
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.tsx
index ea60452376..db4ad9f988 100644
--- a/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index.tsx
+++ b/packages/seller-dashboard/src/routes/_authenticated/$sellerId/payouts/index.tsx
@@ -2,6 +2,7 @@ import { type ResourceSearch, resourceSearchSchema } from '@spree/dashboard-core
import { createFileRoute } from '@tanstack/react-router'
import { PayoutsPage } from '../../../../pages/payouts'
+/** Settlements to this seller — what has been sent, and what is owed. */
export const Route = createFileRoute('/_authenticated/$sellerId/payouts/')({
validateSearch: resourceSearchSchema,
component: PayoutsRoute,
diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.ts
index 05356bbf6b..085bab6f12 100644
--- a/packages/seller-sdk/src/seller-client.ts
+++ b/packages/seller-sdk/src/seller-client.ts
@@ -390,6 +390,12 @@ export class SellerClient {
}),
/**
+ * One of this seller's orders.
+ *
+ * Takes `(id, params, options)` like every other expandable `get` in the
+ * Spree SDKs, so the second argument is the query rather than request
+ * options — pass `undefined` for it when only options are wanted.
+ *
* @param params `expand: ['payment_splits']` adds this order's share of
* the payment the buyer made for the whole basket. A basket placed with
* one seller only does not split and has no shares.