fix(collection-map): clear assigned_at on unassign so item returns to pool

This commit is contained in:
SJCoetz 2026-07-10 00:48:23 +02:00
parent 728bab1671
commit 5ce3ef1000

View file

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