From 5ce3ef1000030ad5b8322c2b1ad1193f5a8f1de1 Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Fri, 10 Jul 2026 00:48:23 +0200 Subject: [PATCH] fix(collection-map): clear assigned_at on unassign so item returns to pool --- src/app/api/v1/collection-map/items/[id]/assign/route.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/api/v1/collection-map/items/[id]/assign/route.ts b/src/app/api/v1/collection-map/items/[id]/assign/route.ts index 294a592..621de50 100644 --- a/src/app/api/v1/collection-map/items/[id]/assign/route.ts +++ b/src/app/api/v1/collection-map/items/[id]/assign/route.ts @@ -97,6 +97,15 @@ export async function PATCH( patch.notes = readyNotes; } } + // Returning an item to the pool (no driver being assigned) also + // clears the date the operator originally assigned. Without this, + // the item keeps its old `assigned_at` and the collection map's + // date filter (which matches by string compare on `assigned_at`) + // may still surface it under the wrong day, or hide it entirely + // on the un-dated fallback. + if (!isAssigning) { + patch.assigned_at = ""; + } const pb = await getAdminPocketBase(); const current = await pb.collection(getOrderItemsCollectionName()).getOne(id).catch(() => null);