/* global React, Icons, FitPaper, CoverFit, makeCoverDoc, SAMPLE_RESUME,
PROFILES, getProfile, profileForTemplate, TEMPLATES, COVER_TEMPLATES, isProTemplate */
// ============================================================
// Gallery — profile-first template picker (résumés + cover letters)
// ============================================================
const ALL_PROFILE = { id: "all", name: "All", icon: "grid", accent: "#e6e600", accent2: "#7deb00" };
// short chip labels (full names stay in the banner)
const CHIP_LABEL = {
all: "All", swe: "Engineering", design: "Design", finance: "Finance",
marketing: "Marketing", sales: "Sales", health: "Healthcare",
data: "Data Science", grad: "New Graduate",
};
function ProfileRail({ profileId, setProfileId, mode }) {
const items = [ALL_PROFILE, ...PROFILES];
return (
{items.map((p) => {
const Ic = Icons[p.icon] || Icons.user;
const on = p.id === profileId;
const total = mode === "covers" ? COVER_TEMPLATES.length : TEMPLATES.length;
const sub = p.id === "all" ? `${total} designs` : `${p.designs.length} designs`;
return (
setProfileId(p.id)}>
{CHIP_LABEL[p.id] || p.name}
{sub}
);
})}
);
}
function Gallery({ mode, setMode, profileId, setProfileId, onPickResume, onPickCover, currentTemplate }) {
const isAll = profileId === "all";
const profile = isAll ? ALL_PROFILE : getProfile(profileId);
const coverDoc = React.useMemo(() => makeCoverDoc(isAll ? "design" : profileId), [profileId, isAll]);
// résumé designs to show + the data each renders with
const resumeList = isAll
? TEMPLATES.map((t) => ({ tid: t.id, data: (profileForTemplate(t.id) || {}).data || SAMPLE_RESUME, pid: (profileForTemplate(t.id) || {}).id || "design" }))
: profile.designs.map((tid) => ({ tid, data: profile.data, pid: profile.id }));
// cover designs to show — each cover matches a résumé, so a profile shows the
// covers paired to its résumé designs (All shows every cover)
const coverList = isAll
? COVER_TEMPLATES
: COVER_TEMPLATES.filter((ct) => profile.designs.includes(ct.match));
const designCount = mode === "covers" ? coverList.length : resumeList.length;
return (
{(() => { const Ic = Icons[profile.icon] || Icons.user; return ; })()}
{isAll ? (mode === "covers" ? "All cover letters" : "All résumé designs") : (profile.name + (mode === "covers" ? " · cover letters" : " résumés"))}
{isAll
? (mode === "covers" ? "Every cover-letter layout in the studio. Pick one and we'll draft it for you." : "Every layout in the studio. Each preview is filled with sample content for its field.")
: profile.blurb}
{designCount} designs
{mode === "resumes" ? (
{resumeList.map(({ tid, data, pid }, i) => {
const t = TEMPLATES.find((x) => x.id === tid) || TEMPLATES[0];
return (
{isProTemplate(tid) &&
PRO}
{currentTemplate === tid &&
In use}
onPickResume(pid, tid)}>
Use this design
{t.name}
{t.tag}
{t.blurb}
{t.swatch.map((c, j) => )}
);
})}
) : (
{coverList.map((ct, i) => (
onPickCover(isAll ? "design" : profile.id, ct.id)}>
Use this design
{ct.name}
{ct.tag}
{ct.blurb}
{ct.swatch.map((c, j) => )}
))}
)}
);
}
window.Gallery = Gallery;