channel: implemented basic backend data fetch
parent
8a6097302b
commit
8d112266f1
@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { FC } from "react";
|
||||
|
||||
import { useClient } from "@/hooks/useClient";
|
||||
|
||||
import { Container } from "@/components/Container";
|
||||
|
||||
export const ChannelPage: FC<{ channelId: string }> = ({ channelId }) => {
|
||||
const client = useClient();
|
||||
|
||||
const { error } = useQuery({
|
||||
queryKey: ["channel", channelId],
|
||||
queryFn: () => {
|
||||
return client.getChannel(channelId);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(error);
|
||||
|
||||
return <Container>{channelId}</Container>;
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
import { NextPage } from "next";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import { ChannelPage } from "./ChannelPage";
|
||||
|
||||
const Page: NextPage<{ params: { id: string } }> = ({ params }) => {
|
||||
return (
|
||||
<>
|
||||
<Suspense>
|
||||
<ChannelPage channelId={params.id} />
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
@ -0,0 +1,29 @@
|
||||
import z from "zod";
|
||||
|
||||
import { ItemModel } from "./item";
|
||||
|
||||
export const tabEnum = [
|
||||
"shorts",
|
||||
"albums",
|
||||
"playlists",
|
||||
"livestreams"
|
||||
] as const;
|
||||
|
||||
export const tabType = z.enum(tabEnum);
|
||||
|
||||
export const ChannelModel = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
avatarUrl: z.string().url(),
|
||||
bannerUrl: z.string().url(),
|
||||
description: z.string(),
|
||||
nextpage: z.string().nullable(),
|
||||
subscriberCount: z.number(),
|
||||
verified: z.boolean(),
|
||||
relatedStreams: ItemModel.array(),
|
||||
tabs: z.object({ name: tabType, data: z.string() }).array()
|
||||
});
|
||||
|
||||
type Channel = z.infer<typeof ChannelModel>;
|
||||
|
||||
export default Channel;
|
@ -0,0 +1,9 @@
|
||||
import { Author } from "./author";
|
||||
|
||||
export interface Channel extends Author {
|
||||
id: string;
|
||||
subscribers: number;
|
||||
description: string;
|
||||
avatar: string;
|
||||
banner?: string;
|
||||
}
|
Loading…
Reference in new issue