Wizzas commited on
Commit
cbf7af6
·
verified ·
1 Parent(s): 808959b

Update verified React dashboard

Browse files
frontend/dist/assets/TeamWorkspace-Bzuqweaa.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as pe,r,l as Ve,a as et,b as tt,d as at,e as rt,s as Ke,f as z,R as nt,g as ze,h as e,i as Ie,p as Qe,n as Oe,j as Ye,k as Xe,m as st,w as De,o as We,q as lt,t as ct,u as it,v as ot,x as dt,y as ut,z as mt,A as pt,B as ft,C as ht,L as Et,S as vt,D as yt,E as je,F as gt,G as bt,H as He,I as wt}from"./index-CAf2svqt.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const St=pe("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Me=pe("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Nt=pe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const kt=pe("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const _t=pe("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Ct=pe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Dt=pe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Rt=pe("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),Ue="17:00",Tt=[{label:"Tomorrow",days:1},{label:"In 3 days",days:3},{label:"In 1 week",days:7},{label:"In 2 weeks",days:14}],xe=l=>String(l).padStart(2,"0"),Fe=l=>l.getFullYear()+"-"+xe(l.getMonth()+1)+"-"+xe(l.getDate());function Be(l,n=new Date){const u=new Date(n);return u.setDate(u.getDate()+l),Fe(u)}const Ge=(l,n)=>l?l+"T"+(n||Ue):"",xt=l=>({date:l?l.slice(0,10):"",time:l?l.slice(11,16):""}),Ze=l=>{const[n,u]=l.split(":").map(Number);return(n%12||12)+":"+xe(u)+" "+(n<12?"AM":"PM")};function At(l){const n=[];for(let u=420;u<=1200;u+=30)n.push(xe(Math.floor(u/60))+":"+xe(u%60));return l&&/^\d\d:\d\d$/.test(l)&&!n.includes(l)&&n.push(l),n.sort()}function qt(l,n=new Date){const u=Math.round((new Date(l.slice(0,10)+"T00:00")-new Date(Fe(n)+"T00:00"))/864e5);return u===0?"today":u===1?"tomorrow":u>1?"in "+u+" days":u===-1?"yesterday":Math.abs(u)+" days ago"}function Je(l,n=new Date){if(!l||!Number.isFinite(Date.parse(l)))return"";const u=new Date(l.slice(0,10)+"T00:00"),i=D=>u.toLocaleDateString("en-GB",D);return i({weekday:"long"})+", "+u.getDate()+" "+i({month:"short"})+" "+u.getFullYear()+" at "+Ze(l.slice(11,16))+" · "+qt(l,n)}const Lt=l=>{const n=new Date(l);return Fe(n)+"T"+String(n.getHours()).padStart(2,"0")+":"+String(n.getMinutes()).padStart(2,"0")};function $e({legend:l,prefix:n,value:u,time:i,setValue:D,setTime:v,disabled:U,required:C,keep:O}){const y=xt(u),W=y.time||i,$=p=>D(Ge(p,W)),K=p=>{v(p),y.date&&D(Ge(y.date,p))};return e.createElement("fieldset",{className:"due-field"},e.createElement("legend",null,l),e.createElement("div",{className:"due-shortcuts",role:"group","aria-label":l+" shortcuts"},O&&e.createElement("button",{type:"button",className:"chip"+(u?"":" selected"),"aria-pressed":!u,disabled:U,onClick:()=>D("")},"Keep current"),Tt.map(p=>{const I=Be(p.days);return e.createElement("button",{type:"button",key:p.days,className:"chip"+(y.date===I?" selected":""),"aria-pressed":y.date===I,disabled:U,onClick:()=>$(I)},p.label)})),e.createElement("div",{className:"due-inputs"},e.createElement("label",{className:"field"},n,"date",e.createElement("input",{type:"date",disabled:U,required:C,min:Fe(new Date),max:Be(365),value:y.date,onInput:p=>$(p.target.value),onChange:p=>$(p.target.value)})),e.createElement("label",{className:"field"},n,"time",e.createElement("select",{disabled:U,value:W,onChange:p=>K(p.target.value)},At(W).map(p=>e.createElement("option",{key:p,value:p},Ze(p)))))),e.createElement("p",{className:"caption due-summary","aria-live":"polite"},u?e.createElement(e.Fragment,null,"Due ",e.createElement("strong",null,Je(u))):O||"Pick a shortcut or a date. The time starts at 5:00 PM."))}function Pt({user:l,inspection:n,notes:u=[],inspections:i=[],inspectionLoading:D=!1,onSelectInspection:v,onEvidence:U}){const C=r.useRef(0),O=r.useRef(!1),y=r.useRef(n==null?void 0:n.id),W=r.useRef(null),$=r.useRef(null),K=r.useRef(null),[p,I]=r.useState("checking"),[F,H]=r.useState([]),[B,f]=r.useState([]),[fe,m]=r.useState(""),[te,S]=r.useState([]),[A,q]=r.useState([]),[he,T]=r.useState(""),[N,J]=r.useState(!1),[le,b]=r.useState(""),[L,Ee]=r.useState(""),[G,s]=r.useState(""),[w,h]=r.useState("Normal"),[x,R]=r.useState(""),[M,ce]=r.useState(Ue),[V,ie]=r.useState(!1),[Ne,Ae]=r.useState(""),[Re,ve]=r.useState(""),[ke,qe]=r.useState(null),[_e,Le]=r.useState(0),[Pe,ae]=r.useState(""),[ye,Ce]=r.useState(""),[oe,j]=r.useState(""),[ge,de]=r.useState(Ue),c=F.find(t=>t.id===fe),ue=Ve(u),me=et(F),a=tt(n,u,F,D),d=at({description:le,owner:L,supervisor:G,priority:w,due:x},B),o=a.ready?d||(V?"":"Confirm that the saved Staff review identifies a defect before creating the case."):a.reason,[P,re]=r.useState([]),k=i.filter(t=>!t.archived_at),Q=k.map(t=>t.id).join(","),ne=t=>st(t.id===(n==null?void 0:n.id)?u:P.filter(E=>E.inspection_id===t.id),F),be=k.map(t=>({row:t,status:ne(t)})).sort((t,E)=>(E.status.key==="ready")-(t.status.key==="ready")),Y=be.filter(t=>t.status.key==="ready").length,ee=rt(c,l.id,B.some(t=>t.user_id===l.id&&t.role==="developer")),_=!!c&&ke!==null&&ke!==c.version;async function X(){const t=++C.current,E=await z(),g=await E.rpc("defectrag_ca_staff");if(t!==C.current)return;if(g.error||g.data!==!0)throw I("denied"),H([]),f([]),m(""),S([]),q([]),new Error("Sign in with an approved Staff account and verify the security code before opening corrective actions.");const Z=await Promise.all([E.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),E.from("staff_members").select("user_id,display_name,role,revoked_at").is("revoked_at",null)]);if(t===C.current){if(Z.some(Te=>Te.error))throw I("unavailable"),H([]),f([]),m(""),S([]),q([]),Z.find(Te=>Te.error).error;I("authorized"),H(Z[0].data||[]),f(Z[1].data||[]),T(""),Le(Te=>Te+1)}}r.useEffect(()=>{const t=Ke(X,{onState:E=>{E.error&&(I("unavailable"),T(E.error),H([]),f([]),m(""),S([]),q([]))}});return()=>{t.stop(),C.current++}},[l.id]),r.useEffect(()=>{const t=()=>{C.current++,I("checking"),H([]),f([]),m(""),S([]),q([]),X().catch(E=>T(E.message))};return window.addEventListener("defectrag-auth-change",t),()=>window.removeEventListener("defectrag-auth-change",t)},[l.id]),r.useEffect(()=>{y.current&&y.current!==(n==null?void 0:n.id)&&(b(""),Ee(""),s(""),R(""),h("Normal")),y.current=n==null?void 0:n.id,ie(!1)},[n==null?void 0:n.id]),r.useEffect(()=>{ie(!1)},[ue==null?void 0:ue.id]),r.useEffect(()=>{let t=!0;const E=Q?Q.split(","):[];if(p!=="authorized"||!E.length){re([]);return}return z().then(g=>g.from("staff_notes").select("id,inspection_id,author_id,body,created_at").in("inspection_id",E).like("body",nt+"%").order("created_at").limit(2e3)).then(({data:g,error:Z})=>{if(t){if(Z)throw Z;re(g||[])}}).catch(()=>{t&&re([])}),()=>{t=!1}},[p,Q,_e]),r.useEffect(()=>{p==="authorized"&&ze($.current)},[p,n==null?void 0:n.id,ue==null?void 0:ue.id]);function we(){ve(""),Ae((c==null?void 0:c.state)||""),ae((c==null?void 0:c.owner_id)||""),Ce((c==null?void 0:c.supervisor_id)||""),j(""),qe((c==null?void 0:c.version)??null)}r.useEffect(we,[c==null?void 0:c.id]),r.useEffect(()=>{c&&ze(W.current)},[c==null?void 0:c.id]),r.useEffect(()=>{let t=!0;const E=C.current;if(!c||p!=="authorized"){K.current=null,S([]),q([]);return}return K.current!==c.id&&(K.current=c.id,S([]),q([])),z().then(g=>Promise.all([g.from("corrective_action_history").select("*").eq("case_id",c.id).order("version"),g.from("corrective_action_events").select("id,case_id,version,kind,status,attempts,last_error,created_at").eq("case_id",c.id).order("created_at",{ascending:!1})])).then(g=>{if(!(!t||E!==C.current)){if(g.some(Z=>Z.error))throw g.find(Z=>Z.error).error;S(g[0].data||[]),q(g[1].data||[])}}).catch(g=>{t&&E===C.current&&T(g.message)}),()=>{t=!1}},[c==null?void 0:c.id,c==null?void 0:c.version,_e,l.id,p]);async function se(t){if(!O.current){O.current=!0,J(!0),T("");try{await t(),await X(),De()}catch(E){T(E.message||"Corrective action request failed.")}finally{O.current=!1,J(!1)}}}const Se=t=>{var E;return((E=B.find(g=>g.user_id===t))==null?void 0:E.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card case-workspace",ref:$,tabIndex:-1,"aria-label":"Corrective Actions workspace"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Corrective Actions"),e.createElement("p",null,"Track work needed after a Staff review confirms a defect. Assign someone to fix it, set a due date, and keep a record of progress.")),e.createElement("button",{className:"secondary",disabled:N,onClick:()=>se(X)},"Refresh cases")),he&&e.createElement("div",{className:"error",role:"alert"},Ie(he)),p==="checking"&&e.createElement("p",{role:"status"},"Checking Staff access and the security code…"),p!=="checking"&&p!=="authorized"&&e.createElement("p",{className:"note"},"Open Staff workspace to check account approval and enter the security code. Then return here and try again."),p==="authorized"&&e.createElement(e.Fragment,null,e.createElement("p",{className:"caption"},"Showing up to 500 cases available to this account. Open: ",me.open," · Resolved / closed: ",me.resolved," · Overdue: ",me.overdue," · Average resolution: ",me.averageResolutionHours===null?"No resolved cases":me.averageResolutionHours.toFixed(1)+" hours",". Email delivery is separate from whether the case has been saved."),e.createElement("h3",null,"Create and assign a case"),e.createElement("p",{className:"caption"},"1. Choose a Team inspection. 2. Save its defect review. 3. Assign the work and deadline."),v&&e.createElement("label",{className:"field"},"Team inspection",e.createElement("select",{value:(n==null?void 0:n.id)||"",disabled:N||D,onChange:t=>v(t.target.value)},e.createElement("option",{value:""},"Choose a shared product inspection"),be.map(({row:t,status:E})=>{var g;return e.createElement("option",{key:t.id,value:t.id},Qe((g=t.payload)==null?void 0:g.category)," · ",new Date(t.created_at).toLocaleString()," · ",t.id.slice(0,8)," — ",E.label)}))),v&&k.length>0&&e.createElement("p",{className:"caption"},Y?`${Y} inspection${Y>1?"s are":" is"} ready, listed first.`:"No inspection is ready yet. A case needs a saved review of Reviewed with “Reject: defect confirmed”."),v&&!k.length&&e.createElement("p",{className:"note"},"No active Team inspections are available. Open a saved Personal inspection and choose Share with team before creating a case."),e.createElement("div",{className:"case-step "+(a.ready?"ready":"blocked")},e.createElement("strong",null,a.ready?"Ready to assign":n?a.existingCaseId?"This inspection already has a case":a.needsReview?"Step 2 needed: confirm the defect in a Staff review":"Not available yet":"Step 1: choose a Team inspection"),e.createElement("p",{id:"case-creation-guidance",role:"status"},a.reason),n&&!n.archived_at&&!D&&e.createElement("button",{type:"button",className:a.needsReview?"primary":"secondary",disabled:N,onClick:()=>U==null?void 0:U(n.id)},a.needsReview?"Open this inspection’s review":"Open photo and Staff review"),a.existingCaseId&&e.createElement("button",{type:"button",className:"secondary",onClick:()=>m(a.existingCaseId)},"Open existing case")),e.createElement("p",{className:"caption"},"Assignment fields can be filled in as a draft. Nothing is saved or emailed until Create corrective action succeeds. Unsaved drafts stay on this page. Reloading, signing out or losing verified access can discard them."),!B.length&&e.createElement("p",{className:"note"},"No active Staff are available for assignment. Refresh cases or contact the workspace administrator. No account permissions will be changed here."),e.createElement("form",{className:"login-form","data-tour":"case","aria-label":"Assign corrective action","aria-describedby":"case-creation-guidance case-submit-guidance",onSubmit:t=>{if(t.preventDefault(),!(o||N||O.current))return se(async()=>{const E=await z(),g=await We(E,"defectrag_create_corrective_action",{p_inspection:n.id,p_review:a.review.id,p_confirmed:V,p_owner:L,p_supervisor:G,p_priority:w,p_description:le,p_due:new Date(x).toISOString()});m(g),b(""),ie(!1)})}},e.createElement("label",{className:"field"},"What needs fixing?",e.createElement("textarea",{disabled:N,required:!0,minLength:10,maxLength:2e3,value:le,onInput:t=>b(t.target.value),onChange:t=>b(t.target.value)})),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{disabled:N,required:!0,value:L,onChange:t=>Ee(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),B.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{disabled:N,required:!0,value:G,onChange:t=>s(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),B.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Priority",e.createElement("select",{disabled:N,value:w,onChange:t=>h(t.target.value)},["Low","Normal","High","Critical"].map(t=>e.createElement("option",{key:t},t)))),$e({legend:"Due date and time",prefix:"Due ",value:x,time:M,setValue:R,setTime:ce,disabled:N,required:!0}),e.createElement("p",{className:"caption"},"Times use this device’s time zone. Choose a future deadline within the next year. The deadline is saved with the case."),e.createElement("p",{className:"note"},"Email reminders require administrator activation. Saving this case does not send an email by itself. The current n8n workflow targets the supervisor; it does not yet email the person responsible automatically. Confirm delivery with the supervisor separately."),e.createElement("label",{className:"consent-check"+(a.ready?"":" locked")},e.createElement("input",{type:"checkbox",disabled:N||!a.ready,checked:V,onChange:t=>ie(t.target.checked)}),e.createElement("span",null,"A Staff review has confirmed a defect that needs fixing. An unusual inspection result alone is not enough.",!a.ready&&e.createElement("small",null," Available after the review step above is complete."))),e.createElement("p",{className:"note",id:"case-submit-guidance",role:"status"},o?"Cannot create yet: "+o:"Ready to save the assignment. No email is sent by this button."),e.createElement("button",{className:"primary",disabled:N||!!o},"Create corrective action")),e.createElement("h3",{className:"section-gap"},"Saved cases"),e.createElement("div",{className:"table-wrap","data-tour":c?void 0:"case-update"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Case"),e.createElement("th",null,"Status"),e.createElement("th",null,"Owner"),e.createElement("th",null,"Priority"),e.createElement("th",null,"Due"),e.createElement("th",null))),e.createElement("tbody",null,F.map(t=>e.createElement("tr",{key:t.id},e.createElement("td",null,t.id.slice(0,8)),e.createElement("td",null,t.state,!["Resolved","Closed","Cancelled"].includes(t.state)&&Date.parse(t.due_at)<Date.now()?" · Overdue":""),e.createElement("td",null,Se(t.owner_id)),e.createElement("td",null,t.priority),e.createElement("td",null,new Date(t.due_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>m(t.id)},"Details")))))),!F.length&&e.createElement("p",{className:"caption"},"No cases are available to this account yet.")),c&&e.createElement("div",{className:"cloud-message","data-tour":"case-update",ref:W,tabIndex:-1,"aria-label":"Corrective action case details"},e.createElement("div",{className:"section-title"},e.createElement("h3",null,"Case ",c.id.slice(0,8)," · ",c.state),e.createElement("button",{className:"text-button",onClick:()=>m("")},"Close details")),e.createElement("p",null,c.description),e.createElement("p",null,"Person responsible: ",Se(c.owner_id)," · Supervisor: ",Se(c.supervisor_id)," · Due: ",new Date(c.due_at).toLocaleString()),e.createElement("p",null,"Confirmed by: ",Se(c.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>U(c.inspection_id)},"Open the linked photo and review"),Oe(c.state).length>0&&!ee&&e.createElement("p",{className:"note"},"Only the person responsible, the supervisor or a Developer can change this case after verifying their security code. Other Staff can read it."),!Oe(c.state).length&&e.createElement("p",{className:"note"},"This case is ",c.state.toLowerCase(),". Its saved assignment and history are available to read; further updates are not permitted."),_&&ee&&e.createElement("p",{className:"note",role:"status"},"This case changed while the update was being drafted. The draft has been kept; it has not been saved. Copy any text needed before loading the latest case. ",e.createElement("button",{className:"secondary",disabled:N,onClick:()=>{we(),T("")}},"Load latest case and replace draft")),Oe(c.state).length>0&&ee&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),se(async()=>{if(_)throw new Error("The case changed. Load the latest case before saving.");const E=await z(),g=await We(E,"defectrag_update_corrective_action",{p_id:c.id,p_version:ke,p_state:Ne,p_note:Re,p_owner:Pe,p_supervisor:ye,p_due:oe?new Date(oe).toISOString():null});qe(g),ve(""),j("")})}},e.createElement("label",{className:"field"},"Case status",e.createElement("select",{disabled:N||_,value:Ne,onChange:t=>Ae(t.target.value)},Oe(c.state).map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Owner",e.createElement("select",{disabled:N||_,required:!0,value:Pe,onChange:t=>ae(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),B.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{disabled:N||_,required:!0,value:ye,onChange:t=>Ce(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),B.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),$e({legend:"Change due date and time (optional)",prefix:"New due ",value:oe,time:ge,setValue:j,setTime:de,disabled:N||_,keep:"The current due date stays: "+Je(Lt(c.due_at))+"."}),e.createElement("label",{className:"field"},"What changed or was fixed?",e.createElement("textarea",{disabled:N,required:!0,minLength:3,maxLength:2e3,value:Re,onInput:t=>ve(t.target.value),onChange:t=>ve(t.target.value)})),e.createElement("button",{className:"primary",disabled:N||!Ne||_},"Save case update")),e.createElement("h3",null,"Status history"),te.map(t=>e.createElement("p",{key:t.id},e.createElement("strong",null,t.state)," · ",Se(t.actor_id)," · ",new Date(t.created_at).toLocaleString(),e.createElement("br",null),t.note,t.snapshot&&e.createElement("small",null,e.createElement("br",null),"Owner: ",Se(t.snapshot.owner_id)," · Supervisor: ",Se(t.snapshot.supervisor_id)," · Due: ",new Date(t.snapshot.due_at).toLocaleString()))),e.createElement("h3",null,"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. If delivery fails or is uncertain, contact the workspace administrator. The case stays saved even when the email service is unavailable."),A.map(t=>e.createElement("p",{key:t.id},Ye(t.kind)," · ",Xe(t.status)," · attempts ",t.attempts,t.last_error?" · "+Ie(t.last_error):"")))))}function Ot({client:l,user:n,onChange:u}){var G;const[i,D]=r.useState(null),[v,U]=r.useState([]),[C,O]=r.useState([]),[y,W]=r.useState(null),[$,K]=r.useState(""),[p,I]=r.useState(""),[F,H]=r.useState(""),[B,f]=r.useState(""),[fe,m]=r.useState(""),[te,S]=r.useState(""),[A,q]=r.useState(!1),[he,T]=r.useState([]),[N,J]=r.useState([]),le=((G=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:G.registrationEnabled)===!0;async function b(){if(!n){D(null),T([]),J([]);return}const s=await lt(l);D(s);const{data:w,error:h}=await l.auth.mfa.listFactors();if(h)throw h;const x=(w.totp||[]).filter(R=>R.status==="verified");if(U(x),O((w.all||[]).filter(R=>R.factor_type==="totp"&&R.status==="unverified")),I(R=>{var M;return x.some(ce=>ce.id===R)?R:((M=x[0])==null?void 0:M.id)||""}),s.role==="developer"&&s.approved&&s.aal2){const[R,M]=await Promise.all([l.rpc("defectrag_access_directory"),l.rpc("defectrag_notification_status")]);if(R.error)throw R.error;if(M.error)throw M.error;T(R.data||[]),J(M.data||[])}else T([]),J([])}async function L(s){q(!0),S("");try{await s()}catch(w){S(w.message||"Security request failed.")}finally{q(!1)}}r.useEffect(()=>{let s=!0;return W(null),K(""),T([]),J([]),l&&n?b().catch(w=>{s&&S(w.message)}):D(null),()=>{s=!1}},[l,n==null?void 0:n.id]);async function Ee(){await ut(l,(y==null?void 0:y.id)||p,$),K(""),W(null),await b(),u(),S("Security code verified. Staff access is available only after the account is approved.")}return e.createElement("div",{className:"section-gap"},n&&e.createElement("h3",null,"Sign-in and account security"),te&&e.createElement("p",{className:"note",role:"status"},Ie(te)),n?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,i!=null&&i.revoked?"revoked":i!=null&&i.approved?"approved":(i==null?void 0:i.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,i!=null&&i.aal2?"security code verified":"enter security code")),e.createElement("button",{className:"secondary",disabled:A,onClick:()=>L(b)},"Refresh account status"),i&&!i.approved&&!i.revoked&&!i.request_status&&e.createElement("form",{className:"login-form",onSubmit:s=>{s.preventDefault(),L(async()=>{await it(l,F),await b(),S("Request sent. Check back here for Developer approval. Team and private Staff work are not available while the request is waiting."),u()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:F,maxLength:80,onChange:s=>H(s.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:A||!i.registration_enabled||!i.email_verified},"Request staff access")),e.createElement("p",{className:"caption"},"Use an authenticator app for the extra six-digit sign-in code. Keep access to that app. If it is lost, contact the workspace administrator; resetting the password does not remove this security check."),!y&&!v.length&&!C.length&&e.createElement("button",{className:"secondary",disabled:A,onClick:()=>L(async()=>W(await ot(l)))},"Set up a security code app"),!y&&C.map(s=>e.createElement("p",{key:s.id,className:"caption"},"Authenticator setup was not finished. ",e.createElement("button",{className:"text-button",disabled:A,onClick:()=>L(async()=>{const{error:w}=await l.auth.mfa.unenroll({factorId:s.id});if(w)throw w;await b()})},"Cancel incomplete setup"))),y&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("p",null,"Open an authenticator app, scan this private QR code, then enter the six-digit code below to finish. Do not share the QR code or security codes."),e.createElement("img",{src:y.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:A,onClick:()=>L(async()=>{const{error:s}=await l.auth.mfa.unenroll({factorId:y.id});if(s)throw s;W(null),K("")})},"Cancel incomplete setup"))),!y&&v.length>0&&(i==null?void 0:i.aal2)&&e.createElement("p",{className:"caption"},"The security code is verified for this sign-in."),(y||v.length>0&&!(i!=null&&i.aal2))&&e.createElement("form",{className:"login-form",onSubmit:s=>{s.preventDefault(),L(Ee)}},!y&&e.createElement("label",{className:"field"},"Security code app",e.createElement("select",{value:p,onChange:s=>I(s.target.value)},v.map(s=>e.createElement("option",{key:s.id,value:s.id},s.friendly_name||"Authenticator")))),e.createElement("label",{className:"field"},"Six-digit security code",e.createElement("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:$,onChange:s=>K(s.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:A},"Verify security code")),(i==null?void 0:i.role)==="developer"&&i.approved&&i.aal2&&e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Staff access management"),e.createElement("p",null,"Approve or reject requests that are still waiting. Removing access stops new Staff actions but keeps inspection history."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Account"),e.createElement("th",null,"Status"),e.createElement("th",null,"Role"),e.createElement("th",null,"Action"))),e.createElement("tbody",null,he.map(s=>e.createElement("tr",{key:s.user_id},e.createElement("td",null,s.display_name,e.createElement("br",null),e.createElement("small",null,s.email)),e.createElement("td",null,s.status),e.createElement("td",null,s.role||"applicant"),e.createElement("td",null,s.user_id!==n.id&&(s.status==="pending"?["approve","reject"]:s.status==="approved"?["revoke"]:[]).map(w=>e.createElement("button",{key:w,className:"text-button",disabled:A,onClick:()=>{window.confirm(`${w[0].toUpperCase()+w.slice(1)} access for ${s.display_name}?`)&&L(async()=>{await dt(l,s,w),await b(),u(),S("Account access updated. Check Email delivery below separately; saving this change does not confirm an email was sent.")})}},{approve:"Approve",reject:"Reject",revoke:"Remove access"}[w])))))))),e.createElement("h3",{className:"section-gap"},"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. Delivery depends on administrator settings and the email service being available. Sent means the email service accepted the message; it may still reach Spam or fail to arrive."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Event"),e.createElement("th",null,"Delivery"),e.createElement("th",null,"Attempts"),e.createElement("th",null))),e.createElement("tbody",null,N.map(s=>e.createElement("tr",{key:s.id},e.createElement("td",null,Ye(s.kind)),e.createElement("td",null,Xe(s.status)),e.createElement("td",null,s.attempts),e.createElement("td",null,s.status==="dead"&&e.createElement("button",{className:"text-button",disabled:A,onClick:()=>L(async()=>{const{error:w}=await l.rpc("defectrag_retry_notification",{p_id:s.id});if(w)throw w;await b()})},"Retry delivery"))))))))):le?e.createElement("details",{className:"register-panel"},e.createElement("summary",null,"New to Staff work? Create an account"),e.createElement("form",{className:"login-form",onSubmit:s=>{s.preventDefault(),L(async()=>{await ct(l,{email:B,password:fe,displayName:F,redirectTo:location.origin+location.pathname}),m(""),S("Check the inbox and Spam folder for a confirmation email. Open its link, sign in, then choose Request staff access. A Developer must approve the request before Staff work is available.")})}},e.createElement("p",null,"New to Staff work? Create an account, confirm the email, then request access. The public demo can be used without an account."),e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:F,onChange:s=>H(s.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:B,onChange:s=>f(s.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:fe,onChange:s=>m(s.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:A||!l},"Register account"))):e.createElement("p",{className:"caption"},"New account registration is currently closed. Existing Staff can sign in below. The public demo is still available."))}function Ft({onOpenInspection:l,onOpenCorrectiveActions:n,onChooseInspection:u,casesView:i=!1,initialInspectionId:D=null}){var me;const v=r.useRef(0),U=r.useRef(null),C=r.useRef(0),O=r.useRef(null),y=r.useRef(0),W=r.useRef(null),$=r.useRef(null),[K,p]=r.useState(0),[I,F]=r.useState(!1),[H,B]=r.useState({state:"refreshing"}),[f,fe]=r.useState(null),[m,te]=r.useState(null),[S,A]=r.useState([]),[q,he]=r.useState({}),[T,N]=r.useState(""),[J,le]=r.useState(""),[b,L]=r.useState(!1),[Ee,G]=r.useState(""),[s,w]=r.useState(!1),[h,x]=r.useState(null),[R,M]=r.useState([]),[ce,V]=r.useState([]),[ie,Ne]=r.useState(""),[Ae,Re]=r.useState(!1),[ve,ke]=r.useState(""),[qe,_e]=r.useState(!1),[Le,Pe]=r.useState(null),ae=mt(),ye=pt(window.DEFECTRAG_PUBLIC_CONFIG);r.useEffect(()=>()=>{R.filter(a=>a.startsWith("blob:")).forEach(a=>URL.revokeObjectURL(a))},[R]),r.useEffect(()=>{O.current=h},[h]),r.useEffect(()=>{h&&ze(W.current)},[K]),r.useEffect(()=>{if(!f||!m||!D)return;const a=f.id+":"+D;$.current!==a&&($.current=a,de({id:D},{focus:!i}))},[f==null?void 0:f.id,m==null?void 0:m.user_id,D]);const Ce=ft(),oe=ae&&Le&&(!i||!m)?e.createElement(Ot,{key:(f==null?void 0:f.id)||"anonymous",client:Le,user:f,onChange:()=>{De(),f&&j(ge)}}):null;async function j(a){L(!0),G("");try{await a()}catch(d){G(d.message||"Team request failed.")}finally{L(!1)}}async function ge(){var _;const a=++C.current,d=v.current,o=(_=O.current)==null?void 0:_.id,{client:P,staff:re}=await wt();let k=P.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);k=s?k.not("archived_at","is",null):k.is("archived_at",null);const[{data:Q,error:ne},{data:be,error:Y},ee]=await Promise.all([k,P.from("staff_members").select("*"),o?P.from("staff_notes").select("*").eq("inspection_id",o).order("created_at"):{data:[]}]);if(ne)throw ne;if(Y)throw Y;if(ee.error)throw ee.error;if(a===C.current&&(te(re),G(""),A(Q||[]),he(Object.fromEntries((be||[]).map(X=>[X.user_id,X.display_name]))),o&&d===v.current)){const X=(Q||[]).find(we=>we.id===o);if(!X)v.current++,x(null),M([]),V([]);else if(x(X),V(ee.data||[]),!ae&&Date.now()-y.current>480*1e3){const we=await Promise.all([X.image_path,X.heatmap_path].map(se=>P.storage.from("team-inspections").createSignedUrl(se,900)));if(a===C.current&&d===v.current){if(we.some(se=>se.error))throw new Error("Shared image links could not refresh.");M(we.map(se=>se.data.signedUrl)),y.current=Date.now()}}}}r.useEffect(()=>{if(!Ce)return;let a=!1,d;return z().then(async o=>{!a&&ae&&Pe(o),d=o.auth.onAuthStateChange((re,k)=>{var Q;if(!a){const ne=((Q=k==null?void 0:k.user)==null?void 0:Q.id)||null;U.current!==ne&&(v.current++,C.current++,x(null),A([]),M([]),V([]),te(null),U.current=ne),fe((k==null?void 0:k.user)||null),re==="PASSWORD_RECOVERY"&&Re(!0)}}).data.subscription;const{data:P}=await o.auth.getUser();a||fe(P.user)}).catch(o=>{a||G(o.message)}),()=>{a=!0,v.current++,d==null||d.unsubscribe()}},[Ce]),r.useEffect(()=>{if(!f)return;const a=Ke(ge,{onState:d=>{B(d),d.error&&(G(d.error),ae&&(v.current++,A([]),he({}),x(null),M([]),V([]),te(null)))}});return()=>{a.stop(),C.current++}},[f==null?void 0:f.id,s]);async function de(a,{focus:d=!0}={}){const o=++v.current;F(!0);try{await j(async()=>{if(o!==v.current)return;const P=await z(),re=P.storage.from("team-inspections"),[{data:k,error:Q},{data:ne,error:be}]=await Promise.all([P.from("shared_inspections").select("*").eq("id",a.id).single(),P.from("staff_notes").select("*").eq("inspection_id",a.id).order("created_at")]);if(o!==v.current)return;if(Q)throw Q;if(be)throw be;const Y=ae?await ht(P,k):null,ee=Y?Y.map(_=>({data:{signedUrl:_}})):await Promise.all([k.image_path,k.heatmap_path].map(_=>re.createSignedUrl(_,900)));if(ee.some(_=>_.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(o!==v.current){Y==null||Y.forEach(_=>URL.revokeObjectURL(_));return}O.current=k,y.current=Date.now(),x(k),M(ee.map(_=>_.data.signedUrl)),V(ne||[]),d&&p(_=>_+1)})}finally{o===v.current&&F(!1)}}function c(){v.current++,O.current=null,F(!1),x(null),M([]),V([])}async function ue(){await j(async()=>{const a=await z(),d=S.filter(o=>o.owner_id===f.id).map(o=>o.id);if(d.length){const{error:o}=await a.rpc("archive_team_inspections",{p_ids:d});if(o)throw o}v.current++,x(null),_e(!1),await ge(),De()})}return Ce?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(Rt,{size:21})," ",i?"Corrective Actions access":"Staff workspace"),e.createElement("p",null,m?"This account can access shared Team work. New inspections start in Personal Workspace and are shared only when chosen.":"Sign in to review inspections shared with the team. New inspections start in Personal Workspace and are shared only when chosen.")),e.createElement("span",{className:"subtle-tag"},e.createElement(Me,{size:13})," STAFF ACCESS")),Ee&&e.createElement("div",{className:"error",role:"alert"},Ie(Ee)),I&&e.createElement("p",{role:"status"},"Opening the shared photo and review…"),i&&!ye&&e.createElement("p",{className:"note"},"Corrective Actions has been turned off for this app. Inspections and reviews are still available. Contact the workspace administrator if needed."),f&&!m&&oe,f?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(vt,{size:18}),e.createElement("strong",null,(m==null?void 0:m.display_name)||f.email),e.createElement("span",{className:"subtle-tag"},(m==null?void 0:m.role)||"CHECKING ACCESS")),e.createElement("button",{className:"secondary",disabled:b,onClick:()=>j(ge)},e.createElement(Ct,{size:16})," Refresh"),!i&&m&&ye&&e.createElement("button",{className:"secondary",onClick:()=>n==null?void 0:n()},"Open Corrective Actions"),i&&m&&e.createElement("button",{className:"secondary",onClick:()=>u==null?void 0:u()},"Choose a Team inspection"),e.createElement("button",{className:"secondary",onClick:()=>j(async()=>{await(await z()).auth.signOut(),A([]),x(null),te(null)})},e.createElement(_t,{size:16})," Sign out")),Ae&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),j(async()=>{const d=await z(),{error:o}=await d.auth.updateUser({password:ve});if(o)throw o;ke(""),Re(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:ve,onChange:a=>ke(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:b},"Save password")),!i&&e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",S.length," shared inspections · ",H.state==="synced"?"updated at "+new Date(H.at).toLocaleTimeString():H.state==="offline"?"offline; shown results may be out of date":H.state==="stale"?"update failed; shown results may be out of date":"refreshing…"," · checks for changes every 15 seconds"),(m==null?void 0:m.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{w(!s),x(null)}},e.createElement(St,{size:16}),s?"Active history":"Restore archived team work"),!s&&e.createElement("button",{className:"secondary danger",disabled:b||!S.some(a=>a.owner_id===f.id),onClick:()=>_e(!0)},e.createElement(yt,{size:16})," Archive my shared inspections")),qe&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:b,onClick:ue},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>_e(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,S.map(a=>{var d;return e.createElement("tr",{key:a.id},e.createElement("td",null,e.createElement("strong",null,a.id.slice(0,8))),e.createElement("td",null,Qe(a.payload.category)),e.createElement("td",null,e.createElement("span",{className:"badge "+((d=a.payload.verdict)==null?void 0:d.toLowerCase())},je(a.payload.verdict))),e.createElement("td",null,q[a.owner_id]||"Staff member"),e.createElement("td",null,new Date(a.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",disabled:b,onClick:()=>de(a)},"Review"),s&&(m==null?void 0:m.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:b,onClick:()=>j(async()=>{const o=await z(),{error:P}=await o.rpc("restore_team_inspections",{p_ids:[a.id]});if(P)throw P;await ge(),De()})},"Restore")))}))),!S.length&&e.createElement("div",{className:"empty"},e.createElement(Me,{size:30}),e.createElement("p",null,s?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with team."))))):e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Sign in"),e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),j(async()=>{const d=await z(),{error:o}=await d.auth.signInWithPassword({email:T,password:J});if(o)throw o;le("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:T,onChange:a=>N(a.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:J,onChange:a=>le(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:b},b?e.createElement(Et,{className:"spin",size:17}):e.createElement(kt,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!T||b,onClick:()=>j(async()=>{const a=await z(),{error:d}=await a.auth.resetPasswordForEmail(T,{redirectTo:location.origin+location.pathname});if(d)throw d;G("Password reset requested. Check the inbox and Spam folder.")})},"Reset password"),e.createElement("p",{className:"caption"},ae?"A new account needs Developer approval before Staff work is available. Approved Staff must also enter their security code when asked.":"The workspace administrator must approve an account before it can access Staff work.")),oe),f&&m&&oe&&e.createElement("details",{className:"account-panel section-gap"},e.createElement("summary",null,"Account & security"),oe)),i&&f&&m&&ye&&e.createElement(Pt,{key:f.id,user:f,inspection:h,notes:ce,inspections:S,inspectionLoading:I,onSelectInspection:a=>a?de({id:a},{focus:!1}):c(),onEvidence:a=>de({id:a})}),f&&h&&e.createElement("section",{className:"card",ref:W,tabIndex:-1,"aria-labelledby":"shared-inspection-title"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",{id:"shared-inspection-title"},"Shared inspection · ",h.id.slice(0,8)),e.createElement("p",null,"Shared copy from ",q[h.owner_id]||"a colleague",". These are saved results. Opening them does not run another inspection.")),e.createElement("div",{className:"button-row"},l&&!h.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>l(h)},"Open full result and assistant"),!i&&ye&&!h.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>n==null?void 0:n(h)},"Create or view corrective actions"),e.createElement("button",{className:"text-button",onClick:c},"Close"))),e.createElement("div",{className:"shared-images"},R.map((a,d)=>e.createElement("img",{key:a,src:a,alt:d?"Saved highlighted areas":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED RESULT"),e.createElement("span",null,je(h.payload.verdict)," · score ",Number(h.payload.score).toFixed(5)," · review limit ",Number(h.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Saved assistant conversation"),(me=h.conversation)!=null&&me.length?h.conversation.map((a,d)=>e.createElement("p",{className:"cloud-message",key:d},e.createElement("strong",null,a.role==="user"?"Inspector":"Evidence Assistant",": "),a.question||a.answer)):e.createElement("p",{className:"caption"},"No assistant conversation was shared with this inspection."),!h.archived_at&&e.createElement(gt,{key:h.id+String(ce.length),current:ce.map(a=>He(a,q)).filter(Boolean).at(-1),disabled:b,onSave:async a=>{const d=await z(),{error:o}=await d.from("staff_notes").insert({inspection_id:h.id,author_id:f.id,body:bt(a.status,a.decision,a.note)});if(o)throw o;await de(h,{focus:!i}),De()}}),e.createElement("h3",{className:"section-gap"},"Team notes"),ce.filter(a=>!He(a,q)).map(a=>e.createElement("div",{className:"cloud-message",key:a.id},e.createElement("strong",null,q[a.author_id]||"Staff member"),e.createElement("p",null,a.body),e.createElement("small",null,new Date(a.created_at).toLocaleString()))),!h.archived_at&&e.createElement("form",{className:"question-form",onSubmit:a=>{a.preventDefault(),j(async()=>{const d=await z(),{error:o}=await d.from("staff_notes").insert({inspection_id:h.id,author_id:f.id,body:ie.trim()});if(o)throw o;Ne(""),await de(h),De()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a note for the team…",value:ie,onChange:a=>Ne(a.target.value)}),e.createElement("button",{className:"primary",disabled:b||!ie.trim()},e.createElement(Dt,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(Me,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"Team workspace is not available yet."),e.createElement("p",null,"The workspace administrator needs to connect shared storage before Staff can sign in here."),e.createElement("div",{className:"setup-grid"},[["01","Connect shared storage","The workspace administrator completes this setup."],["02","Set up staff access","The administrator sets up approval and account security."],["03","Connect this dashboard","The administrator connects the app, then Staff can sign in."]].map(([a,d,o])=>e.createElement("div",{key:a},e.createElement("b",null,a),e.createElement("h3",null,d),e.createElement("p",null,o)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Administrator setup ",e.createElement(Nt,{size:16})),e.createElement("p",{className:"caption"},"Contact the workspace administrator for help. The public demo can be used without Staff access."))}export{Ft as default};
frontend/dist/assets/index-CAf2svqt.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/index.html CHANGED
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#fafafa" media="(prefers-color-scheme: light)"/><meta name="theme-color" content="#171717" media="(prefers-color-scheme: dark)"/><script>try{var t=localStorage.getItem("defectrag-theme");if(t==="dark"||(t!=="light"&&matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")}catch(e){}</script><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-68sbwmhR.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-BkrBCXOl.css">
3
  </head><body><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#fafafa" media="(prefers-color-scheme: light)"/><meta name="theme-color" content="#171717" media="(prefers-color-scheme: dark)"/><script>try{var t=localStorage.getItem("defectrag-theme");if(t==="dark"||(t!=="light"&&matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")}catch(e){}</script><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-CAf2svqt.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-BkrBCXOl.css">
3
  </head><body><div id="root"></div></body></html>