/* cold-email.jsx — Cold email / cover note generator */ const EMAIL_TONES = [ { id:"professional", label:"Professional", desc:"Formal, polished" }, { id:"confident", label:"Confident", desc:"Direct, assertive" }, { id:"friendly", label:"Friendly", desc:"Warm, approachable" }, ]; const EMAIL_TYPES = [ { id:"outreach", label:"Cold outreach", desc:"Reach out to recruiter / hiring manager directly" }, { id:"apply", label:"Application note", desc:"Short email when submitting application" }, { id:"followup", label:"Follow-up", desc:"After no response for 1–2 weeks" }, ]; function ColdEmailDrawer({ data, onClose }) { const { useState: S, useEffect: E } = React; const [jobText, setJobText] = S(""); const [tone, setTone] = S("professional"); const [type, setType] = S("outreach"); const [stage, setStage] = S("idle"); const [email, setEmail] = S(""); const [copied, setCopied] = S(false); const [errMsg, setErrMsg] = S(""); const [limitHit, setLimitHit] = S(false); E(() => { const onKey = e => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, []); const generate = async () => { if (!window.groqStream) { setErrMsg("AI not available."); setStage("error"); return; } if (!jobText.trim()) { setErrMsg("Paste a job posting or job description first."); return; } setStage("loading"); setEmail(""); setErrMsg(""); const ctx = window.buildResumeCtx ? window.buildResumeCtx(data) : ""; const toneLabel = EMAIL_TONES.find(t => t.id === tone)?.label || "Professional"; const typeLabel = EMAIL_TYPES.find(t => t.id === type)?.label || "Cold outreach"; await window.groqStream({ messages: [ { role: "system", content: window.GROQ_SYSTEM || "" }, { role: "user", content: `Write a ${toneLabel.toLowerCase()} ${typeLabel.toLowerCase()} email for a job application. Type: ${typeLabel} Tone: ${toneLabel} Rules: - EXACTLY 3 short paragraphs (2-3 sentences each) - Paragraph 1: Who you are + strongest relevant credential from resume - Paragraph 2: Why THIS specific role/company (use details from job posting) - Paragraph 3: Clear call to action (request a call / meeting) - No subject line — just the email body - No generic phrases like "I hope this email finds you well" - No "I am writing to express my interest" - Strong verbs, specific numbers from resume where relevant - End with candidate's name: ${data.basics?.name || "[Your Name]"} Candidate resume context: ${ctx.slice(0, 2000)} Job posting: ${jobText.slice(0, 2000)}` }, ], maxTokens: 600, onChunk: (_, full) => { setEmail(full); setStage("streaming"); }, onDone: (full) => { setEmail(full); setStage("done"); }, onError: e => { if (e === "free_limit_reached") { setLimitHit(true); } else { setErrMsg(typeof e==="string"?e:"AI error."); } setStage("error"); }, }); }; const copy = () => { navigator.clipboard?.writeText(email).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2200); }); }; return ( <>

Cold Email Generator

3-paragraph outreach from resume + job posting

{/* Email type */}
{EMAIL_TYPES.map(t => ( ))}
{/* Tone */}
{EMAIL_TONES.map(t => ( ))}
{/* Job posting input */}