import type { Locale } from "@/i18n/config";
import type { Dictionary } from "@/i18n/get-dictionary";
import { routes } from "@/lib/routes";
import { projects } from "@/content/catalog";
import { FilterGrid } from "@/components/shared/filter-grid";
import { PageIntro } from "@/components/shared/page-intro";
import { ProjectCard } from "@/components/shared/project-card";
import { Section } from "@/components/shared/section";

type ProjectsListSectionProps = {
  locale: Locale;
  t: Dictionary["projects"];
  items: Dictionary["catalog"]["projects"];
  categoryLabels: Dictionary["catalog"]["categories"];
};

/** Projects page: title, intro, category chips and all project cards (Figma "Projects", 1440). */
export function ProjectsListSection({ locale, t, items, categoryLabels }: ProjectsListSectionProps) {
  return (
    // Under the fixed header: Figma desktop 100px header + 80px. Phone/tablet: 80px header + 20/40px.
    <Section labelledBy="projects-page-title" className="pt-[100px] md:pt-[120px] lg:pt-[180px]">
      <div className="flex flex-col gap-10">
        <PageIntro id="projects-page-title" title={t.title} lines={t.intro} />
        <FilterGrid
          allLabel={t.all}
          labels={categoryLabels}
          filterLabel={t.filterLabel}
          itemCategories={projects.map((p) => p.categories)}
          // Same grid as the Home projects section: 3 columns on desktop, 2 on tablet, 322px cards on phones.
          listClassName="grid gap-5 md:grid-cols-2 lg:grid-cols-3 lg:gap-10"
          itemClassName="max-md:mx-auto max-md:w-full max-md:max-w-[322px]"
        >
          {projects.map(({ id, slug, image, color, position }) => (
            <ProjectCard key={id} image={image} color={color} position={position} href={routes.project(locale, slug)} {...items[id]} />
          ))}
        </FilterGrid>
      </div>
    </Section>
  );
}
