From 77a0b69d9a0dd755a0a59a4c1dc3f3d045327e89 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 22 Nov 2023 21:58:45 -0800 Subject: feat: re-implement individual statistic pages on next --- src/pages/stats/[slug].tsx | 72 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 11 deletions(-) (limited to 'src/pages/stats') diff --git a/src/pages/stats/[slug].tsx b/src/pages/stats/[slug].tsx index 03f8adf..1971c1e 100644 --- a/src/pages/stats/[slug].tsx +++ b/src/pages/stats/[slug].tsx @@ -1,16 +1,66 @@ -"use client" -import { useRouter } from 'next/router' - +"use client"; +import React, { useEffect, useState } from "react"; +import { useRouter } from "next/router"; +import "../../app/globals.css"; +import TitleBar from "../../components/TitleBar/TitleBar"; +import { ChannelCard } from "@/components/channel-card"; +import DataChart from "@/components/DataChart/DataChart"; +import axios from "axios"; + +interface ChannelDataProp { + channel_name: string; + profile_pic: string; + subscribers: number; + sub_org: string; + video_count: number; + next_milestone: string; + days_until_next_milestone: string; + next_milestone_date: string; +} + export default function Page() { + const [channelData, setChannelData] = useState(null); const router = useRouter(); + const { slug } = router.query; + useEffect(() => { + const apiUrl = process.env.NEXT_PUBLIC_API_URL; + if (slug) { + const encodedSlug = encodeURIComponent(slug as string); + console.log(apiUrl + `/api/channel/${encodedSlug}`); + axios.get(apiUrl + `/api/channel/${encodedSlug}`).then((response) => { + console.log(response); + setChannelData(response.data); + }); + } + }, [slug]); + return ( -
-
-

Under Construction

-

We are currently working on this page. Please check back later.

-

Thank you for your patience

-

Slug: {router.query.slug}

+ <> + +
+
+ {channelData && ( + + )} +
-
+
+
+ +
+
+ +
+
+ ); -} \ No newline at end of file +} -- cgit v1.2.3