import { useState } from 'react'; const CATEGORIES = [ { key: 'all', label: '전체' }, { key: 'company', label: '회사' }, { key: 'personal', label: '개인' }, { key: 'academy', label: '아카데미' }, ]; const emptyProject = { category: 'personal', title: '', description: '', tech_stack: [], role: '', start_date: '', end_date: '', url: '', image_url: '', sort_order: 0, }; export default function ProjectTab({ projects, editing, api, onRefresh }) { const [filter, setFilter] = useState('all'); const [form, setForm] = useState(null); const [techInput, setTechInput] = useState(''); const filtered = filter === 'all' ? projects : projects.filter(p => p.category === filter); const addTech = () => { const tag = techInput.trim(); if (tag && !form.tech_stack.includes(tag)) { setForm(f => ({ ...f, tech_stack: [...f.tech_stack, tag] })); } setTechInput(''); }; const removeTech = (tag) => { setForm(f => ({ ...f, tech_stack: f.tech_stack.filter(t => t !== tag) })); }; const save = async () => { if (form.id) { await api.editProject(form.id, form); } else { await api.addProject(form); } setForm(null); setTechInput(''); onRefresh(); }; const remove = async (id) => { await api.removeProject(id); onRefresh(); }; return (
{/* 카테고리 필터 */}
{CATEGORIES.map(c => ( ))} {editing && }
{/* 추가/수정 폼 */} {form && (