import { client } from "@/api/AxiosClient"; import { StepApiResponse } from "@/api/types"; import { cn } from "@/util/utils"; import { useQuery } from "@tanstack/react-query"; import { useParams, useSearchParams } from "react-router-dom"; import { PAGE_SIZE } from "../constants"; type Props = { activeIndex: number; onActiveIndexChange: (index: number) => void; }; function StepNavigation({ activeIndex, onActiveIndexChange }: Props) { const { taskId } = useParams(); const [searchParams] = useSearchParams(); const page = searchParams.get("page") ? Number(searchParams.get("page")) : 1; const { data: steps, isFetching, isError, error, } = useQuery>({ queryKey: ["task", taskId, "steps", page], queryFn: async () => { return client .get(`/tasks/${taskId}/steps`, { params: { page, page_size: PAGE_SIZE, }, }) .then((response) => response.data); }, }); if (isFetching) { return
Loading...
; } if (isError) { return
Error: {error?.message}
; } if (!steps) { return
No steps found
; } return ( ); } export { StepNavigation };