${fmtDate(s.soldAt)} · ${s.salePrice?money.format(s.salePrice):"Price not recorded"}
From 0be4d8377db1cfa0a3babd3463437ed35b2ad21f Mon Sep 17 00:00:00 2001 From: mfwadejr <125498560+mfwadejr@users.noreply.github.com> Date: Sat, 29 Aug 2026 16:01:47 -0400 Subject: [PATCH] Add customer support notes timeline --- public/app.js | 9 ++++++--- public/extras.css | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/app.js b/public/app.js index 28e7557..6bcd8ca 100644 --- a/public/app.js +++ b/public/app.js @@ -4,6 +4,7 @@ const PAGE_SIZE = 10; const money = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }); const today = () => new Date().toISOString().slice(0, 10); const fmtDate = (v) => v ? new Date(`${v}T12:00:00`).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : "—"; +const fmtDateTime = (v) => v ? new Date(`${v.replace(" ","T")}Z`).toLocaleString("en-US", { year:"numeric", month:"short", day:"numeric", hour:"numeric", minute:"2-digit" }) : "—"; const esc = (v = "") => String(v).replace(/[&<>'"]/g, c => ({ "&":"&", "<":"<", ">":">", "'":"'", '"':""" })[c]); const ids = p => [["UID",p.uid],["SN",p.sn],["MAC",p.mac]].filter(([,v]) => v); const primaryId = p => ids(p)[0]?.[1] || "No identifier"; @@ -59,20 +60,22 @@ function receiveForm() { } function sellForm(id="") { const available=state.products.filter(p=>p.status==="available"); - openModal(`
Enter the customer, payment, and shipped-to details.
`); + openModal(`Enter the customer, payment, and shipped-to details.
`); $("#sellForm").onsubmit=async e=>{ e.preventDefault(); const data=Object.fromEntries(new FormData(e.currentTarget)), productId=data.productId; delete data.productId; await change(`/api/products/${encodeURIComponent(productId)}/sell`,"POST",data,"Sale recorded."); }; $("[data-cancel]").onclick=closeModal; } async function submitForm(e,path,message,method="POST"){ e.preventDefault(); await change(path,method,Object.fromEntries(new FormData(e.currentTarget)),message); } async function change(path,method,body,message){ try{ await api(path,{method,body:body?JSON.stringify(body):undefined}); closeModal(); await load(); toast(message); }catch(e){ toast(e.message); } } function viewSale(p) { - openModal(`${esc(p.model)} · ${fmtDate(p.soldAt)}
${esc(p.customerName||"Unknown")}
${esc(p.phone||"No phone recorded")}
${esc(p.paymentMethod||"Not recorded")}
${p.paymentReference?`Reference: ${esc(p.paymentReference)}
`:""}${address(p)?esc(address(p)):"No shipping address recorded"}
${p.shippingNotes?`${esc(p.shippingNotes)}
`:""}${esc(p.manufacturer)} ${esc(p.model)} · ${esc(p.condition)}
Received: ${fmtDate(p.receivedAt)} · Sold: ${fmtDate(p.soldAt)}
Cost: ${p.cost?money.format(p.cost):"—"} · Sale price: ${p.salePrice?money.format(p.salePrice):"—"}
${p.notes?`Inventory notes: ${esc(p.notes)}
`:""}${esc(p.model)} · ${fmtDate(p.soldAt)}
${esc(p.customerName||"Unknown")}
${esc(p.phone||"No phone recorded")}
${esc(p.paymentMethod||"Not recorded")}
${p.paymentReference?`Reference: ${esc(p.paymentReference)}
`:""}${address(p)?esc(address(p)):"No shipping address recorded"}
${p.shippingNotes?`${esc(p.shippingNotes)}
`:""}${esc(p.manufacturer)} ${esc(p.model)} · ${esc(p.condition)}
Received: ${fmtDate(p.receivedAt)} · Sold: ${fmtDate(p.soldAt)}
Cost: ${p.cost?money.format(p.cost):"—"} · Sale price: ${p.salePrice?money.format(p.salePrice):"—"}
${p.notes?`Inventory notes: ${esc(p.notes)}
`:""}Customer record and complete purchase history.
${esc(c.phone||"No phone recorded")}
${addr?esc(addr):"No shipping address recorded"}
${c.shippingNotes?`${esc(c.shippingNotes)}
`:""}${fmtDate(s.soldAt)} · ${s.salePrice?money.format(s.salePrice):"Price not recorded"}
Customer record, support notes, and purchase history.
${esc(c.phone||"No phone recorded")}
${addr?esc(addr):"No shipping address recorded"}
${c.shippingNotes?`${esc(c.shippingNotes)}
`:""}${esc(n.note)}
No customer notes yet.
"}${fmtDate(s.soldAt)} · ${s.salePrice?money.format(s.salePrice):"Price not recorded"}
Return ${esc(p.model)} to inventory.
`); $("[data-cancel]").onclick=closeModal; $("#restockForm").onsubmit=e=>submitForm(e,`/api/products/${encodeURIComponent(p.id)}/restock`,"Product restocked."); } diff --git a/public/extras.css b/public/extras.css index ce025e6..40b2bfb 100644 --- a/public/extras.css +++ b/public/extras.css @@ -1,3 +1,4 @@ .customer-link{background:transparent!important;color:#1d4ed8!important;padding:0!important;text-align:left}.customer-link:hover{text-decoration:underline} #pagination{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;color:#68758b;font-size:13px;border-top:1px solid #edf0f5}#pagination div{display:flex;gap:8px}#pagination button{background:#fff;border:1px solid #d7deea;padding:7px 11px}#pagination button:disabled{opacity:.4;cursor:default} .address-grid{display:grid;grid-template-columns:2fr 1fr 1fr;gap:10px}.detail-card{background:#f7f9fc;border:1px solid #e2e7ef;border-radius:10px;padding:14px;margin:14px 0}.detail-card h3,.customer-purchases h3{margin:0 0 10px}.detail-card p{margin:4px 0!important}.customer-purchases{max-height:330px;overflow:auto}.customer-purchases article{border-top:1px solid #e5e9f0;padding:12px 0}.customer-purchases article:first-child{border-top:0}.customer-purchases button{padding:6px 9px;background:#edf3ff;color:#1d4ed8}@media(max-width:760px){.address-grid{grid-template-columns:1fr}#pagination{align-items:flex-start;flex-direction:column}#pagination>div{width:100%;align-items:center;justify-content:space-between}} +.customer-notes{margin:18px 0}.customer-notes h3{margin-bottom:8px}.customer-notes article{position:relative;border:1px solid #e2e7ef;border-radius:9px;padding:12px;margin:8px 0}.customer-notes article>div{display:flex;align-items:center;gap:8px;color:#667085}.customer-notes article p{white-space:pre-wrap;margin:10px 0}.customer-notes article>button{position:absolute;right:8px;top:8px;padding:5px 8px;background:#fff0f0;color:#c62828}.note-category{background:#edf3ff;color:#1d4ed8;border-radius:99px;padding:3px 8px;font-size:12px;font-weight:700}