Revert "Preserve pick list item ordering by creation time"

This commit is contained in:
beatz174-bit
2025-11-24 15:58:09 +10:00
committed by GitHub
parent 60a2ab8ec3
commit 772c7993bf
+13 -8
View File
@@ -78,20 +78,25 @@ export const ActivePickListScreen = () => {
const sortedItems = useMemo(() => {
return [...itemsVisibleByStatus].sort((a, b) => {
const timeA = a.created_at ?? 0;
const timeB = b.created_at ?? 0;
if (timeA !== timeB) {
return timeA - timeB;
}
const productA = productMap.get(a.product_id);
const productB = productMap.get(b.product_id);
const nameA = productA?.name.trim().toLowerCase() ?? '';
const nameB = productB?.name.trim().toLowerCase() ?? '';
return nameA.localeCompare(nameB, undefined, { sensitivity: 'base' });
const nameComparison = nameA.localeCompare(nameB, undefined, { sensitivity: 'base' });
if (nameComparison !== 0) {
return nameComparison;
}
if (a.is_carton !== b.is_carton) {
return a.is_carton ? 1 : -1;
}
const timeA = a.updated_at ?? a.created_at;
const timeB = b.updated_at ?? b.created_at;
return timeA - timeB;
});
}, [itemsVisibleByStatus, productMap]);