Campaign drag reorder: fix sort in fetchDetails path

fetchDetails (db active path) sorted by createdAt, ignored order field.
Drag persisted but UI didn't re-sort. Now both paths sort by order
(fallback createdAt).
This commit is contained in:
david raistrick
2026-07-07 15:37:04 -04:00
parent 1078062b53
commit 9dbbb88730
+5 -1
View File
@@ -2377,8 +2377,12 @@ function AdminView({ userId }) {
})
);
// newest first by createdAt (fallback to name for stable order).
// sort by order field (fallback createdAt)
detailedCampaigns.sort((a, b) => {
const ao = a.order ?? null, bo = b.order ?? null;
if (ao !== null && bo !== null) return ao - bo;
if (ao !== null) return -1;
if (bo !== null) return 1;
const at = a.createdAt || 0;
const bt = b.createdAt || 0;
if (at === bt) return (a.name || '').localeCompare(b.name || '');