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 ( <>
Last refreshed: {playlist.data.playlist_last_refresh}
Playlist:{" "} {playlist.data.playlist_subscribed ? ( ) : ( )}
Youtube:{" "} Active
Total Videos archived: {playlist.data.playlist_entries.length}
Watched:{" "}
{playlist.data.playlist_description}
{error.message}