import { Link } from 'react-router-dom' import { useStatusLabel } from '../api' import { useLang } from '../i18n/lang' import { PremiumButton } from './PremiumButton' import type { StaticProject } from '../data/projectsData' import type { ProjectCardItem } from '../data/site' type ProjectCardProps = { project: StaticProject | ProjectCardItem; imageUrl?: string; detailHref?: string; } export function ProjectCard({ project, imageUrl, detailHref }: ProjectCardProps) { const isOngoing = project.status === 'progress' const statusText = useStatusLabel(project.status) const { t, lang } = useLang() // Type guards for backward compatibility const isStatic = 'name' in project; // Resolve localized texts const title = isStatic ? (project.name[lang as 'en' | 'fa'] || project.name.en) : (project as ProjectCardItem).title; const locRaw = isStatic ? project.location : (project as ProjectCardItem).location; const location = typeof locRaw === 'string' ? locRaw : (locRaw?.[lang as 'en' | 'fa'] || locRaw?.en); const areaRaw = isStatic ? project.area : (project as ProjectCardItem).area; const area = typeof areaRaw === 'string' ? areaRaw : (areaRaw?.[lang as 'en' | 'fa'] || areaRaw?.en); const finalImageUrl = imageUrl || (project as ProjectCardItem).image; const finalDetailHref = detailHref || (project as ProjectCardItem).detailHref || '#'; const dotColor = isOngoing ? 'bg-copper animate-pulse' : 'bg-ivory/60' const textColor = isOngoing ? 'text-copper' : 'text-ivory/90' return (
{/* Fixed height image wrapper */}
{finalImageUrl && ( {title} )} {/* نشانگر وضعیت کپسولی شیشه‌ای */}
{statusText}

{title}

{location &&

{location}

}
{area && ( <>
{/* واحد زیربنا در محتوای انگلیسی داخل خود مقدار است — فقط در فارسی اضافه می‌شود */} {lang === 'fa' ? `${area} ${t('sqm')}` : area}
)}
{/* پایهٔ کارت: یک دکمه واحد */}
{t('viewProject')}
) }