"use client"; import Image from "next/image"; import Link from "next/link"; import { useEffect, useMemo, useState } from "react"; import { Reveal } from "@/components/Reveal"; import { Pagination } from "@/components/shared/Pagination"; import type { DisplayProject, PortfolioCategory } from "@/lib/api"; const ALL_ID = "__all__"; const PAGE_SIZE = 9; /** * Category tabs above a grid — no search, click a tab to filter in place. * * Tabs only render when there is more than one real category on the fetched * projects. The client's portfolio items currently share a single category, * so the bar stays hidden rather than show one meaningless tab; the moment * a second category exists in the CMS, this switches on with no code change. */ export function PortfolioBrowser({ projects, categories, }: { projects: DisplayProject[]; categories: PortfolioCategory[]; }) { const [activeId, setActiveId] = useState(ALL_ID); const [page, setPage] = useState(1); const showTabs = categories.length > 1; const filtered = useMemo( () => (activeId === ALL_ID ? projects : projects.filter((p) => p.categoryId === activeId)), [projects, activeId], ); // Switching category with a stale page number could land on an empty page. useEffect(() => setPage(1), [activeId]); const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)); const pageItems = filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE); return (
پروژهای در این دسته یافت نشد.
) : (