fix(empty-return-requests): map queue columns to camelCase

`findAll` selected `r.*` in raw SQL. `dataSource.query` bypasses the entity
mapping, so rows came back under their database names — `container_numbers`,
`submitted_at`, `quoted_total_amount` — while both clients read camelCase.
Every field on the row was undefined; the backoffice queue crashed on
`containerNumbers.join(", ")` and took the page down through the error
boundary.

Alias each column explicitly, the way `plannedReturns()` below it already
does, and cast the two numeric columns with `::float8` — raw SQL skips the
entity's numeric->Number transformer, which would otherwise hand the clients
strings. Type the result as `EmptyReturnRequestRow` so the signature matches
what the projection actually selects rather than claiming absent fields.

Guard the three `containerNumbers.join(...)` call sites too, so one odd row
cannot white-screen the queue again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hager
2026-09-06 19:43:21 +00:00
parent 2b6c78cf71
commit 808af074e2
2 changed files with 57 additions and 9 deletions

View File

@@ -79,7 +79,7 @@ export default function EmptyReturnRequestsPage() {
const controls = useListControls(requests, {
dateKey: "submittedAt",
searchValue: (row) =>
`${row.bookingReference ?? ""} ${row.companyName ?? ""} ${row.containerNumbers.join(" ")}`,
`${row.bookingReference ?? ""} ${row.companyName ?? ""} ${(row.containerNumbers ?? []).join(" ")}`,
});
const invalidate = () => {
@@ -143,7 +143,7 @@ export default function EmptyReturnRequestsPage() {
<Stack gap={2}>
<Badge size="sm">{row.original.containerCount}</Badge>
<Text size="xs" c="dimmed" lineClamp={2}>
{row.original.containerNumbers.join(", ")}
{(row.original.containerNumbers ?? []).join(", ")}
</Text>
</Stack>
),
@@ -386,7 +386,7 @@ function ApproveModal({
Containers coming back
</Text>
<Text size="sm" c="dimmed">
{request.containerNumbers.join(", ")}
{(request.containerNumbers ?? []).join(", ")}
</Text>
</div>