App and sorting updates

This commit is contained in:
Sean Edmunds
2025-04-01 13:59:18 -05:00
parent b741903649
commit c36ca07893
10 changed files with 390 additions and 109 deletions

View File

@@ -12,7 +12,7 @@ function Links({ contentType }: any) {
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
endpoint: 'api/categories',
});
const { isMobile } = useCommonHooks();
const { isMobile, bookmarkSort } = useCommonHooks();
const [bookmarkData, setBookmarkData] = useState<Bookmark[]>([]);
const [groups, setGroups] = useState<BookmarkGroup[]>([]);
@@ -28,12 +28,23 @@ function Links({ contentType }: any) {
return category;
});
setGroups(
groupList.sort((a: BookmarkGroup, b: BookmarkGroup) =>
a.categoryIndex > b.categoryIndex ? 1 : -1,
),
groupList.sort((a: any, b: any) => {
switch (bookmarkSort) {
case 'A>Z':
return a.categoryName > b.categoryName ? 1 : -1;
case 'Z>A':
return a.categoryName < b.categoryName ? 1 : -1;
case 'Newest':
return a.id < b.id ? 1 : -1;
case 'Oldest':
return a.id > b.id ? 1 : -1;
case 'Custom':
return a.index > b.index ? 1 : -1;
}
}),
);
}
}, [groupData, groupsIsFetched]);
}, [groupData, groupsIsFetched, bookmarkSort]);
return (
<>
@@ -55,11 +66,14 @@ function Links({ contentType }: any) {
gridTemplateRows: 'auto',
}}
>
{groups.map((category: BookmarkGroup) => {
if (
contentType.includes(category.filterName) ||
contentType.includes('All')
) {
{groups
?.filter(
(category: BookmarkGroup) =>
contentType.includes(category.filterName) ||
contentType.includes('All'),
)
.map((category: BookmarkGroup) => {
return (
<LinkGroups
key={category.categoryName}
@@ -70,8 +84,7 @@ function Links({ contentType }: any) {
)}
/>
);
}
})}
})}
</Stack>
</Stack>
)}