feat(stock-orders): show SKU in line table on stock-order detail

Adds a 'SKU' column between Description and Ordered in the lines
table on /stock-orders/[id]. The column reads from
line.expand.stock_item.sku (the relation was already accessible via
the type, but the page was not expanding it on the fetch).

Falls back to an em-dash when expand is missing (e.g. an item whose
stock_item was deleted) so the row never renders an empty cell.

Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
SJCoetz 2026-07-31 14:20:17 +02:00
parent e3295e3c13
commit 2cb6491654

View file

@ -144,6 +144,10 @@ export default function StockOrderDetailPage({
.getFullList<StockPurchaseItem>({
filter: `purchase = "${id}"`,
sort: "created",
// Expand the related stock_item so the row can show the
// SKU next to the description. The relation is a string
// ID otherwise; the page only reads `stock_item.sku`.
expand: "stock_item",
}),
]);
setPurchase(purchaseRes);
@ -540,6 +544,7 @@ export default function StockOrderDetailPage({
<TableHeader>
<TableRow>
<TableHead>Description</TableHead>
<TableHead>SKU</TableHead>
<TableHead className="text-right">Ordered</TableHead>
<TableHead className="text-right">Cost / unit</TableHead>
<TableHead className="text-right">Received</TableHead>
@ -550,7 +555,7 @@ export default function StockOrderDetailPage({
{items.length === 0 ? (
<TableRow>
<TableCell
colSpan={5}
colSpan={6}
className="text-center text-muted-foreground py-8"
>
No lines on this stock order.
@ -573,6 +578,9 @@ export default function StockOrderDetailPage({
</div>
)}
</TableCell>
<TableCell className="font-mono text-xs text-muted-foreground">
{line.expand?.stock_item?.sku ?? "—"}
</TableCell>
<TableCell className="text-right tabular-nums">
{ordered}
</TableCell>