import type { SWRConfiguration, SWRResponse } from "swr"; import useSWR from "swr"; import client from "../../client"; import type { GetProjectsQueryParams, GetProjectsQueryResponse, } from "../models/GetProjects"; export function getProjectsQueryOptions< TData = GetProjectsQueryResponse, TError = unknown, >( params?: GetProjectsQueryParams, options: Partial[0]> = {} ): SWRConfiguration { return { fetcher: () => { return client({ method: "get", url: `/projects`, params, ...options, }); }, }; } /** * @description Retrieve an array of carbon projects filtered by desired query parameters * @summary List projects * @link /projects */ export function useGetProjects< TData = GetProjectsQueryResponse, TError = unknown, >( params?: GetProjectsQueryParams, options?: { query?: SWRConfiguration; client?: Partial>[0]>; } ): SWRResponse { const { query: queryOptions, client: clientOptions = {} } = options ?? {}; const query = useSWR(`/projects`, { ...getProjectsQueryOptions(params, clientOptions), ...queryOptions, }); return query; }