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
Lay out deliveries the way fulfillments are laid out
Damian Legawiec25423b5625b2
diff --git a/packages/dashboard/src/components/spree/stock-receipts-card.tsx b/packages/dashboard/src/components/spree/stock-receipts-card.tsxindex c9c9b6a287..3da447d85f 100644--- a/packages/dashboard/src/components/spree/stock-receipts-card.tsx+++ b/packages/dashboard/src/components/spree/stock-receipts-card.tsx@@ -1,5 +1,6 @@import type { PaginatedResponse, StockReceipt } from '@spree/admin-sdk'import {+ Badge,Card,CardContent,CardHeader,@@ -12,14 +13,16 @@ import {TableHeader,TableRow,} from '@spree/dashboard-ui'+import { PackageCheckIcon } from '@spree/dashboard-ui/icons'import { useQuery } from '@tanstack/react-query'import { useTranslation } from 'react-i18next'import { VariantLink } from './variant-link'/**- * The deliveries booked against a purchase order or a transfer, newest first,- * each with the lines it counted. The document's running totals say where it- * stands; this says how it got there.+ * The deliveries booked against a purchase order or a transfer, each as a+ * nested card inside one container — the way an order's fulfillments read.+ * The document's running totals say where it stands; this says how it got+ * there.*/export function StockReceiptsCard({queryKey,@@ -33,89 +36,106 @@ export function StockReceiptsCard({const receipts = data?.data ?? []return (- <Card>+ <Card variant="container"><CardHeader><CardTitle>+ <PackageCheckIcon className="size-4" />{t('admin.stock_receipts.title')}- {receipts.length > 0 && (- <span className="ml-2 font-normal text-muted-foreground text-sm">- {receipts.length}- </span>+ {receipts.length > 0 && <Badge variant="outline">{receipts.length}</Badge>}+ </CardTitle>+ </CardHeader>+ {/* A failed request is not an empty list: saying "no deliveries" over an+ error would tell the merchant something false about their stock. */}+ {isError ? (+ <CardContent>+ <p className="py-8 text-center text-destructive">+ {t('admin.stock_receipts.load_failed')}+ </p>+ </CardContent>+ ) : receipts.length === 0 ? (+ <CardContent>+ <p className="py-8 text-center text-muted-foreground">+ {t('admin.stock_receipts.empty')}+ </p>+ </CardContent>+ ) : (+ <CardContent className="flex flex-col gap-4">+ {receipts.map((receipt) => (+ <StockReceiptPanel key={receipt.id} receipt={receipt} />+ ))}+ </CardContent>+ )}+ </Card>+ )+}++/** One delivery: when it came, under which note, and what it counted. */+function StockReceiptPanel({ receipt }: { receipt: StockReceipt }) {+ const { t } = useTranslation()+ const items = receipt.items ?? []++ return (+ <Card variant="nested">+ <CardHeader>+ <CardTitle className="min-w-0 font-normal text-sm">+ <span className="font-medium tabular-nums">{receipt.number}</span>+ <span className="text-muted-foreground text-xs">+ <RelativeTime iso={receipt.received_at} />+ </span>+ {receipt.reference && (+ <span className="truncate text-muted-foreground text-xs">{receipt.reference}</span>)}</CardTitle></CardHeader>- <CardContent className="flex flex-col p-0">- {/* A failed request is not an empty list: saying "no deliveries" over an- error would tell the merchant something false about their stock. */}- {isError ? (- <p className="p-4 text-destructive text-sm">{t('admin.stock_receipts.load_failed')}</p>- ) : receipts.length === 0 ? (- <p className="p-4 text-muted-foreground text-sm">{t('admin.stock_receipts.empty')}</p>- ) : (- receipts.map((receipt) => (- <div key={receipt.id} className="border-t first:border-t-0">- <div className="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 text-sm">- <span className="font-medium tabular-nums">{receipt.number}</span>- <RelativeTime iso={receipt.received_at} className="text-muted-foreground" />- {receipt.reference && (- <span className="text-muted-foreground">{receipt.reference}</span>- )}- <span className="ml-auto text-muted-foreground tabular-nums">- {t('admin.stock_receipts.summary', {- accepted: receipt.quantity_accepted_total,- rejected: receipt.quantity_rejected_total,- })}- </span>- </div>- {receipt.items && receipt.items.length > 0 && (- <Table scrollX>- <TableHeader>- <TableRow>- <TableHead>{t('admin.inventory_lines.columns.variant')}</TableHead>- <TableHead className="text-right">- {t('admin.stock_receipts.columns.accepted')}- </TableHead>- <TableHead className="text-right">- {t('admin.stock_receipts.columns.rejected')}- </TableHead>- <TableHead>{t('admin.stock_receipts.columns.reason')}</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {receipt.items.map((item) => (- <TableRow key={item.id}>- <TableCell>- <VariantLink- name={item.variant_name}- sku={item.variant_sku}- thumbnailUrl={item.thumbnail_url}- />- </TableCell>- <TableCell className="text-right tabular-nums">- {item.quantity_accepted}- </TableCell>- <TableCell className="text-right tabular-nums">- {item.quantity_rejected}- </TableCell>- <TableCell>- {item.rejection_reason- ? t(`admin.stock_receipts.rejection_reasons.${item.rejection_reason}`, {- defaultValue: item.rejection_reason,- })- : '—'}- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- )}- {receipt.notes && (- <p className="px-4 pb-3 text-muted-foreground text-sm">{receipt.notes}</p>- )}- </div>- ))- )}++ <CardContent className="flex items-center justify-between border-b border-border-subtle py-3 text-sm">+ <span className="text-muted-foreground">+ {t('admin.stock_receipts.summary', {+ accepted: receipt.quantity_accepted_total,+ rejected: receipt.quantity_rejected_total,+ })}+ </span>+ {receipt.notes && <span className="truncate text-muted-foreground">{receipt.notes}</span>}</CardContent>++ {items.length > 0 && (+ <Table scrollX roundedBottom>+ <TableHeader>+ <TableRow>+ <TableHead>{t('admin.inventory_lines.columns.variant')}</TableHead>+ <TableHead className="text-right">+ {t('admin.stock_receipts.columns.accepted')}+ </TableHead>+ <TableHead className="text-right">+ {t('admin.stock_receipts.columns.rejected')}+ </TableHead>+ <TableHead>{t('admin.stock_receipts.columns.reason')}</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {items.map((item) => (+ <TableRow key={item.id}>+ <TableCell>+ <VariantLink+ name={item.variant_name}+ sku={item.variant_sku}+ thumbnailUrl={item.thumbnail_url}+ />+ </TableCell>+ <TableCell className="text-right tabular-nums">{item.quantity_accepted}</TableCell>+ <TableCell className="text-right tabular-nums">{item.quantity_rejected}</TableCell>+ <TableCell>+ {item.rejection_reason+ ? t(`admin.stock_receipts.rejection_reasons.${item.rejection_reason}`, {+ defaultValue: item.rejection_reason,+ })+ : '—'}+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ )}</Card>)}