'use client'; import { useTranslations } from 'next-intl'; import { TimelineSection, TimelineEntry, formatTimelineDate } from './timeline'; import { EditableSection, EditableEntry, PROJECT_FIELDS } from '@/components/profile-editor'; import { projectToValues, valuesToProject } from '@/components/profile-editor/section-converters'; import { sortByDateDesc, dateRangeExtractor } from '@/lib/sort-by-date'; import type { ProfileProject } from '@/lib/types'; interface ProjectsSectionProps { projects: ProfileProject[]; isOwnProfile?: boolean; } export function ProjectsSection({ projects, isOwnProfile }: ProjectsSectionProps) { const t = useTranslations('sections'); if (!projects.length && !isOwnProfile) return null; return ( sectionTitle={t('projects')} profileKey="projects" isOwnProfile={isOwnProfile} fields={PROJECT_FIELDS} toValues={projectToValues} fromValues={ valuesToProject as (v: Record) => Omit } collection="id.sifa.profile.project" maxVisible={3} sortItems={(items) => sortByDateDesc(items, dateRangeExtractor)} renderEntry={(proj, controls) => ( {})} onDelete={controls?.onDelete ?? (() => {})} entryLabel={proj.name} > )} /> ); } function formatProjectDateRange(start?: string, end?: string): string { if (!start && !end) return ''; if (!start) return end ? formatTimelineDate(end) : ''; if (!end) return formatTimelineDate(start); return `${formatTimelineDate(start)} - ${formatTimelineDate(end)}`; }