import { useState, useEffect } from "react";
import { useSearchParams } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";
import { search } from "../api";
import VideoCard from "../components/VideoCard";
import ChannelCard from "../components/ChannelCard";
function Badge({ label }) {
return (
{label}
);
}
function Spinner() {
return (
Type something in the search bar above.
;
}
if (isLoading) return
Results for "{q}"
{source === "live" &&
}
{source === "local" &&
}
{source === "mixed" &&
}
{isLiveLoading && (
searching YouTube…
)}
{/* Channels first when they're the primary result */}
{channelsFirst && channels.length > 0 && (
Channels
{channels.map((c) => (
))}
)}
{/* Video results */}
{videos.length > 0 ? (
Videos
{hasMore ? `${visibleCount} of ${videos.length}` : videos.length}
{visibleVideos.map((v) => (
))}
{hasMore && (
)}
) : (
!isLoading && !channels.length && (
No results found for "{q}".
)
)}
{/* Channels after videos when videos dominate */}
{!channelsFirst && channels.length > 0 && (
Channels
{channels.map((c) => (
))}
)}
);
}