import React, { useState } from 'react'; import { PageHero } from '../components/PageHero'; import { Reveal } from '../components/Reveal'; import { ProjectCard } from '../components/ProjectCard'; import { Gallery } from '../components/home/Gallery'; import { ContactSection } from '../components/ContactSection'; import type { ProjectStatus } from '../data/site'; import { useSite, useStatusLabel } from '../api'; import { useFieldSaver } from '../admin/AdminContext'; import { InlineEdit } from '../components/admin/InlineEdit'; import { AddItemButton, EditableItem } from '../admin/Editable'; export function Projects() { const { projects, status_labels } = useSite(); const save = useFieldSaver(); const saveStatusLabel = (key: string, value: string) => { const label = status_labels.find((s) => s.key === key); if (!label) return; void save('status-labels', label.id, { label: value }, (d) => { const s = d.status_labels.find((x) => x.id === label.id); if (s) s.label = value; }); }; const doneLabel = useStatusLabel('done'); const progressLabel = useStatusLabel('progress'); const FILTERS: {key: ProjectStatus;label: string;}[] = [ { key: 'done', label: doneLabel }, { key: 'progress', label: progressLabel } ]; const [status, setStatus] = useState('done'); const list = projects.filter((p) => p.status === status); return ( <>
{/* دکمه‌های فیلتر مینیمال و شیشه‌ای (وسط‌چین و بدون کادر) */}
{FILTERS.map((filter, index) => { const isSelected = status === filter.key; return ( {/* خط جداکننده بین دکمه‌ها */} {index > 0 && ( ); })}
{list.map((project, i) => ( ))}
); }