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;