import { useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import {
    getClientsOptions,
    getClientsQueryKey,
} from "@/lib/client/@tanstack/react-query.gen";

const useClientsList = () => {
    const { data, refetch } = useQuery(getClientsOptions());
    const clients = useMemo(() => data?.items ?? [], [data]);

    const queryKey = getClientsQueryKey();

    return { clients, refetch, queryKey };
};

export default useClientsList;
