import { Link, useLoaderData } from "@remix-run/react"; import type { LoaderFunction } from "@remix-run/server-runtime"; import { API_URL } from "~/lib/constants"; import { API_KEY } from "~/lib/constants.server"; import { getChannel } from "~/lib/getChannels"; import { getPlaylist, getPlaylistVideos } from "~/lib/getPlaylists"; import type { Channel } from "~/types/channel"; import type { Playlist } from "~/types/playlist"; import type { PlaylistVideos } from "~/types/playlistVideos"; export const loader: LoaderFunction = async ({ params, context, request }) => { const playlist = await getPlaylist(API_KEY, params.id); const channel = await getChannel(API_KEY, playlist.data.playlist_channel_id); const videos = await getPlaylistVideos(API_KEY, params.id); const channelThumb = `http://localhost:8000${channel.data.channel_thumb_url}`; return { playlist, channel, channelThumb, videos }; }; export const PlaylistPage = () => { const { playlist, channel, channelThumb, videos } = useLoaderData<{ playlist: Playlist; channel: Channel; channelThumb: string; videos: PlaylistVideos; }>(); return ( <>

{playlist.data.playlist_name}

channel thumb

{channel.data.channel_name}

Subscribers: {channel.data.channel_subs.toLocaleString("en-US")}

Last refreshed: {playlist.data.playlist_last_refresh}

Playlist:{" "} {playlist.data.playlist_subscribed ? ( ) : ( )}

Youtube:{" "} Active

Delete {playlist.data.playlist_name}

Total Videos archived: {playlist.data.playlist_entries.length}

Watched:{" "}

{playlist.data.playlist_description}

Hide watched videos:
grid plus row grid minus row
grid view list view
{videos.data.map((video) => (
video thumbnail
play button
{video.player.watched ? ( seen indicator ) : ( seen indicator )} {video.published} | {video.player.duration_str}

{video.title}

))}
); }; export const ErrorBoundary = ({ error }: { error: Error }) => { console.log(error); return (

Error:

{error.message}

); }; export default PlaylistPage;