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 { TA_BASE_URL } from "../../lib/constants"; import { getVideo } from "../../lib/getVideos"; import VideoPlayer from "../../components/VideoPlayer/VideoPlayer"; 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 %} */}
Youtube:{" "} Active
{/* {% else %} */}Youtube: Deactivated
{/* {% endif %} */}
:
{data.data.stats.view_count}{" "}
:
{data.data.stats.like_count}{" "}
: {data?.data?.stats?.dislike_count}{" "}
Rating:
{/* {% for star in video.stats.average_rating %} */}
{/* {% endfor %} */}
Description:{" "}