import Slider from '@app/components/Slider'; import TmdbTitleCard from '@app/components/TitleCard/TmdbTitleCard'; import { UserType, useUser } from '@app/hooks/useUser'; import { ArrowRightCircleIcon } from '@heroicons/react/24/outline'; import type { WatchlistItem } from '@server/interfaces/api/discoverInterfaces'; import Link from 'next/link'; import { defineMessages, useIntl } from 'react-intl'; import useSWR from 'swr'; const messages = defineMessages({ plexwatchlist: 'Your Plex Watchlist', emptywatchlist: 'Media added to your Plex Watchlist will appear here.', }); const PlexWatchlistSlider = () => { const intl = useIntl(); const { user } = useUser(); const { data: watchlistItems, error: watchlistError } = useSWR<{ page: number; totalPages: number; totalResults: number; results: WatchlistItem[]; }>(user?.userType === UserType.PLEX ? '/api/v1/discover/watchlist' : null, { revalidateOnMount: true, }); if ( user?.userType !== UserType.PLEX || (watchlistItems && watchlistItems.results.length === 0 && !user?.settings?.watchlistSyncMovies && !user?.settings?.watchlistSyncTv) || watchlistError ) { return null; } return ( <>
{intl.formatMessage(messages.plexwatchlist)}
( {msg} ), })} items={watchlistItems?.results.map((item) => ( ))} /> ); }; export default PlexWatchlistSlider;