import { GetServerSideProps, NextPage } from "next"; import NextImage from "next/image"; import { getSession, useSession } from "next-auth/react"; import { useRouter } from "next/router"; import { dehydrate, QueryClient, useQuery } from "react-query"; import { CustomHead } from "../../components/CustomHead"; import { Layout } from "../../components/Layout"; import { getTAUrl } from "../../lib/constants"; import { getVideo } from "../../lib/getVideos"; import VideoPlayer from "../../components/VideoPlayer/VideoPlayer"; const TA_BASE_URL = getTAUrl(); export const getServerSideProps: GetServerSideProps = async (context) => { const queryClient = new QueryClient(); const session = await getSession(context); const videoId = context.query.videoId; if (!session) { return { redirect: { destination: "/auth/login", permanent: false, }, }; } await queryClient.prefetchQuery(["video", videoId], () => getVideo(session.ta_token.token, videoId as string) ); return { props: { dehydratedState: dehydrate(queryClient), session, }, }; }; const Video: NextPage = () => { const router = useRouter(); const { videoId } = router.query; const { data: session } = useSession(); const { data, error, isLoading } = useQuery( ["video", session.ta_token.token], () => getVideo(session.ta_token.token, videoId as string), { enabled: !!session?.ta_token?.token, } ); if (isLoading) return

Loading...

; return (
{/* {% if cast %} */} {/* */} {/* {% endif %} */}

{data?.data?.title}

{" "} {data?.data?.channel?.channel_name}{" "}

{/* {% if video.channel.channel_subs >= 1000000 %} */}

Subscribers: {data?.data?.channel?.channel_subs}

{/* {% else %} */} {/*

Subscribers: video.channel.channel_subs|intcomma

*/} {/* {% endif %} */}

Published: {data?.data?.published}

Last refreshed: {data?.data?.vid_last_refresh}

Watched: {/* {% if video.player.watched %} */} seen-icon {/* {% else %} */} unseen-icon {/* {% endif %} */}

{/* {% if video.active %} */}

Youtube:{" "} Active

{/* {% else %} */}

Youtube: Deactivated

{/* {% endif %} */}
Are you sure? {" "}

views: {data.data.stats.view_count}{" "}

thumbs-up: {data.data.stats.like_count}{" "}

{/* {% if video.stats.dislike_count %} */} {data.data.stats.dislike_count > 0 ? (

thumbs-down : {data?.data?.stats?.dislike_count}{" "}

) : null} {/* {% endif %} */} {/* {% if video.stats.average_rating %} */} {data.data.stats.average_rating ? (

Rating: {/* {% for star in video.stats.average_rating %} */} {{ star }} {/* {% endfor %} */}

) : null} {/* {% endif %} */}
{/* {% if video.description %} */}

Description:{" "}

{data?.data?.description}
{/* {% endif %} */} {/* {% if playlist_nav %} */} {/* {% for playlist_item in playlist_nav %} */}

Playlist playlist_item.playlist_meta.current_idx|add:1 : playlist_item.playlist_meta.playlist_name{" "}

{/* {% if playlist_item.playlist_previous %} */} previous thumbnail {/* {% endif %} */}
{/* {% if playlist_item.playlist_next %} */} previous thumbnail {/* {% endif %} */}
{/* {% endfor %} {% endif %} */}
); }; export default Video;