Sent to PunchList ${esc(fmtTs(pp.sentAt))} — project created with a starter list of ${pp.issueCount} scope issues. Open PunchList with this same account to work it.
Turn this accepted quote into a PunchList project: the project is created under this same account, with a starter list whose issues are this quote's scope lines.
`}
`;
const send = async () => {
const note = $("#punchNote"); note.textContent = "Sending to PunchList…";
try {
const lines = (est.lines || []).filter((ln) => ln.kind !== "adjust")
.map((ln) => ({ text: `${num(ln.qty)} × ${ln.name}`, note: ln.note || "" }));
const r = await fetch("https://punchlist.oisinteriorinstallation.com/api/integrations/project-from-quote", {
method: "POST", credentials: "include", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ quoteId: est.id, quoteNumber: est.number, clientName: est.clientName,
clientCompany: est.clientCompany, projectName: est.projectName || est.clientCompany || "New Project",
address: est.address, companyName: S.settings.companyName, startDate: est.dateISO, lines }) });
const b = await r.json().catch(() => ({}));
if (!r.ok || !b.ok) throw new Error(b.error || ("PunchList answered " + r.status));
est.punchProject = { projectId: b.projectId, listId: b.listId, issueCount: b.issueCount, sentAt: Date.now() };
touchEst(est, b.already ? "Sent to PunchList again — project already existed, no duplicates" :
"Sent to PunchList — project + starter list created (" + b.issueCount + " issues)");
toast(b.already ? "Already in PunchList — no duplicates." : "Project created in PunchList.");
render();
} catch (e) {
note.textContent = "Couldn't reach PunchList: " + e.message + " — check your connection and try again.";
}
};
const b1 = $("#punchSend"); if (b1) b1.addEventListener("click", send);
const b2 = $("#punchAgain"); if (b2) b2.addEventListener("click", send);
}