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);