chore: use toggle order

This commit is contained in:
Scott Wilson
2024-11-26 17:26:49 -08:00
parent 4f4b5be8ea
commit cf5f49d14e
2 changed files with 16 additions and 8 deletions
+5 -1
View File
@@ -33,6 +33,10 @@ export const usePagination = <T extends string>(
search, search,
setSearch, setSearch,
orderBy, orderBy,
setOrderBy setOrderBy,
toggleOrderDirection: () =>
setOrderDirection((prev) =>
prev === OrderByDirection.DESC ? OrderByDirection.ASC : OrderByDirection.DESC
)
}; };
}; };
+11 -7
View File
@@ -514,8 +514,16 @@ const OrganizationPage = () => {
const isWorkspaceEmpty = !isProjectViewLoading && orgWorkspaces?.length === 0; const isWorkspaceEmpty = !isProjectViewLoading && orgWorkspaces?.length === 0;
const { setPage, perPage, setPerPage, page, offset, limit, setOrderDirection, orderDirection } = const {
usePagination(ProjectOrderBy.Name, { initPerPage: 24 }); setPage,
perPage,
setPerPage,
page,
offset,
limit,
toggleOrderDirection,
orderDirection
} = usePagination(ProjectOrderBy.Name, { initPerPage: 24 });
const filteredWorkspaces = useMemo( const filteredWorkspaces = useMemo(
() => () =>
@@ -805,11 +813,7 @@ const OrganizationPage = () => {
variant="plain" variant="plain"
size="xs" size="xs"
colorSchema="secondary" colorSchema="secondary"
onClick={() => onClick={toggleOrderDirection}
setOrderDirection((prev) =>
prev === OrderByDirection.ASC ? OrderByDirection.DESC : OrderByDirection.ASC
)
}
> >
<FontAwesomeIcon <FontAwesomeIcon
icon={orderDirection === OrderByDirection.ASC ? faArrowDownAZ : faArrowUpZA} icon={orderDirection === OrderByDirection.ASC ? faArrowDownAZ : faArrowUpZA}