import { useState } from "react"; import { useProductsInfiniteQuery } from "../../requestHandler/use-explore-hooks"; import { useGetHomeCategories } from "../../requestHandler/use-home-hooks"; import TabContainer from "./TabContainer"; import { Link } from "@remix-run/react"; import { Telescope } from "lucide-react"; import MondrianProductList from "../MondrianProductList"; import { Skeleton } from "../ui/skeleton"; const MainSection = () => { const tabs = ["دسته بندی ها", "همه"]; const [activeTab, setActiveTab] = useState(0); // Use our custom infinite query hook const { data, fetchNextPage, hasNextPage, isFetchingNextPage, status, refetch, } = useProductsInfiniteQuery(); // Use the new categories hook const { data: categories, isLoading: categoriesLoading, isError: categoriesError, } = useGetHomeCategories(); // Flatten all products from all pages const allProducts = data?.pages.flatMap((page) => page.results) || []; // Loading skeleton for categories const CategorySkeleton = () => (
{Array.from({ length: 6 }).map((_, index) => (
))}
); return (
{activeTab === 0 ? ( categoriesLoading ? ( ) : categoriesError ? (

خطا در بارگذاری دسته بندی ها

) : (
{categories?.map((category, index) => { return ( {category.categoryName}

{category.categoryName}

); })}

در ویترون، پوشاک تنها یک انتخاب نیست، بلکه تجربه ای از سبک و کیفیت است. هر دسته بندی با دقت طراحی شده تا شما را در مسیر ساخت استایل شخصی و متمایزتان همراهی کند.

) ) : ( { return { id: product.id, title: product.title, images: product.imageUrls || [], discountPercent: product.discountPercent || 0, discountPrice: product.discountPrice || 0, basePrice: product.basePrice ? parseInt(product.basePrice) : undefined, sellerName: product.sellerName, sellerLogo: product.sellerLogo, sellerUsername: product.sellerUsername, }; })} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} isFetchingNextPage={isFetchingNextPage} isLoading={status === "pending"} isError={status === "error"} refetch={refetch} emptyState={{ image: , title: "محصولی در اکسپلور یافت نشد", description: "فکر میکنم بهتر باشه یه وقت دیگه تست کنید یا اینکه چیزی جدید بیاید.", }} /> )}
); }; export default MainSection;