Purchase Content

An infinite scroll grid component for displaying purchased content with TanStack Query integration

Zezo Purchase Content Component

📦 Installation

pnpm dlx shadcn@latest add https://zezo-ui.vercel.app/r/zezo-purchase-content.json

💡 Usage Example

import PurchaseContent from "@/components/zezo/users/purchase-content/PurchaseContent";
import type { IPageData, IPurchaseItem } from "@/components/zezo/users/purchase-content/PurchaseContentInner";

// Fetch function
const fetchPurchaseList = async ({ 
  pageParam = 1 
}: { 
  pageParam?: number 
}): Promise<IPageData> => {
  const response = await fetch(`/api/purchases?page=${pageParam}`);
  return response.json();
};

// Component usage
<PurchaseContent
  fetchPurchaseList={fetchPurchaseList}
  onItemClick={(item: IPurchaseItem) => {
    console.log("Clicked:", item.name);
    // Navigate to content page
  }}
/>

📘 Props

PropTypeRequiredDescription
fetchPurchaseList(params: { pageParam?: number }) => Promise<IPageData>YesAsync function to fetch paginated purchase items. Must return IPageData with pagination metadata
onItemClick(item: IPurchaseItem) => voidOptionalCallback function called when user clicks on a purchase item

🧩 Interfaces

The component uses these TypeScript interfaces:

export interface IPurchaseItem {
  _id: string;           // Required: Unique item identifier
  name: string;          // Required: Item name/title
  slug: string;         // Required: URL-friendly identifier
  poster: string;       // Required: Poster image URL (displayed if available)
  thumbnail: string;    // Required: Thumbnail image URL (fallback if poster missing)
}

export interface IPageData {
  data: IPurchaseItem[];  // Required: Array of purchase items for this page
  meta: {                 // Required: Pagination metadata
    pagination: {
      page: number;        // Current page number
      limit: number;       // Items per page
      pages: number;       // Total number of pages
      total: number;       // Total number of items
      hasNextPage: boolean; // Whether more pages are available
      nextPage: number | null; // Next page number or null
    };
  };
}

📦 Required Packages

Install these packages before using PurchaseContent:

npm install @tanstack/react-query react-infinite-scroll-component

✨ Features

♾️ Infinite Scroll

Automatically loads more items as user scrolls

🔄 TanStack Query

Built-in React Query integration for data fetching

⏳ Loading States

Skeleton loading animation while fetching data

🖼️ Image Display

Shows poster image, falls back to thumbnail

🛒 Shopping Cart Icon

Section header with shopping cart icon

🎬 Hover Effects

Smooth scale animation on hover

📭 Empty State

Shows message when no purchases available

🖱️ Click Handler

Optional onClick callback for each item

📱 Responsive

Flexible grid layout adapts to screen size

🌓 Dark Mode

Automatic theme support