Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9 lines
4.7 KiB
JavaScript
9 lines
4.7 KiB
JavaScript
import"./hoisted.yFz1BYXO.js";const p=window.__PW_API||"",b=new URLSearchParams(window.location.search),d=b.get("token")||sessionStorage.getItem("pw_esign_token")||"";d&&sessionStorage.setItem("pw_esign_token",d);const w=()=>d?{Authorization:`Bearer ${d}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"},i=t=>document.getElementById(t),g=i("loading-overlay"),k=i("main-ui"),L=i("success-screen"),P=i("hdr-entity"),S=i("entity-name-inline"),_=i("entity-name-confirm"),E=i("letter-preview-container"),f=i("letter-loading"),y=i("agree-chk"),l=i("submit-btn"),o=i("status-msg"),n=i("sig-canvas"),R=i("sig-clear"),C=i("sig-hint"),T=i("already-signed-card"),N=i("signed-at-display"),s=n.getContext("2d");let c=!1,u=!1;function h(t){const e=n.getBoundingClientRect(),r=n.width/e.width,a=n.height/e.height,v=t instanceof TouchEvent?t.touches[0]:t;return{x:(v.clientX-e.left)*r,y:(v.clientY-e.top)*a}}function H(){const t=n.getBoundingClientRect();n.width=t.width*devicePixelRatio,n.height=t.height*devicePixelRatio,s.scale(devicePixelRatio,devicePixelRatio),s.strokeStyle="#1e3a5f",s.lineWidth=2.5,s.lineCap="round",s.lineJoin="round"}n.addEventListener("mousedown",t=>{c=!0;const e=h(t);s.beginPath(),s.moveTo(e.x,e.y)});n.addEventListener("mousemove",t=>{if(!c)return;const e=h(t);s.lineTo(e.x,e.y),s.stroke(),x()});n.addEventListener("mouseup",()=>{c=!1});n.addEventListener("mouseleave",()=>{c=!1});n.addEventListener("touchstart",t=>{t.preventDefault(),c=!0;const e=h(t);s.beginPath(),s.moveTo(e.x,e.y)},{passive:!1});n.addEventListener("touchmove",t=>{if(t.preventDefault(),!c)return;const e=h(t);s.lineTo(e.x,e.y),s.stroke(),x()},{passive:!1});n.addEventListener("touchend",()=>{c=!1});function x(){u||(u=!0,n.classList.add("has-sig"),C.textContent="Signature drawn ✓",m())}R.addEventListener("click",()=>{s.clearRect(0,0,n.width/devicePixelRatio,n.height/devicePixelRatio),u=!1,n.classList.remove("has-sig"),C.textContent="Draw your signature above",m()});function m(){l.disabled=!(u&&y.checked)}y.addEventListener("change",m);async function I(){if(!d){g.innerHTML=`<div style="color:#dc2626;font-weight:600">
|
|
Invalid or expired link.<br>
|
|
<span style="font-size:.875rem;font-weight:400;color:#64748b">
|
|
Please use the link from your Performance West email. Links expire after 72 hours.
|
|
</span>
|
|
</div>`;return}try{const t=await fetch(`${p}/api/v1/portal/esign-info`,{headers:w()});if(!t.ok){const a=await t.json().catch(()=>({error:"Request failed"}));g.innerHTML=`<div style="color:#dc2626">${a.error||"Failed to load. Please try the link again."}</div>`;return}const e=await t.json(),r=e.entity_name||e.customer_name;if(P.textContent=`Order ${e.order_number} — ${r}`,S.textContent=r,_.textContent=r,g.style.display="none",k.style.display="block",e.letter_preview_url){f.style.display="none";const a=document.createElement("iframe");a.src=e.letter_preview_url,a.className="letter-frame",a.title="CRTC Notification Letter",a.setAttribute("allowfullscreen",""),E.appendChild(a)}else f.innerHTML=`
|
|
<svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" style="margin-bottom:.5rem"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"/></svg>
|
|
Letter preview unavailable — please continue with signing.
|
|
`;if(e.already_signed&&e.signed_at){T.style.display="block",document.querySelectorAll(".card:not(#already-signed-card)").forEach(a=>a.style.display="none"),N.textContent=new Date(e.signed_at).toLocaleString("en-CA",{dateStyle:"long",timeStyle:"short"});return}H()}catch{g.innerHTML='<div style="color:#dc2626">Network error — please refresh and try again.</div>'}}l.addEventListener("click",async()=>{if(!u){o.textContent="Please draw your signature above.",o.className="err";return}if(!y.checked){o.textContent="Please confirm that you have read the letter.",o.className="err";return}l.disabled=!0,o.textContent="Submitting signature…",o.className="info";const t=n.toDataURL("image/png");try{const e=await fetch(`${p}/api/v1/portal/esign-submit`,{method:"POST",headers:w(),body:JSON.stringify({signature_png:t,agreed:!0})}),r=await e.json();if(!e.ok||!r.success){o.textContent=r.error||"Submission failed. Please try again.",o.className="err",l.disabled=!1;return}k.style.display="none",L.style.display="block",sessionStorage.removeItem("pw_esign_token")}catch{o.textContent="Network error. Please check your connection and try again.",o.className="err",l.disabled=!1}});I();
|