PageSourceSearch

https://saar-seva-app.saarbazaar.workers.dev/assets/SerialLookup-aiuQhy00.js

js saar-seva-app.saarbazaar.workers.dev collected 2026-10-03 08:10:34 UTC 11,370 bytes, 4 lines download raw bytes

1import{r as d,j as e,B as k,y,z as C,f as p,P as S}from"./index-BsRJbbzd.js";function L({lookup:t=y.serialLookup,qcRunPdf:n=y.qcRunPdfBlob,qcDevicePdf:a=y.qcDevicePdfBlob}){const[l,i]=d.useState(""),[s,r]=d.useState(!1),[b,m]=d.useState(""),[h,g]=d.useState(null),[f,c]=d.useState(!1),j=async o=>{if(o){r(!0),m(""),g(null);try{g(await t(o))}catch(N){m(N.detail||N.message||"Lookup failed.")}finally{r(!1)}}},u=o=>{o==null||o.preventDefault(),j(l.trim())},v=o=>{const N=C(o);c(!1),i(N),j(N)};return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl mx-auto",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-slate-900",children:"Serial lookup"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Where a device is, and which document is holding it. Search by serial / IMEI — not by model name."})]}),e.jsxs("form",{onSubmit:u,className:"flex gap-2",children:[e.jsx("input",{value:l,onChange:o=>i(o.target.value),placeholder:"Serial / IMEI",inputMode:"numeric",autoFocus:!0,className:`min-w-0 flex-1 rounded-lg border border-slate-300 px-3 py-2 text-sm
2                     focus:outline-none focus:ring-2 focus:ring-slate-900/10`}),e.jsx("button",{type:"button",onClick:()=>c(!0),className:`shrink-0 rounded-lg border border-slate-300 px-3 py-2
3                     text-sm font-semibold text-slate-700`,children:"Scan"}),e.jsx("button",{type:"submit",disabled:s||!l.trim(),className:`shrink-0 rounded-lg bg-slate-900 px-4 py-2 text-sm
4                     font-medium text-white disabled:opacity-40`,children:s?"…":"Find"})]}),f&&e.jsx(k,{onScan:v,onClose:()=>c(!1)}),b&&e.jsx("p",{className:"rounded-lg bg-rose-50 px-3 py-2 text-sm text-rose-700",children:b}),h&&e.jsx(w,{data:h,qcRunPdf:n,qcDevicePdf:a})]})}function w({data:t,qcRunPdf:n,qcDevicePdf:a}){if(!t.odoo_ok)return e.jsxs("div",{className:"rounded-lg border border-amber-300 bg-amber-50 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Couldn't reach Odoo"}),e.jsx("p",{className:"mt-1 text-xs text-amber-800",children:t.summary})]});if(!t.found)return e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:t.summary}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Check for a typo, or the device may never have been received into Odoo."}),e.jsx(_,{qc:t.qc,serial:t.serial,qcRunPdf:n,qcDevicePdf:a})]});const l=t.held_by||[],i=l.length?"border-amber-300 bg-amber-50 text-amber-900":"border-emerald-300 bg-emerald-50 text-emerald-900";return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:`rounded-lg border p-3 ${i}`,children:e.jsx("p",{className:"text-sm font-medium",children:t.summary})}),e.jsx(R,{service:t.service}),e.jsx(_,{qc:t.qc,serial:t.serial,qcRunPdf:n,qcDevicePdf:a}),e.jsx(x,{title:"Device",children:(t.lots||[]).map(s=>e.jsxs("div",{className:"text-sm text-slate-700",children:[e.jsx("p",{className:"font-medium",children:s.product_name||"—"}),e.jsxs("p",{className:"text-xs text-slate-500",children:["Serial ",t.serial," · lot #",s.lot_id,s.company_name?` · ${s.company_name}`:" · no company set",s.created_at?` · added ${p(s.created_at)}`:""]})]},s.lot_id))}),e.jsxs(x,{title:"Held by",empty:!l.length&&"Nothing is holding it.",children:[l.map((s,r)=>e.jsxs("div",{className:"text-sm text-slate-700",children:[e.jsxs("p",{className:"font-medium",children:[s.document,s.picking_state?e.jsx("span",{className:"ml-2 rounded bg-slate-100 px-1.5 py-0.5 text-[11px] font-normal text-slate-600",children:s.picking_state}):null]}),e.jsxs("p",{className:"text-xs text-slate-500",children:[s.operation||"—",s.origin?` · ${s.origin}`:"",s.partner_name?` · ${s.partner_name}`:""]}),e.jsxs("p",{className:"text-xs text-slate-500",children:[s.source," → ",s.destination,s.scheduled_date?` · scheduled ${p(s.scheduled_date)}`:""]})]},r)),l.length>0&&e.jsx("p",{className:"text-xs text-slate-500",children:"To free it, unreserve or cancel that document — a hold belongs to the document, not to the stock screen."})]}),e.jsx(x,{title:"In stock",empty:!(t.on_hand||[]).length&&"Not in any internal location — it has left stock.",children:(t.on_hand||[]).map((s,r)=>e.jsxs("div",{className:"flex items-baseline justify-between text-sm",children:[e.jsx("span",{className:"text-slate-700",children:s.location_name}),e.jsxs("span",{className:"text-xs text-slate-500",children:["qty ",s.qty,s.reserved?` · ${s.reserved} reserved`:" · free"]})]},r))}),(t.virtual||[]).length>0&&e.jsxs(x,{title:"Other ledger entries",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Non-stock locations. A negative Vendors line usually means the same serial was received t
4wice — it isn't physical stock."}),t.virtual.map((s,r)=>e.jsxs("div",{className:"flex items-baseline justify-between text-sm",children:[e.jsx("span",{className:"text-slate-700",children:s.location_name}),e.jsxs("span",{className:"text-xs text-slate-500",children:["qty ",s.qty]})]},r))]}),e.jsx(x,{title:"History",empty:!(t.history||[]).length&&"No movements.",children:(t.history||[]).map((s,r)=>e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-700",children:s.reference}),e.jsxs("p",{className:"text-xs text-slate-500",children:[p(s.date)," · ",s.source," → ",s.destination]})]},r))})]})}const $={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",partial:"bg-amber-100 text-amber-800"};function _({qc:t,serial:n,qcRunPdf:a,qcDevicePdf:l}){const[i,s]=d.useState(""),[r,b]=d.useState("");if(!t)return null;const[m,h]=d.useState(null),g=async f=>{s(f+"-save"),b("");try{const c=f==="run"?await a(t.run_id):await l(n),j=URL.createObjectURL(c),u=document.createElement("a");u.href=j,u.download=f==="run"?`SAAR-QC-${n}-run${t.run_no}.pdf`:`SAAR-QC-history-${n}.pdf`,document.body.appendChild(u),u.click(),u.remove(),setTimeout(()=>URL.revokeObjectURL(j),6e4)}catch(c){b(c.detail||c.message||"Couldn't download the report.")}finally{s("")}};return t.checked===!1?e.jsx(x,{title:"QC",children:e.jsx("p",{className:"text-sm text-amber-800",children:"Couldn't check whether this device has been QC tested. That is not the same as it having no test."})}):t.run_id?e.jsxs(x,{title:"QC",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.result&&e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase ${$[t.result]||"bg-slate-100 text-slate-700"}`,children:t.result}),e.jsxs("span",{className:"text-sm text-slate-700",children:["Run ",t.run_no,t.stage?` · ${t.stage.replace(/_/g," ")}`:""]}),e.jsxs("span",{className:"text-xs text-slate-500",children:[t.tested_at?p(t.tested_at):"no date recorded",t.operator?` · ${t.operator}`:""]})]}),e.jsx(Q,{qc:t}),e.jsx(A,{qc:t}),t.can_open?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>h("run"),className:"text-sm font-medium text-brand-900 hover:underline",children:"Open the latest QC report"}),e.jsx("button",{type:"button",onClick:()=>g("run"),disabled:!!i,className:"text-xs text-slate-600 hover:underline disabled:opacity-50",children:i==="run-save"?"Downloading…":"Download PDF"}),t.run_count>1&&e.jsx("button",{type:"button",onClick:()=>h("device"),className:"text-sm font-medium text-brand-900 hover:underline",children:`All ${t.run_count} tests for this device`})]}):e.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"A report exists, but opening it needs QC access."}),r&&e.jsx("p",{className:"mt-2 text-xs text-rose-700",children:r}),e.jsx(S,{open:!!m,onClose:()=>h(null),label:"QC report",title:m==="device"?"All QC tests for this device":"QC report",subtitle:e.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-slate-500",children:n}),filename:m==="device"?`SAAR-QC-history-${n}.pdf`:`SAAR-QC-${n}-run${t.run_no}.pdf`,load:()=>m==="device"?l(n):a(t.run_id)})]}):e.jsx(x,{title:"QC",children:e.jsx("p",{className:"text-sm text-slate-500",children:"No QC test recorded for this serial."})})}function Q({qc:t}){const n=[[t.passed_count,"passed"],[t.failed_count,"failed"],[t.skipped_count,"skipped"],[t.unsupported_count,"not supported"]].filter(([a])=>a>0);return n.length?e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:n.map(([a,l])=>`${a} ${l}`).join(" · ")}):null}function A({qc:t}){const n=t.failed_tests||[],a=(t.defect_summary||"").trim();if(!n.length&&!a)return null;const l=Math.max(0,(t.failed_count||0)-n.length);return e.jsxs("div",{className:"mt-2 rounded-lg border border-rose-200 bg-rose-50 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-rose-800",children:"Why it failed"}),a&&e.jsx("p",{className:"mt-1 text-sm text-rose-900",children:a}),n.length>0&&e.jsx("ul",{className:"mt-1.5 list-disc space-y-1 pl-4 marker:text-rose-400",children:n.map(i=>e.jsxs("li",{className:"text-sm text-rose-900",children:[e.jsx("span",{className:"font-medium",children:i.label}),i.note?e.jsxs("span",{className:"text-rose-800",children:[" — ",i.note]}):null]},i.key))}),l>0&&e.jsxs("p",{className:"mt-1.5 text-xs text-rose-700",children:["Showing ",n.length," of ",t.failed_count," failed tests — the full report lists them all."]})]})}function R({service:t}){return t?t.checked===!1?e.jsx("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:"Couldn't check whether this is a customer's phone in for service."}):t.found?e.jsxs("section",{className:"rounded-lg border border-violet-200 bg-vi
4olet-50/50 p-3",children:[e.jsx("h2",{className:"text-[11px] font-semibold uppercase tracking-wider text-violet-800",children:"Service"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"rounded-full bg-violet-100 px-2 py-0.5 text-xs font-semibold text-violet-900",children:t.stage_label||t.stage}),t.cycle_label&&e.jsx("span",{className:"rounded-full bg-white px-2 py-0.5 text-xs font-semibold text-violet-800 ring-1 ring-violet-200",children:t.cycle_label})]}),t.next_step&&e.jsxs("p",{className:"mt-1.5 text-sm font-medium text-slate-800",children:["Next: ",t.next_step]}),e.jsxs("div",{className:"mt-1.5 space-y-0.5 text-xs text-slate-600",children:[t.location&&e.jsxs("p",{children:["Odoo holds it at ",e.jsx("span",{className:"font-mono",children:t.location})]}),e.jsxs("p",{children:[t.customer_name||"Customer",t.odoo_ticket_id?` · ticket #${t.odoo_ticket_id}`:"",t.received_at?` · in ${p(t.received_at)}`:""]}),t.inbound_qc_at&&e.jsxs("p",{children:["Inbound QC ",(t.inbound_qc_result||"—").toUpperCase()," ·"," ",p(t.inbound_qc_at)]}),t.post_qc_at&&e.jsxs("p",{children:["Post-repair QC ",(t.post_qc_result||"—").toUpperCase()," ·"," ",p(t.post_qc_at)]}),t.shelf_error&&e.jsxs("p",{className:"text-rose-700",children:["Last move refused: ",t.shelf_error]})]})]}):null:null}function x({title:t,children:n,empty:a}){return e.jsxs("section",{className:"rounded-lg border border-slate-200 bg-white p-3",children:[e.jsx("h2",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:t}),e.jsx("div",{className:"mt-2 space-y-2",children:a?e.jsx("p",{className:"text-sm text-slate-500",children:a}):n})]})}export{L as default,C as serialFromBarcode};

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.