diff --git a/src/pages/archives/videos/c/[uid].tsx b/src/pages/archives/videos/c/[uid].tsx index ca36703..b85db68 100644 --- a/src/pages/archives/videos/c/[uid].tsx +++ b/src/pages/archives/videos/c/[uid].tsx @@ -22,7 +22,6 @@ import { useTypedRouter } from "hooks/useTypedRouter"; import { Select } from "components/Inputs/Select"; import { sendAnalytics } from "helpers/analytics"; import { Button } from "components/Inputs/Button"; -import { GetVideoChannelQuery } from "graphql/generated"; import { getReadySdk } from "graphql/sdk"; import { Paginator } from "components/Containers/Paginator"; import { useFormat } from "hooks/useFormat"; @@ -56,9 +55,11 @@ const queryParamSchema = z.object({ */ interface Props extends AppLayoutRequired { - channel: NonNullable< - NonNullable["data"][number]["attributes"] - >; + channel: { + uid: string; + title: string; + subscribers: number; + }; } const Channel = ({ channel, ...otherProps }: Props): JSX.Element => { @@ -282,14 +283,23 @@ export default Channel; export const getStaticProps: GetStaticProps = async (context) => { const sdk = getReadySdk(); const { format } = getFormat(context.locale); - const channel = await sdk.getVideoChannel({ - channel: context.params && isDefined(context.params.uid) ? context.params.uid.toString() : "", - }); - if (!channel.videoChannels?.data[0]?.attributes) return { notFound: true }; + const videoChannel = ( + await sdk.getVideoChannel({ + channel: context.params && isDefined(context.params.uid) ? context.params.uid.toString() : "", + }) + ).videoChannels?.data[0]?.attributes; + + if (!videoChannel) return { notFound: true }; + + const channel: Props["channel"] = { + uid: videoChannel.uid, + subscribers: videoChannel.subscribers, + title: videoChannel.title, + }; const props: Props = { - channel: channel.videoChannels.data[0].attributes, - openGraph: getOpenGraph(format, channel.videoChannels.data[0].attributes.title), + channel, + openGraph: getOpenGraph(format, channel.title), }; return { props: props, diff --git a/src/pages/archives/videos/v/[uid].tsx b/src/pages/archives/videos/v/[uid].tsx index b491455..e1a7855 100644 --- a/src/pages/archives/videos/v/[uid].tsx +++ b/src/pages/archives/videos/v/[uid].tsx @@ -9,10 +9,10 @@ import { NavOption } from "components/PanelComponents/NavOption"; import { ReturnButton } from "components/PanelComponents/ReturnButton"; import { ContentPanel, ContentPanelWidthSizes } from "components/Containers/ContentPanel"; import { SubPanel } from "components/Containers/SubPanel"; -import { GetVideoQuery } from "graphql/generated"; +import { Enum_Video_Source } from "graphql/generated"; import { getReadySdk } from "graphql/sdk"; import { prettyShortenNumber } from "helpers/formatters"; -import { filterHasAttributes, isDefined } from "helpers/asserts"; +import { filterHasAttributes, isDefined, isUndefined } from "helpers/asserts"; import { getVideoFile, getVideoThumbnailURL } from "helpers/videos"; import { getOpenGraph } from "helpers/openGraph"; import { atoms } from "contexts/atoms"; @@ -29,15 +29,29 @@ import { Markdown } from "components/Markdown/Markdown"; */ interface Props extends AppLayoutRequired { - video: NonNullable["data"][number]["attributes"]>; + video: { + isGone: boolean; + uid: string; + title: string; + description: string; + publishedDate: string; + views: number; + likes: number; + source?: Enum_Video_Source; + }; + channel?: { + title: string; + href: string; + subscribers: number; + }; } -const Video = ({ video, ...otherProps }: Props): JSX.Element => { +const Video = ({ video, channel, ...otherProps }: Props): JSX.Element => { const isContentPanelAtLeast4xl = useAtomGetter(atoms.containerQueries.isContentPanelAtLeast4xl); const is1ColumnLayout = useAtomGetter(atoms.containerQueries.is1ColumnLayout); const setSubPanelOpened = useAtomSetter(atoms.layout.subPanelOpened); const closeSubPanel = useCallback(() => setSubPanelOpened(false), [setSubPanelOpened]); - const { format, formatDate } = useFormat(); + const { format } = useFormat(); const subPanel = ( @@ -62,7 +76,7 @@ const Video = ({ video, ...otherProps }: Props): JSX.Element => {
- {video.gone ? ( + {video.isGone ? ( ) : (