mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
Sort project items alphabetically with rejected last
This commit is contained in:
@@ -45,10 +45,21 @@ export function ProjectItemsSection({
|
|||||||
const [showActiveOnly, setShowActiveOnly] = useState(false);
|
const [showActiveOnly, setShowActiveOnly] = useState(false);
|
||||||
|
|
||||||
const displayItems = useMemo(() => {
|
const displayItems = useMemo(() => {
|
||||||
if (!showActiveOnly) {
|
const filtered = showActiveOnly
|
||||||
return items;
|
? items.filter((item) => item.status === 'active')
|
||||||
}
|
: items;
|
||||||
return items.filter((item) => item.status === 'active');
|
|
||||||
|
const createDisplayName = (item: Item) =>
|
||||||
|
item.manufacturer ? `${item.manufacturer} ${item.model}` : item.model;
|
||||||
|
|
||||||
|
return [...filtered].sort((first, second) => {
|
||||||
|
if (first.status !== second.status) {
|
||||||
|
return first.status === 'active' ? -1 : 1;
|
||||||
|
}
|
||||||
|
return createDisplayName(first).localeCompare(createDisplayName(second), undefined, {
|
||||||
|
sensitivity: 'base'
|
||||||
|
});
|
||||||
|
});
|
||||||
}, [items, showActiveOnly]);
|
}, [items, showActiveOnly]);
|
||||||
|
|
||||||
const mismatchedAttributes = useMemo(() => {
|
const mismatchedAttributes = useMemo(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user