You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add customer sorting: custom order, A-Z, Z-A, most used (#1)
Closes #1. The list could only ever show insertion order.
Four modes, chosen from a control next to the search box and remembered between
launches:
- Custom order — the stored order, now rearrangeable by dragging a card.
- Name A-Z / Z-A — system locale collation, so Nordic users get æ/ø/å in the
right place, and numeric so "Customer 2" precedes "Customer 10".
- Most used — by how often the customer's portals have been opened, breaking ties
on most recently opened and then name so the order is stable.
Sorting is a view concern and never rewrites the stored order, so switching to
A-Z and back leaves a hand-arranged list intact. Dragging is only offered in
custom mode with no active search, since reordering a sorted or filtered list has
no meaningful result — the list says so when a search hides it.
"Most used" needs usage data, so each customer now carries openCount and
lastOpenedAt, incremented locally when a portal opens. Counted on your machine
only; nothing leaves it, and the counters survive an export/import round-trip
rather than resetting everyone's history.
One bug found while testing the drag path: the dragged id was React state, so
dragover and drop read a stale value when they fired in the same tick as
dragstart. Moved it to a ref, with the dataTransfer payload as a fallback.
18 new tests cover the sort modes, the reorder helper, locale and numeric
ordering, tie-breaking, non-mutation, and counter normalisation on import.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>