sorting changes url as url param

This commit is contained in:
DaKheera47 2026-01-20 11:32:25 +00:00
parent da30b65fcb
commit 7f99db7873

View File

@ -80,14 +80,18 @@ export const OrchestratorPage: React.FC = () => {
const sort = useMemo((): JobSort => {
const s = searchParams.get("sort");
if (!s) return DEFAULT_SORT;
const [key, direction] = s.split(":");
const [key, direction] = s.split("-");
return { key: key as any, direction: direction as any };
}, [searchParams]);
const setSort = (newSort: JobSort) => {
setSearchParams(
(prev) => {
prev.set("sort", `${newSort.key}:${newSort.direction}`);
if (newSort.key === DEFAULT_SORT.key && newSort.direction === DEFAULT_SORT.direction) {
prev.delete("sort");
} else {
prev.set("sort", `${newSort.key}-${newSort.direction}`);
}
return prev;
},
{ replace: true },