PageSourceSearch

https://www.travelling-technicians.ca/_next/static/chunks/pages/technician/service-orders-bf899f5a21978c75.js

js travelling-technicians.ca collected 2026-10-04 04:56:12 UTC 14,687 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[947],{58679:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/technician/service-orders",function(){return r(77279)}])},95030:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]])},47782:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},23973:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},77098:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]])},41138:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]])},9633:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},114:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},6479:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]])},95239:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]])},36460:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},49801:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]])},42540:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]])},17911:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},32330:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]])},22972:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(33592).Z)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
1],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},77279:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return g}});var a=r(85893),n=r(67294),l=r(11163),s=r(41664),i=r.n(s),o=r(62303),c=r(80056),u=r(1555),d=r(114),h=r(49801),m=r(36460),y=r(9633),p=r(47782),x=r(23973),f=r(64712);let b=[{value:"open",label:"Open"},{value:"paid",label:"Paid"},{value:"all",label:"All"}];function g(){let e=(0,l.useRouter)(),t="string"==typeof e.query.booking?e.query.booking:null,[r,s]=(0,n.useState)("loading"),[g,v]=(0,n.useState)([]),[k,w]=(0,n.useState)("open"),[N,j]=(0,n.useState)(!1),[Z,C]=(0,n.useState)(!1),[M,E]=(0,n.useState)({customerName:"",customerEmail:"",customerPhone:"",deviceNote:"",warrantyDays:"",partsUsedInternal:""}),[S,_]=(0,n.useState)(""),P=(0,n.useCallback)(async()=>{try{let e=await (0,c.Cg)("/api/technician/service-orders"),t=await e.json().catch(()=>({}));if(404===e.status&&(null==t?void 0:t.code)==="GATE_OFF"){s("off");return}if(!e.ok)throw Error(t.error||"Could not load your bills");v(t.orders||[]),s("on")}catch(e){f.Am.error(e instanceof Error?e.message:"Could not load your bills"),s("on")}},[]);(0,n.useEffect)(()=>{P()},[P]),(0,n.useEffect)(()=>{t&&j(!0)},[t]),(0,n.useEffect)(()=>{N&&!S&&_((0,u.A8)())},[N,S]);let D=(0,n.useMemo)(()=>g.filter(e=>"all"===k||("paid"===k?"paid"===e.status:"paid"!==e.status&&"cancelled"!==e.status)),[g,k]);async function A(r){r.preventDefault(),C(!0);try{var a,n;let r={idempotencyKey:S,deviceNote:M.deviceNote||null,partsUsedInternal:M.partsUsedInternal||null,warrantyDays:""===M.warrantyDays?null:Number(M.warrantyDays)};M.customerName&&(r.customerName=M.customerName),M.customerEmail&&(r.customerEmail=M.customerEmail),M.customerPhone&&(r.customerPhone=M.customerPhone),t&&(r.bookingId=t);let l=await (0,c.Cg)("/api/technician/service-orders",{method:"POST",body:JSON.stringify(r)}),s=await l.json().catch(()=>({}));if(!l.ok)throw Error(s.error||((null===(n=s.details)||void 0===n?void 0:null===(a=n[0])||void 0===a?void 0:a.message)?"".concat(s.details[0].path,": ").concat(s.details[0].message):"Could not create the bill"));f.Am.success(s.deduped?"Opening your existing bill":"Bill created"),e.push("/technician/service-orders/".concat(s.order.id))}catch(e){f.Am.error(e instanceof Error?e.message:"Could not create the bill")}finally{C(!1)}}return(0,a.jsx)(o.Z,{title:"Bills",headerTitle:"Bills",children:(0,a.jsx)("div",{className:"px-4 py-4 space-y-4",children:"loading"===r?(0,a.jsx)("div",{className:"flex justify-center py-12",children:(0,a.jsx)(d.Z,{className:"h-6 w-6 animate-spin text-primary-600"})}):"off"===r?(0,a.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-5 text-center",children:[(0,a.jsx)(h.Z,{className:"h-10 w-10 mx-auto text-gray-300 mb-2"}),(0,a.jsx)("p",{className:"font-semibold text-gray-900",children:"Bills aren't switched on yet"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"The office turns this on from site settings. Until then, complete jobs and send payment links from the job page as usual."}),(0,a.jsx)(i(),{href:"/technician",className:"inline-block mt-4 text-sm font-medium text-primary-600 underline",children:"Back to home"})]}):(0,a.jsxs)(a.Fragment,{children:[N?(0,a.jsxs)("form",{onSubmit:A,className:"bg-white rounded-xl border border-gray-200 p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"font-semibold text-gray-900",children:"New bill"}),(0,a.jsx)("button",{type:"button",onClick:()=>{j(!1),t&&e.replace("/technician/service-orders")},className:"text-sm text-gray-500",children:"Cancel"})]}),t?(0,a.jsxs)("p",{className:"text-xs text-blue-800 bg-blue-50 border border-blue-200 rounded-lg px-3 py-2 flex items-start gap-2",children:[(0,a.jsx)(y.Z,{className:"h-4 w-4 flex-none mt-0.5"}),"Linked to the job you came from. Leave a field blank to copy it from the booking. The bill never changes the booking's price."]}):null,(0,a.jsx)("input",{value:M.customerName,onChange:e=>E({...M,customerName:e.target.value}),placeholder:t?"Customer name (from booking if blank)":"Customer name",required:!t,className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,a.jsx)("input",{type:"email",value:M.customerEmail,onChange:e=>E({...M,customerEmail:e.target.value}),placeholder:"Email (needed for a payment link / warranty)",className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,a.jsx)("input",{value:M.customerPhone,onChange:e=>E({...M,customerPhone:e.target.value}),placeholder:"Phone (for referral codes / WhatsApp)",className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,a.jsx)("input",{value:M.deviceNote,onChange:e=>E({...M,deviceNote:e.target.value}),placeholder:"Device, e.g. iPhone 13 Pro",className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,a.jsx)("select",{value:M.warrantyDays,onChange:e=>E({...M,warrantyDays:e.target.value}),className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm",children:u.HC.map(e=>(0,a.jsx)("option",{value:null==e.value?"":String(e.value),children:e.label},String(e.value)))}),(0,a.jsx)("textarea",{value:M.partsUsedInternal,onChange:e=>E({...M,partsUsedInternal:e.target.value}),placeholder:"Parts used (internal note — not shown to the customer; keep costs/SKUs out)",rows:2,className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,a.jsxs)("button",{type:"submit",disabled:Z,className:"w-full py-3 bg-primary-600 text-white font-semibold rounded-xl text-sm hover:bg-primary-700 disabled:opacity-50 flex items-center justify-center gap-2",children:[Z?(0,a.jsx)(d.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(m.Z,{className:"h-4 w-4"})," Create & add lines"]})]}):(0,a.jsxs)("button",{type:"button",onClick:()=>j(!0),className:"w-full py-3 bg-accent-500 text-primary-900 font-bold rounded-xl text-sm hover:bg-accent-400 flex items-center justify-center gap-2",children:[(0,a.jsx)(m.Z,{className:"h-4 w-4"})," New bill"]}),(0,a.jsx)("div",{className:"flex gap-2",children:b.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>w(e.value),className:"px-3 py-1.5 rounded-full text-xs font-medium ".concat(k===e.value?"bg-primary-600 text-white":"bg-white border border-gray-300 text-gray-700"),children:e.label},e.value))}),0===D.length?(0,a.jsxs)("div",{className:"text-center py-10 text-gray-500",children:[(0,a.jsx)(h.Z,{className:"h-10 w-10 mx-auto text-gray-300 mb-2"}),(0,a.jsxs)("p",{className:"text-sm",children:["No ","all"===k?"":k," bills yet."]})]}):(0,a.jsx)("ul",{className:"space-y-2",children:D.map(t=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onClick:()=>e.push("/technician/service-orders/".concat(t.id)),className:"w-full bg-white border border-gray-100 shadow-sm rounded-xl p-4 flex items-center gap-3 text-left hover:border-accent-300 active:bg-gray-50",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs text-gray-500",children:t.order_ref}),(0,a.jsx)("span",{className:"text-[11px] px-2 py-0.5 rounded-full font-medium ".concat(u.pw[t.status]),children:u.e3[t.status]})]}),(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-900 truncate",children:t.customer_name}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 truncate",children:[t.device_note||"—"," \xb7 ",(0,u.Zh)(t.created_at)]})]}),(0,a.jsx)("div",{className:"text-right flex-none",children:(0,a.jsx)("p",{className:"text-sm font-semibold tabular-nums text-gray-900",children:null!=t.total_amount?(0,u.CZ)(t.total_amount):"—"})}),(0,a.jsx)(p.Z,{className:"h-4 w-4 text-gray-400 flex-none"})]})},t.id))}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 flex items-start gap-1.5",children:[(0,a.jsx)(x.Z,{className:"h-3.5 w-3.5 mt-0.5 flex-none"})," Cash or e-transfer you collect on a bill is settled with the office by hand for now."]})]})})})}},1555:function(e,t,r){"use strict";r.d(t,{A8:function(){return h},CZ:function(){return o},HC:function(){return i},PH:function(){return u},Zh:function(){return d},_h:function(){return c},e3:function(){return a},j$:function(){return s},ks:function(){return l},pw:function(){return n}});let a={draft:"Draft",sent:"Link sent",expired:"Link expired",paid:"Paid",cancelled:"Cancelled"},n={draft:"bg-gray-100 text-gray-800",sent:"bg-yellow-100 text-yellow-800",expired:"bg-orange-100 text-orange-800",paid:"bg-green-100 text-green-800",cancelled:"bg-red-100 text-red-800"},l=[{value:"service",label:"Service",hint:"A fixed-price repair or job, e.g. screen replacement",negative:!1},{value:"labour",label:"Labour",hint:"Time billed at the door or on the bench (use quantity for hours)",negative:!1},{value:"part",label:"Part",hint:"A component billed to the customer",negative:!1},{value:"credit",label:"Credit",hint:"Money already paid that applies to this bill (e.g. a visit fee)",negative:!0},{value:"discount",label:"Discount",hint:"A goodwill or promotional reduction",negative:!0}],s={service:"Service",labour:"Labour",part:"Part",discount:"Discount",credit:"Credit"},i=[{value:null,label:"No warranty"},{value:90,label:"90 days"},{value:120,label:"120 days"},{value:365,label:"12 months"}];function o(e){let t="number"==typeof e?e:parseFloat(String(null!=e?e:""));if(!Number.isFinite(t))return"—";let r=Math.abs(t);return r<.005?"$0.00":"".concat(t<0?"−":"","$").concat(r.toFixed(2))}function c(e,t){let r=e.trim();return!("discount"===t||"credit"===t)||!r||r.startsWith("-")||r.startsWith("−")?r.replace(/^−/,"-"):"-".concat(r)}function u(e,t){let r="draft"===e||"expired"===e;return{editLines:r,editDetails:r,editPartsNote:"cancelled"!==e,send:r,recordCash:r||"sent"===e,revokeLink:"sent"===e&&t.hasLink,cancel:r||"sent"===e,reconcile:t.admin&&"sent"===e&&t.hasLink,reassign:t.admin&&"cancelled"!==e,referral:r}}function d(e){if(!e)return"—";let t=new Date(10===e.length?"".concat(e,"T00:00:00Z"):e);return Number.isNaN(t.getTime())?"—":t.toLocaleDateString("en-CA",{timeZone:10===e.length?"UTC":"America/Vancouver",month:"short",day:"numeric",year:"numeric"})}function h(){try{let e=globalThis.crypto;if(e&&"function"==typeof e.randomUUID)return e.randomUUID()}catch(e){}return"so-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10),"-").concat(Math.random().toString(36).slice(2,10))}}},function(e){e.O(0,[2840,6444,2303,2888,9774,179],function(){return e(e.s=58679)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.