26 lines
625 B
TypeScript
26 lines
625 B
TypeScript
import { useMemo } from "react";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import {
|
|
getClientsOptions,
|
|
getClientsQueryKey,
|
|
} from "@/lib/client/@tanstack/react-query.gen";
|
|
|
|
type Props = {
|
|
includeDeleted?: boolean;
|
|
};
|
|
|
|
const useClientsList = (
|
|
{ includeDeleted = false }: Props = { includeDeleted: false }
|
|
) => {
|
|
const { data, refetch } = useQuery(
|
|
getClientsOptions({ query: { includeDeleted } })
|
|
);
|
|
const clients = useMemo(() => data?.items ?? [], [data]);
|
|
|
|
const queryKey = getClientsQueryKey();
|
|
|
|
return { clients, refetch, queryKey };
|
|
};
|
|
|
|
export default useClientsList;
|