feat: attribute selects and options editors

This commit is contained in:
2025-11-04 12:19:44 +04:00
parent 311210394f
commit 33dd1e1c0f
31 changed files with 1833 additions and 112 deletions

View File

@ -0,0 +1,32 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { AttrSelectSchema } from "@/lib/client";
import {
getAttrSelectsOptions,
getAttrSelectsQueryKey,
} from "@/lib/client/@tanstack/react-query.gen";
const useAttrSelectsList = () => {
const queryClient = useQueryClient();
const { data, refetch } = useQuery(getAttrSelectsOptions());
const queryKey = getAttrSelectsQueryKey();
const setSelects = (selects: AttrSelectSchema[]) => {
queryClient.setQueryData(
queryKey,
(old: { items: AttrSelectSchema[] }) => ({
...old,
items: selects,
})
);
};
return {
selects: data?.items ?? [],
setSelects,
refetch,
queryKey,
};
};
export default useAttrSelectsList;