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
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 %} */} {/* {% else %} */} {/* {% endif %} */}
{/* {% if video.active %} */}Youtube:{" "} Active
{/* {% else %} */}Youtube: Deactivated
{/* {% endif %} */}: {data.data.stats.view_count}{" "}
: {data.data.stats.like_count}{" "}
{/* {% if video.stats.dislike_count %} */} {data.data.stats.dislike_count > 0 ? (: {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 %} */} {/* {% endfor %} */}
) : null} {/* {% endif %} */}Description:{" "}