import { useEffect, useState } from "react"; import { api, type Resume } from "../../lib/api"; export function AdminResume() { const [form, setForm] = useState({ fullName: "", title: "", email: "", phone: "", location: "", website: "", summary: "", sectionsJson: "[]", htmlContent: "", }); const [msg, setMsg] = useState(null); const [err, setErr] = useState(null); useEffect(() => { api.adminResume().then((r) => { if (!r) return; setForm({ fullName: r.fullName, title: r.title || "", email: r.email || "", phone: r.phone || "", location: r.location || "", website: r.website || "", summary: r.summary || "", sectionsJson: JSON.stringify(r.sections ?? [], null, 2), htmlContent: r.htmlContent || "", }); }); }, []); async function save(e: React.FormEvent) { e.preventDefault(); setErr(null); setMsg(null); let sections: unknown = []; try { sections = JSON.parse(form.sectionsJson || "[]"); } catch { setErr("Sections JSON is invalid"); return; } try { await api.saveResume({ fullName: form.fullName, title: form.title, email: form.email || null, phone: form.phone || null, location: form.location || null, website: form.website || null, summary: form.summary, sections, htmlContent: form.htmlContent || null, }); setMsg("Resume saved"); } catch (e) { setErr((e as Error).message); } } return (

Resume

Public at /resume ยท PDF at{" "} /api/v1/resume/pdf

{msg &&
{msg}
} {err &&
{err}
}
setForm({ ...form, fullName: e.target.value })} />
setForm({ ...form, title: e.target.value })} />
setForm({ ...form, email: e.target.value })} />
setForm({ ...form, phone: e.target.value })} />
setForm({ ...form, location: e.target.value })} />
setForm({ ...form, website: e.target.value })} />