diff --git a/tubearchivist/www/package.json b/tubearchivist/www/package.json index 761e695..72afb53 100644 --- a/tubearchivist/www/package.json +++ b/tubearchivist/www/package.json @@ -16,6 +16,7 @@ "react": "^18.0.0", "react-dom": "^18.0.0", "react-player": "^2.10.0", + "react-query": "^3.34.19", "sharp": "^0.30.3" }, "devDependencies": { diff --git a/tubearchivist/www/src/components/VideoList.tsx b/tubearchivist/www/src/components/VideoList.tsx index e6d0d49..6655bc7 100644 --- a/tubearchivist/www/src/components/VideoList.tsx +++ b/tubearchivist/www/src/components/VideoList.tsx @@ -1,14 +1,18 @@ import NextImage from "next/image"; import { useState } from "react"; import ReactPlayer from "react-player/file"; +import { useQuery } from "react-query"; import IconClose from "../images/icon-close.svg"; import IconPlay from "../images/icon-play.svg"; import { TA_BASE_URL } from "../lib/constants"; +import { getVideos } from "../lib/getVideos"; import { formatNumbers } from "../lib/utils"; import { Datum, Videos } from "../types/video"; -export const VideoList = ({ videos }: { videos: Videos }) => { +export const VideoList = () => { const [selectedVideoUrl, setSelectedVideoUrl] = useState(); + const { data: queryData } = useQuery("videos", getVideos); + const { data: videos } = queryData; const handleSelectedVideo = (video: Datum) => { setSelectedVideoUrl(video); @@ -163,7 +167,7 @@ export const VideoList = ({ videos }: { videos: Videos }) => {
{videos && - videos?.data?.map((video) => { + videos?.map((video) => { return (
{ }; function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) { + const [queryClient] = useState(() => new QueryClient()); return ( <> {/*