feat(web): sort accounts by created_at ascending (earliest first)

Earlier accounts were ordered by label, so the list reshuffled every
time an account was renamed. Switch to created_at ASC + id ASC as a
deterministic tiebreaker. Earliest-added accounts now stay on top
where the operator added them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yiekheng 2026-05-10 21:19:01 +08:00
parent 7df3ef9c31
commit f566e4683a

View File

@ -63,9 +63,12 @@ export async function listAccounts(operatorId: string) {
// exposes Pair / Re-pair / Delete actions accordingly. Hiding rows // exposes Pair / Re-pair / Delete actions accordingly. Hiding rows
// by status produced phantom "I created an account but it's gone" // by status produced phantom "I created an account but it's gone"
// bug reports. // bug reports.
// Earliest-added on top, newest at the bottom. Stable across renames
// (a label edit shouldn't reorder the list and confuse muscle memory)
// and matches how other admin tools order accounts that grow over time.
return db.query.whatsappAccounts.findMany({ return db.query.whatsappAccounts.findMany({
where: (a, { eq }) => eq(a.operatorId, operatorId), where: (a, { eq }) => eq(a.operatorId, operatorId),
orderBy: (a, { asc }) => [asc(a.label)], orderBy: (a, { asc }) => [asc(a.createdAt), asc(a.id)],
}); });
} }