import Header from '@app/components/Common/Header'; import ListView from '@app/components/Common/ListView'; import PageTitle from '@app/components/Common/PageTitle'; import useDiscover from '@app/hooks/useDiscover'; import { useUser } from '@app/hooks/useUser'; import Error from '@app/pages/_error'; import type { WatchlistItem } from '@server/interfaces/api/discoverInterfaces'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { defineMessages, useIntl } from 'react-intl'; const messages = defineMessages({ discoverwatchlist: 'Your Watchlist', watchlist: 'Plex Watchlist', }); const DiscoverWatchlist = () => { const intl = useIntl(); const router = useRouter(); const { user } = useUser({ id: Number(router.query.userId), }); const { user: currentUser } = useUser(); const { isLoadingInitialData, isEmpty, isLoadingMore, isReachingEnd, titles, fetchMore, error, mutate, } = useDiscover( `/api/v1/${ router.pathname.startsWith('/profile') ? `user/${currentUser?.id}` : router.query.userId ? `user/${router.query.userId}` : 'discover' }/watchlist` ); if (error) { return ; } const title = intl.formatMessage( router.query.userId ? messages.watchlist : messages.discoverwatchlist ); return ( <>
{user?.displayName} ) : ( '' ) } > {title}
0) } isReachingEnd={isReachingEnd} onScrollBottom={fetchMore} mutateParent={mutate} /> ); }; export default DiscoverWatchlist;