diff --git a/apps/opik-frontend/src/api/datasets/useDatasetItemByName.ts b/apps/opik-frontend/src/api/datasets/useDatasetItemByName.ts index c9f0fdc0f..d4988a742 100644 --- a/apps/opik-frontend/src/api/datasets/useDatasetItemByName.ts +++ b/apps/opik-frontend/src/api/datasets/useDatasetItemByName.ts @@ -1,4 +1,4 @@ -import { useQuery } from "@tanstack/react-query"; +import { QueryFunctionContext, useQuery } from "@tanstack/react-query"; import api, { DATASETS_REST_ENDPOINT, QueryConfig } from "@/api/api"; import { Dataset } from "@/types/datasets"; @@ -6,12 +6,18 @@ type UseDatasetByNameParams = { datasetName: string; }; -const getDatasetByName = async ({ datasetName }: UseDatasetByNameParams) => { +const getDatasetByName = async ( + { signal }: QueryFunctionContext, + { datasetName }: UseDatasetByNameParams, +) => { const response = await api.post( `${DATASETS_REST_ENDPOINT}/retrieve`, { dataset_name: datasetName, }, + { + signal, + }, ); return response.data; @@ -23,7 +29,7 @@ export default function useDatasetItemByName( ) { return useQuery({ queryKey: ["dataset", params], - queryFn: () => getDatasetByName(params), + queryFn: (context) => getDatasetByName(context, params), ...options, }); } diff --git a/apps/opik-frontend/src/api/projects/useProjectByName.ts b/apps/opik-frontend/src/api/projects/useProjectByName.ts index f5926cb64..2a09c63ad 100644 --- a/apps/opik-frontend/src/api/projects/useProjectByName.ts +++ b/apps/opik-frontend/src/api/projects/useProjectByName.ts @@ -6,34 +6,26 @@ type UseProjectByNameParams = { projectName: string; }; -type UseProjectsListResponse = { - content: Project[]; - total: number; -}; - -// @todo: replace it with another request to get a project id only when the be is ready const getProjectByName = async ( { signal }: QueryFunctionContext, { projectName }: UseProjectByNameParams, ) => { - const { data } = await api.get( - PROJECTS_REST_ENDPOINT, + const { data } = await api.post( + `${PROJECTS_REST_ENDPOINT}retrieve`, + { + name: projectName, + }, { signal, - params: { - search: projectName, - page: 1, - size: 10000, - }, }, ); - return data?.content.find((p) => p.name === projectName) || null; + return data; }; export default function useProjectByName( params: UseProjectByNameParams, - options?: QueryConfig, + options?: QueryConfig, ) { return useQuery({ queryKey: ["project", params],