feat: add service type fitler

This commit is contained in:
Nathnael
2026-08-18 11:38:07 +00:00
parent 2f293e4ae4
commit 03b16b4ee8
9 changed files with 103 additions and 4 deletions

View File

@@ -130,6 +130,15 @@ export default function BookingRequestsPage() {
[yardRefs],
);
// Service-type options — same reference-data payload the booking form uses.
const { data: refData } = useQuery(
api.bookings.referenceData.queryOptions({ staleTime: 5 * 60_000 }),
);
const serviceTypeOptions = useMemo(
() => (refData?.service ?? []).map((s) => ({ value: s.id, label: s.name })),
[refData],
);
// Deep links land here pre-filtered (?statuses=A,B&tradeDirection=IMPORT) —
// the header's document-review alarm opens exactly the undecided requests
// it is counting down for. No sync effect needed any more: controls.values
@@ -147,6 +156,7 @@ export default function BookingRequestsPage() {
options: filterOptions(TRADE_DIRECTION_OPTIONS),
},
{ key: "freightType", label: "Freight", type: "enum", multiple: false, options: FREIGHT_TYPE_OPTIONS },
{ key: "serviceTypeId", label: "Service", type: "enum", multiple: false, options: serviceTypeOptions },
{ key: "paymentStatus", label: "Payment", type: "enum", multiple: false, options: PAYMENT_STATUS_OPTIONS, secondary: true },
{
// Wins over the `paymentStatus` filter above — the queue is by
@@ -172,7 +182,7 @@ export default function BookingRequestsPage() {
toParams: dateRangeParams("scheduledFrom", "scheduledTo"),
},
],
[filterOptions, yardOptions],
[filterOptions, yardOptions, serviceTypeOptions],
);
const controls = useFilters(bookingFilterDefs, { defaultSort: "createdAt:DESC", pageSize: 10 });

View File

@@ -115,6 +115,15 @@ export default function ContractRequestsPage() {
[yardRefs],
);
// Service-type options — same reference-data payload the booking form uses.
const { data: refData } = useQuery(
api.bookings.referenceData.queryOptions({ staleTime: 5 * 60_000 }),
);
const serviceTypeOptions = useMemo(
() => (refData?.service ?? []).map((s) => ({ value: s.id, label: s.name })),
[refData],
);
// Static shape only (no facet counts) — this is what useFilters needs to
// parse the URL and build API params. Counts are attached separately below,
// for rendering only, once the summary query (which itself depends on
@@ -143,6 +152,13 @@ export default function ContractRequestsPage() {
multiple: false,
options: FREIGHT_TYPE_OPTIONS,
},
{
key: "serviceTypeId",
label: "Service",
type: "enum",
multiple: false,
options: serviceTypeOptions,
},
{
key: "paymentCurrency",
label: "Currency",
@@ -170,7 +186,7 @@ export default function ContractRequestsPage() {
toParams: ({ v }) => ({ originYardId: v[0], destinationYardId: v[1] }),
},
],
[filterOptions, yardOptions],
[filterOptions, yardOptions, serviceTypeOptions],
);
const controls = useFilters(filterDefs, {