import React from 'react'; import useSWR from 'swr'; import type { MovieResult, TvResult } from '../../../server/models/Search'; import TitleCard from '../TitleCard'; import { MediaRequest } from '../../../server/entity/MediaRequest'; import RequestCard from '../TitleCard/RequestCard'; interface MovieDiscoverResult { page: number; totalResults: number; totalPages: number; results: MovieResult[]; } interface TvDiscoverResult { page: number; totalResults: number; totalPages: number; results: TvResult[]; } const Discover: React.FC = () => { const { data: movieData, error: movieError } = useSWR( '/api/v1/discover/movies' ); const { data: tvData, error: tvError } = useSWR( '/api/v1/discover/tv' ); const { data: requests, error: requestError } = useSWR( '/api/v1/request' ); return ( <>

Recent Requests

{requests?.map((request) => (
))} {!requests && !requestError && [...Array(10)].map((_item, i) => (
))} {requests && !requestError && requests.length === 0 && (
No Requests found :(
)}

Popular Movies

{movieData?.results.map((title) => (
))} {!movieData && !movieError && [...Array(10)].map((_item, i) => (
))}

Popular TV Shows

{tvData?.results.map((title) => (
))} {!tvData && !tvError && [...Array(10)].map((_item, i) => (
))}
); }; export default Discover;