import { useState } from 'react';
const CAREER_CATEGORIES = { company: '회사', education: '교육', etc: '기타' };
const SKILL_CATEGORIES = { language: '언어', framework: '프레임워크', infra: '인프라', tool: '도구' };
const emptyCareer = { category: 'company', organization: '', role: '', description: '', start_date: '', end_date: '', sort_order: 0 };
const emptySkill = { category: 'language', name: '', level: 3, sort_order: 0 };
const SKILL_LOGO_SLUGS = {
Python: 'python',
JavaScript: 'javascript',
SQL: 'mysql',
'HTML/CSS': 'html5',
FastAPI: 'fastapi',
React: 'react',
Vite: 'vite',
Docker: 'docker',
'Synology NAS': 'synology',
Nginx: 'nginx',
Gitea: 'gitea',
SQLite: 'sqlite',
Linux: 'linux',
Git: 'git',
'Claude API': 'anthropic',
Ollama: 'ollama',
'Suno API': 'suno',
};
function SkillLogoNode({ name, slug }) {
const [error, setError] = useState(false);
if (!slug || error) {
return {name};
}
return (
setError(true)}
/>
);
}
export default function ProfileTab({ data, editing, api, onRefresh }) {
const { profile, careers, skills } = data;
const [editingProfile, setEditingProfile] = useState(null);
const [careerForm, setCareerForm] = useState(null);
const [skillForm, setSkillForm] = useState(null);
// ── Profile 편집 ──
const startEditProfile = () => setEditingProfile({ ...profile });
const saveProfileEdit = async () => {
await api.saveProfile(editingProfile);
setEditingProfile(null);
onRefresh();
};
// ── Career CRUD ──
const saveCareer = async () => {
if (careerForm.id) {
await api.editCareer(careerForm.id, careerForm);
} else {
await api.addCareer(careerForm);
}
setCareerForm(null);
onRefresh();
};
const deleteCareer = async (id) => {
await api.removeCareer(id);
onRefresh();
};
// ── Skill CRUD ──
const saveSkill = async () => {
if (skillForm.id) {
await api.editSkill(skillForm.id, skillForm);
} else {
await api.addSkill(skillForm);
}
setSkillForm(null);
onRefresh();
};
const deleteSkill = async (id) => {
await api.removeSkill(id);
onRefresh();
};
const grouped = (items, catMap) => {
const groups = {};
for (const key of Object.keys(catMap)) groups[key] = [];
for (const item of items) {
const cat = item.category || Object.keys(catMap)[0];
if (!groups[cat]) groups[cat] = [];
groups[cat].push(item);
}
return groups;
};
return (
{profile.name_en}
}{profile.role || profile.role_en}
{profile.bio}
} {editing && } > )}{c.description}
} {editing && (