From 313f6af8745890903c9e5badca2e8fa9ef327b23 Mon Sep 17 00:00:00 2001 From: Cooper Ransom Date: Sun, 17 Mar 2024 16:54:18 -0400 Subject: [PATCH] revert to OG flix page bc i cant code for shit --- src/pages/TopFlix.tsx | 124 +++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 39 deletions(-) diff --git a/src/pages/TopFlix.tsx b/src/pages/TopFlix.tsx index 48c8a293..550aa3bc 100644 --- a/src/pages/TopFlix.tsx +++ b/src/pages/TopFlix.tsx @@ -1,15 +1,14 @@ import classNames from "classnames"; -import { useEffect, useState } from "react"; +import { ReactNode, useEffect, useState } from "react"; +import { Link } from "react-router-dom"; // Import Link from react-router-dom -import { getMediaDetails, getMediaPoster } from "@/backend/metadata/tmdb"; -import { TMDBContentTypes } from "@/backend/metadata/types/tmdb"; import { ThiccContainer } from "@/components/layout/ThinContainer"; -import { MediaCard } from "@/components/media/MediaCard"; -import { MediaGrid } from "@/components/media/MediaGrid"; +import { Divider } from "@/components/utils/Divider"; import { Heading1, Paragraph } from "@/components/utils/Text"; -import { MediaItem } from "@/utils/mediaTypes"; import { SubPageLayout } from "./layouts/SubPageLayout"; +// import { MediaGrid } from "@/components/media/MediaGrid" +// import { TopFlixCard } from "@/components/media/FlixCard"; function Button(props: { className: string; @@ -32,25 +31,53 @@ function Button(props: { ); } -function isShowOrMovie(tmdbFullId: string): "show" | "movie" { +function isShowOrMovie(tmdbFullId: string): "series" | "movie" | "unknown" { if (tmdbFullId.includes("show-")) { - return "show"; + return "series"; } if (tmdbFullId.includes("movie-")) { return "movie"; } - throw new Error("Invalid tmdbFullId"); + return "unknown"; } -async function getPoster( - tmdbId: string, - type: TMDBContentTypes.MOVIE | TMDBContentTypes.TV, -): Promise { - const details = await getMediaDetails(tmdbId, type); +function directLinkToContent(tmdbFullId: string) { + if (isShowOrMovie(tmdbFullId) === "series") { + return `${window.location.pathname}#/media/tmdb-movie-${ + tmdbFullId.split("-")[1] + }`; + } + if (isShowOrMovie(tmdbFullId) === "movie") { + return `${window.location.pathname}#/media/tmdb-tv-${ + tmdbFullId.split("-")[1] + }`; + } + return null; +} - const posterPath = getMediaPoster(details.poster_path); - - return posterPath || ""; +function ConfigValue(props: { + name: string; + id: string; + children?: ReactNode; +}) { + const link = directLinkToContent(props.id); + return ( + <> +
+

+ {link ? ( + + {props.name} + + ) : ( +

{props.name}

+ )} +

+

{props.children}

+
+ + + ); } async function getRecentPlayedItems() { @@ -112,8 +139,9 @@ export function TopFlix() { const [totalViews, setTotalViews] = useState(null); const [loading, setLoading] = useState(true); const [currentPage, setCurrentPage] = useState(1); - const itemsPerPage = 12; - const maxItemsToShow = 12; // Maximum items to show + const itemsPerPage = 10; + const maxItemsToShow = 100; // Maximum items to show + const maxPageCount = Math.ceil(maxItemsToShow / itemsPerPage); // Calculate max page count based on maxItemsToShow useEffect(() => { getRecentPlayedItems() @@ -157,8 +185,6 @@ export function TopFlix() { ); } - // make a object named media and it should be of type MediaItem - return ( @@ -169,30 +195,50 @@ export function TopFlix() { the current backend deployment.
-
+

Overall Views: {totalViews}

- - {getItemsForCurrentPage().map((item) => { - const tmdbId = item.tmdbFullId.split("-")[1]; - const type = isShowOrMovie(item.tmdbFullId); - const poster = getPoster(tmdbId, type === "movie" ? TMDBContentTypes.MOVIE : TMDBContentTypes.TV); - console.log(poster); - const media: MediaItem = { - id: tmdbId, - title: item.title, - type, - poster, - // year: 420, - }; - - return ; - })} - + + {getItemsForCurrentPage().map((item) => { + return ( + + {`${item.providerId}, ${isShowOrMovie( + item.tmdbFullId, + )} - Views: `} + {item.count} + + ); + })} +
+
+ +
+ {currentPage} / {maxPageCount} +
+