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

View File

@ -33,6 +33,10 @@ export const usePagination = <T extends string>(
search,
setSearch,
orderBy,
setOrderBy
setOrderBy,
toggleOrderDirection: () =>
setOrderDirection((prev) =>
prev === OrderByDirection.DESC ? OrderByDirection.ASC : OrderByDirection.DESC
)
};
};

View File

@ -514,8 +514,16 @@ const OrganizationPage = () => {
const isWorkspaceEmpty = !isProjectViewLoading && orgWorkspaces?.length === 0;
const { setPage, perPage, setPerPage, page, offset, limit, setOrderDirection, orderDirection } =
usePagination(ProjectOrderBy.Name, { initPerPage: 24 });
const {
setPage,
perPage,
setPerPage,
page,
offset,
limit,
toggleOrderDirection,
orderDirection
} = usePagination(ProjectOrderBy.Name, { initPerPage: 24 });
const filteredWorkspaces = useMemo(
() =>
@ -805,11 +813,7 @@ const OrganizationPage = () => {
variant="plain"
size="xs"
colorSchema="secondary"
onClick={() =>
setOrderDirection((prev) =>
prev === OrderByDirection.ASC ? OrderByDirection.DESC : OrderByDirection.ASC
)
}
onClick={toggleOrderDirection}
>
<FontAwesomeIcon
icon={orderDirection === OrderByDirection.ASC ? faArrowDownAZ : faArrowUpZA}