import * as React from "react" import axios from "axios" import { useQuery } from "@tanstack/react-query" import type { Coach } from "../types/Coach" import { Container } from "../components/Container" import { FadeIn, FadeInStagger } from "../components/FadeIn" import { FallbackMessage } from "../components/FallbackMessage" import { FilterModal } from "../components/FilterModal" import { FilterScroll } from "../components/FilterScroll" import { Loading } from "../components/Loading" import { SearchResult } from "../components/SearchResult" import { defaultSearchParams } from "../types/SearchParams" function SearchResults() { const { isLoading, isError, data } = useQuery({ queryKey: ["coaches"], queryFn: async () => { const response = await axios.get<{ data: Coach[] }>("/api/coaches/") return response.data.data }, }) if (isLoading) { return } if (isError) { return ( ) } return ( {data?.map((coach, index) => ( ))} ) } export function Search() { const [searchParams, setSearchParams] = React.useState(defaultSearchParams) const [modalOpen, setModalOpen] = React.useState(false) return ( setModalOpen(true)} /> setModalOpen(false)} onSubmit={(q) => { setSearchParams(q) setModalOpen(false) }} /> ) }