mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
UX Improvements
This commit is contained in:
parent
cf0a711c93
commit
7b4367335f
1 changed files with 14 additions and 1 deletions
|
|
@ -360,12 +360,25 @@ export async function renderItem($app, skuInput) {
|
|||
}
|
||||
}
|
||||
|
||||
function rowMinPrice(r) {
|
||||
const p = parsePriceToNumber(r?.price);
|
||||
return p === null ? Infinity : p;
|
||||
}
|
||||
|
||||
const linkRows = Array.from(bestByStore.entries())
|
||||
.map(([store, r]) => ({ store, r }))
|
||||
.sort((A, B) => {
|
||||
// 1) cheapest current price first (Infinity sorts to end)
|
||||
const ap = rowMinPrice(A.r);
|
||||
const bp = rowMinPrice(B.r);
|
||||
if (ap !== bp) return ap - bp;
|
||||
|
||||
// 2) live before removed
|
||||
const ar = Boolean(A.r?.removed) ? 1 : 0;
|
||||
const br = Boolean(B.r?.removed) ? 1 : 0;
|
||||
if (ar !== br) return ar - br; // live first
|
||||
if (ar !== br) return ar - br;
|
||||
|
||||
// 3) stable fallback
|
||||
return A.store.localeCompare(B.store);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue