import { useState, useMemo } from 'react' import { Link } from 'react-router-dom' import { Search, ChevronRight, ChevronLeft } from 'lucide-react' import { reports } from '@/data/reports' import type { ReportCategory, ReportType } from '@/data/reports' /* ─── constants ──────────────────────────────────────────── */ const CATEGORIES: { label: string; value: ReportCategory | 'همه' }[] = [ { label: 'همه', value: 'همه' }, { label: 'بازار جهانی', value: 'بازار جهانی' }, { label: 'سیاست‌گذاری', value: 'سیاست‌گذاری' }, { label: 'انرژی و ESG', value: 'انرژی و ESG' }, { label: 'صادرات', value: 'صادرات' }, { label: 'تولید داخلی', value: 'تولید داخلی' }, { label: 'ریسک و بحران', value: 'ریسک و بحران' }, ] const TYPES: { label: string; value: ReportType | 'همه' | 'رایگان' }[] = [ { label: 'همه', value: 'همه' }, { label: 'رایگان', value: 'رایگان' }, { label: 'Flash Report', value: 'flash' }, { label: 'فصلی', value: 'quarterly' }, { label: 'گزارش ویژه', value: 'special' }, { label: 'ریسک', value: 'risk' }, ] const SORT_OPTIONS = [ { label: 'جدیدترین', value: 'newest' }, { label: 'قدیمی‌ترین', value: 'oldest' }, { label: 'گران‌ترین', value: 'price-desc' }, { label: 'ارزان‌ترین', value: 'price-asc' }, ] const TYPE_COLORS: Record = { quarterly: '#166534', flash: '#9b1c1c', risk: '#92400e', free: '#1d4ed8', special: '#4a1d96', } const TYPE_LABELS: Record = { quarterly: 'فصلی', flash: 'فلش', risk: 'ریسک', free: 'رایگان', special: 'ویژه', } const PAGE_SIZE = 9 /* ─── price formatter ────────────────────────────────────── */ function formatPrice(price: number): string { if (price === 0) return 'رایگان' return price.toLocaleString('fa-IR') + ' تومان' } /* ─── report card ────────────────────────────────────────── */ function ReportCard({ report }: { report: (typeof reports)[0] }) { const [hovered, setHovered] = useState(false) return (
{/* top meta */}
{report.category} {report.isFree && ( رایگان )} {TYPE_LABELS[report.type]}
{/* title */} setHovered(true)} onMouseLeave={() => setHovered(false)} > {report.title} {/* meta row */}
{report.author} · {report.publishDate} · {report.pages} صفحه
{/* divider */}
{/* price row */}
{formatPrice(report.price)} {report.isFree ? 'دانلود' : 'خرید'}
) } /* ─── main component ─────────────────────────────────────── */ export default function Reports() { const [activeCategory, setActiveCategory] = useState('همه') const [activeType, setActiveType] = useState('همه') const [sortBy, setSortBy] = useState('newest') const [searchQuery, setSearchQuery] = useState('') const [page, setPage] = useState(1) const filtered = useMemo(() => { let result = [...reports] if (activeCategory !== 'همه') { result = result.filter((r) => r.category === activeCategory) } if (activeType !== 'همه') { if (activeType === 'رایگان') { result = result.filter((r) => r.isFree) } else { result = result.filter((r) => r.type === activeType) } } if (searchQuery.trim()) { const q = searchQuery.trim().toLowerCase() result = result.filter( (r) => r.title.toLowerCase().includes(q) || r.author.toLowerCase().includes(q) || r.category.toLowerCase().includes(q) || r.tags.some((t) => t.toLowerCase().includes(q)) ) } switch (sortBy) { case 'oldest': result = result.reverse() break case 'price-desc': result = result.sort((a, b) => b.price - a.price) break case 'price-asc': result = result.sort((a, b) => a.price - b.price) break } return result }, [activeCategory, activeType, sortBy, searchQuery]) const totalPages = Math.ceil(filtered.length / PAGE_SIZE) const paged = filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE) // Reset to page 1 on filter change const handleCategoryChange = (cat: ReportCategory | 'همه') => { setActiveCategory(cat) setPage(1) } const handleTypeChange = (type: ReportType | 'همه' | 'رایگان') => { setActiveType(type) setPage(1) } return (
{/* Page header */}

گزارش‌ها

تحلیل‌های تخصصی بازار فولاد ایران و جهان — گزارش‌های فصلی، ریسک، و فلش

{/* ─── Filter bar ──────────────────────────────────── */}
{/* Category pills */}
{CATEGORIES.map((cat) => ( ))}
{/* Second row: type + sort + search */}
{/* Type filter */}
{TYPES.map((t) => ( ))}
{/* Sort */}
مرتب‌سازی
{/* Search */}
{ setSearchQuery(e.target.value) setPage(1) }} style={{ border: '1px solid var(--ink)', padding: '8px 36px 8px 12px', fontSize: 12, fontFamily: 'inherit', background: 'transparent', color: 'var(--ink)', borderRadius: 0, outline: 'none', width: 200, direction: 'rtl', }} />
{/* ─── Report grid ─────────────────────────────────── */} {paged.length > 0 ? (
{paged.map((report) => ( ))} {/* Fill empty cells in last row to keep grid consistent */} {paged.length % 3 !== 0 && Array.from({ length: 3 - (paged.length % 3) }).map((_, i) => (
))}
) : (

نتیجه‌ای یافت نشد

جستجو یا فیلترهای خود را تغییر دهید

)} {/* ─── Pagination ──────────────────────────────────── */} {totalPages > 1 && (
صفحه {page.toLocaleString('fa-IR')} از {totalPages.toLocaleString('fa-IR')}
)} {/* ─── Mobile responsive styles ────────────────────── */}
) }