import NotFound from "./404"; import { GetStaticProps, NextPage } from "next"; import { NextSeo } from "next-seo"; import Link from "next/link"; import { useRouter } from "next/router"; import { useQuery } from "react-query"; import axios, { AxiosError } from "axios"; import Avatar from "@mui/material/Avatar"; import Box from "@mui/material/Box"; import Container from "@mui/material/Container"; import Divider from "@mui/material/Divider"; import Typography from "@mui/material/Typography"; import { useTheme } from "@mui/material/styles"; import Share from "@mui/icons-material/Share"; import { abbreviateNumber } from "@src/utils"; import { Error } from "@interfaces/api"; import VideoAPI from "@interfaces/api/video"; import useSettings from "@utils/hooks/useSettings"; import Layout from "@components/Layout"; import Loading from "@components/Loading"; import Player from "@components/Player"; import styles from "./watch.module.css"; const Watch: NextPage = () => { const { query, isReady } = useRouter(); const theme = useTheme(); const videoId = query["v"]; const [settings] = useSettings(); const { isLoading, error, data } = useQuery< VideoAPI | null, AxiosError >(["videoData", videoId], () => videoId ? axios .get(`https://${settings.invidiousServer}/api/v1/videos/${videoId}`, { params: {} }) .then((res) => res.data) : null ); if (!isReady || isLoading) { return ( <> ); } if (!videoId) { return ; } return ( <> {data && ( <> {data.title} {abbreviateNumber(data.viewCount)} Views •{" "} {new Date(data.published * 1000).toLocaleDateString()} thumbnail.width == 100 )?.url } alt={data.author} sx={{ mr: 2 }} /> {data.author} ") }} > )} ); }; export default Watch;