From 5b787922f2f6a8f82daab3e9fde3ec817eae7727 Mon Sep 17 00:00:00 2001
From: Tejas Panchal
Date: Mon, 11 Aug 2025 12:10:13 +0530
Subject: [PATCH] updated category page
---
src/components/categorycard/CategoryCard.jsx | 73 ++++++++-----
src/pages/category/Category.jsx | 102 ++++++++++---------
2 files changed, 102 insertions(+), 73 deletions(-)
diff --git a/src/components/categorycard/CategoryCard.jsx b/src/components/categorycard/CategoryCard.jsx
index b5cbf7b..579d93f 100644
--- a/src/components/categorycard/CategoryCard.jsx
+++ b/src/components/categorycard/CategoryCard.jsx
@@ -159,18 +159,31 @@ const CategoryCard = React.memo(
)}
-
- {item.tvInfo.showType.split(" ").shift()}
-
-
-
- {item.tvInfo?.duration === "m" ||
- item.tvInfo?.duration === "?" ||
- item.duration === "m" ||
- item.duration === "?"
- ? "N/A"
- : item.tvInfo?.duration || item.duration || "N/A"}
-
+ {item.tvInfo?.showType && (
+
+ {item.tvInfo.showType.split(" ").shift()}
+
+ )}
+ {item.releaseDate && (
+
+ {item.releaseDate}
+
+ )}
+ {!item.tvInfo?.showType && item.type && (
+
+ {item.type}
+
+ )}
+ {(item.tvInfo?.duration || item.duration) && (
+
+ {item.tvInfo?.duration === "m" ||
+ item.tvInfo?.duration === "?" ||
+ item.duration === "m" ||
+ item.duration === "?"
+ ? "N/A"
+ : item.tvInfo?.duration || item.duration || "N/A"}
+
+ )}
@@ -253,17 +266,31 @@ const CategoryCard = React.memo(
)}
-
- {item.tvInfo.showType.split(" ").shift()}
-
-
- {item.tvInfo?.duration === "m" ||
- item.tvInfo?.duration === "?" ||
- item.duration === "m" ||
- item.duration === "?"
- ? "N/A"
- : item.tvInfo?.duration || item.duration || "N/A"}
-
+ {item.tvInfo?.showType && (
+
+ {item.tvInfo.showType.split(" ").shift()}
+
+ )}
+ {item.releaseDate && (
+
+ {item.releaseDate}
+
+ )}
+ {!item.tvInfo?.showType && item.type && (
+
+ {item.type}
+
+ )}
+ {(item.tvInfo?.duration || item.duration) && (
+
+ {item.tvInfo?.duration === "m" ||
+ item.tvInfo?.duration === "?" ||
+ item.duration === "m" ||
+ item.duration === "?"
+ ? "N/A"
+ : item.tvInfo?.duration || item.duration || "N/A"}
+
+ )}
diff --git a/src/pages/category/Category.jsx b/src/pages/category/Category.jsx
index f16f80e..9b4b39b 100644
--- a/src/pages/category/Category.jsx
+++ b/src/pages/category/Category.jsx
@@ -2,14 +2,9 @@ import { useEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
import getCategoryInfo from "@/src/utils/getCategoryInfo.utils";
import CategoryCard from "@/src/components/categorycard/CategoryCard";
-import Genre from "@/src/components/genres/Genre";
-import Topten from "@/src/components/topten/Topten";
-import Loader from "@/src/components/Loader/Loader";
-import Error from "@/src/components/error/Error";
+import CategoryCardLoader from "@/src/components/Loader/CategoryCard.loader";
import { useNavigate } from "react-router-dom";
-import { useHomeInfo } from "@/src/context/HomeInfoContext";
import PageSlider from "@/src/components/pageslider/PageSlider";
-import SidecardLoader from "@/src/components/Loader/Sidecard.loader";
function Category({ path, label }) {
const [searchParams, setSearchParams] = useSearchParams();
@@ -18,8 +13,8 @@ function Category({ path, label }) {
const [error, setError] = useState(null);
const [totalPages, setTotalPages] = useState(0);
const page = parseInt(searchParams.get("page")) || 1;
- const { homeInfo, homeInfoLoading } = useHomeInfo();
const navigate = useNavigate();
+
useEffect(() => {
const fetchCategoryInfo = async () => {
setLoading(true);
@@ -31,68 +26,75 @@ function Category({ path, label }) {
} catch (err) {
setError(err);
console.error("Error fetching category info:", err);
+ setLoading(false);
}
};
fetchCategoryInfo();
- window.scrollTo(0, 0);
+ window.scrollTo({ top: 0, behavior: 'smooth' });
}, [path, page]);
- if (loading) return ;
- if (error) {
- navigate("/error-page");
- return ;
- }
- if (!categoryInfo) {
- navigate("/404-not-found-page");
- return null;
- }
+
const handlePageChange = (newPage) => {
setSearchParams({ page: newPage });
};
+ const categoryGridClass = "grid-cols-8 max-[1600px]:grid-cols-6 max-[1200px]:grid-cols-4 max-[758px]:grid-cols-3 max-[478px]:grid-cols-3 max-[478px]:gap-x-2";
+
return (
-
- {categoryInfo ? (
-
- {page > totalPages ? (
-
+
+
+ {loading ? (
+
+ ) : page > totalPages ? (
+
+
+ {label.split("/").pop()}
+
+
You came a long way, go back
nothing is here
- ) : (
-
- {categoryInfo && categoryInfo.length > 0 && (
-
- )}
+
+ ) : categoryInfo && categoryInfo.length > 0 ? (
+
+
+ {label.split("/").pop()}
+
+
+
- )}
-
- {homeInfoLoading ? (
-
- ) : (
- <>
- {homeInfo && homeInfo.topten && (
-
- )}
- {homeInfo?.genres && }
- >
- )}
-
- ) : (
-
- )}
+ ) : error ? (
+
+
+ {label.split("/").pop()}
+
+
+ Couldn't get {label.split("/").pop()} results, please try again
+
+
+ ) : (
+
+
+ {label.split("/").pop()}
+
+
+ No results found for: {label.split("/").pop()}
+
+
+ )}
+
);
}