'use client'; import React from 'react'; import dynamic from 'next/dynamic'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; // Lazy-load TipTap-based editor — keeps it out of the initial bundle. const RichTextEditor = dynamic( () => import('@/components/ui/rich-text-editor').then((m) => m.RichTextEditor), { ssr: false, loading: () => (
), } ); import { Project } from '@/components/dashboard/resume-component'; import { Plus, Trash2, Github, Globe } from 'lucide-react'; import { useTranslations } from '@/lib/i18n'; interface ProjectsFormProps { data: Project[]; onChange: (data: Project[]) => void; } export const ProjectsForm: React.FC = ({ data, onChange }) => { const { t } = useTranslations(); const handleAdd = () => { const newId = Math.max(...data.map((d) => d.id), 0) + 1; onChange([ ...data, { id: newId, name: '', role: '', years: '', github: '', website: '', description: [''], }, ]); }; const handleRemove = (id: number) => { onChange(data.filter((item) => item.id !== id)); }; const handleChange = (id: number, field: keyof Project, value: string | string[]) => { onChange( data.map((item) => { if (item.id === id) { return { ...item, [field]: value }; } return item; }) ); }; const handleDescriptionChange = (id: number, index: number, value: string) => { onChange( data.map((item) => { if (item.id === id) { const newDesc = [...(item.description || [])]; newDesc[index] = value; return { ...item, description: newDesc }; } return item; }) ); }; const handleAddDescription = (id: number) => { onChange( data.map((item) => { if (item.id === id) { return { ...item, description: [...(item.description || []), ''] }; } return item; }) ); }; const handleRemoveDescription = (id: number, index: number) => { onChange( data.map((item) => { if (item.id === id) { const newDesc = [...(item.description || [])]; newDesc.splice(index, 1); return { ...item, description: newDesc }; } return item; }) ); }; return (
{data.map((item) => (
handleChange(item.id, 'name', e.target.value)} placeholder={t('builder.forms.projects.placeholders.projectName')} className="rounded-none border-black bg-white" />
handleChange(item.id, 'role', e.target.value)} placeholder={t('builder.forms.projects.placeholders.role')} className="rounded-none border-black bg-white" />
handleChange(item.id, 'years', e.target.value)} placeholder={t('builder.forms.projects.placeholders.years')} className="rounded-none border-black bg-white" />
handleChange(item.id, 'github', e.target.value)} placeholder={t('builder.forms.projects.placeholders.github')} className="rounded-none border-black bg-white" />
handleChange(item.id, 'website', e.target.value)} placeholder={t('builder.forms.projects.placeholders.website')} className="rounded-none border-black bg-white" />
{item.description?.map((desc, idx) => (
handleDescriptionChange(item.id, idx, html)} placeholder={t('builder.forms.projects.placeholders.description')} minHeight="60px" />
))}
))} {data.length === 0 && (

{t('builder.genericItemForm.noEntries', { label: t('resume.sections.projects') })}

)}
); };