Restore visible model results and update Staff dashboard guidance
Browse files
frontend/dist/assets/TeamWorkspace-ClrcLwON.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{c as te,p as Ne,r,s as Pe,f as De,a as P,R as e,b as Ce,e as Oe,d as Fe,w as ge,g as Ue,h as Me,i as ze,j as Ie,k as je,v as We,l as He,m as Be,n as Ge,o as Ae,L as Ke,S as Qe,A as $e,q as Le,t as Ye,u as Ze,x as Je}from"./index-D5pBAfRX.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 Xe=te("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 Re=te("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 Ve=te("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 et=te("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 tt=te("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 at=te("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 rt=te("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 nt=te("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"}]]);function lt(o,u,b=!1){return!!o&&typeof u=="string"&&u.length>0&&(o.owner_id===u||o.supervisor_id===u||b===!0)}function xe(o){return{Open:["Open","Assigned","Cancelled"],Assigned:["Assigned","In Progress","Cancelled"],"In Progress":["In Progress","Resolved","Cancelled"],Resolved:["Resolved","Closed","In Progress","Cancelled"],Closed:[],Cancelled:[]}[o]||[]}function st(o){const b=o.filter(s=>Ne(s)).sort((s,E)=>String(s.created_at).localeCompare(String(E.created_at))||s.id.localeCompare(E.id)).at(-1),l=b&&Ne(b);return(l==null?void 0:l.status)==="Reviewed"&&l.decision==="Reject"?b:null}function ct(o,u=Date.now()){const b=o.filter(s=>!["Closed","Cancelled"].includes(s.state)),l=o.filter(s=>["Resolved","Closed"].includes(s.state)).map(s=>Date.parse(s.resolved_at)-Date.parse(s.created_at)).filter(s=>Number.isFinite(s)&&s>=0);return{open:b.filter(s=>s.state!=="Resolved").length,resolved:o.filter(s=>["Resolved","Closed"].includes(s.state)).length,overdue:b.filter(s=>s.state!=="Resolved"&&Date.parse(s.due_at)<u).length,averageResolutionHours:l.length?l.reduce((s,E)=>s+E,0)/l.length/36e5:null}}async function Te(o,u,b){const{data:l,error:s}=await o.rpc(u,b);if(s)throw s;return l}function it({user:o,inspection:u,notes:b=[],onEvidence:l}){const s=r.useRef(0),E=r.useRef(null),ae=r.useRef(null),[k,U]=r.useState("checking"),[w,O]=r.useState([]),[M,z]=r.useState([]),[de,I]=r.useState(""),[K,A]=r.useState([]),[ue,m]=r.useState([]),[Z,f]=r.useState(""),[j,C]=r.useState(!1),[_,W]=r.useState(""),[re,H]=r.useState(""),[me,Q]=r.useState(""),[ne,y]=r.useState("Normal"),[D,pe]=r.useState(""),[F,n]=r.useState(!1),[v,h]=r.useState(""),[R,S]=r.useState(""),[x,J]=r.useState(0),[$,fe]=r.useState(""),[ye,ke]=r.useState(""),[he,be]=r.useState(""),c=w.find(t=>t.id===de),le=st(b),Y=ct(w),we=lt(c,o.id,M.some(t=>t.user_id===o.id&&t.role==="developer"));async function Ee(){const t=++s.current,p=await P(),g=await p.rpc("defectrag_ca_staff");if(t!==s.current)return;if(g.error||g.data!==!0)throw U("denied"),O([]),z([]),I(""),A([]),m([]),new Error("Sign in with an approved Staff account and verify the security code before opening corrective actions.");const L=await Promise.all([p.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),p.from("staff_members").select("user_id,display_name,role,revoked_at").is("revoked_at",null)]);if(t===s.current){if(L.some(se=>se.error))throw U("unavailable"),O([]),z([]),I(""),A([]),m([]),L.find(se=>se.error).error;U("authorized"),O(L[0].data||[]),z(L[1].data||[]),f(""),J(se=>se+1)}}r.useEffect(()=>{const t=Pe(Ee,{onState:p=>{p.error&&(U("unavailable"),f(p.error),O([]),z([]),I(""),A([]),m([]))}});return()=>{t.stop(),s.current++}},[o.id]),r.useEffect(()=>{const t=()=>{s.current++,U("checking"),O([]),z([]),I(""),A([]),m([]),Ee().catch(p=>f(p.message))};return window.addEventListener("defectrag-auth-change",t),()=>window.removeEventListener("defectrag-auth-change",t)},[o.id]),r.useEffect(()=>{n(!1),W("")},[u==null?void 0:u.id,le==null?void 0:le.id]),r.useEffect(()=>{k==="authorized"&&De(ae.current)},[k,u==null?void 0:u.id]),r.useEffect(()=>{S(""),h((c==null?void 0:c.state)||""),fe((c==null?void 0:c.owner_id)||""),ke((c==null?void 0:c.supervisor_id)||""),be("")},[c==null?void 0:c.id,c==null?void 0:c.version]),r.useEffect(()=>{c&&De(E.current)},[c==null?void 0:c.id]),r.useEffect(()=>{let t=!0;const p=s.current;if(A([]),m([]),!(!c||k!=="authorized"))return P().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||p!==s.current)){if(g.some(L=>L.error))throw g.find(L=>L.error).error;A(g[0].data||[]),m(g[1].data||[])}}).catch(g=>{t&&p===s.current&&f(g.message)}),()=>{t=!1}},[c==null?void 0:c.id,c==null?void 0:c.version,x,o.id,k]);async function G(t){if(!j){C(!0),f("");try{await t(),await Ee(),ge()}catch(p){f(p.message||"Corrective action request failed.")}finally{C(!1)}}}const B=t=>{var p;return((p=M.find(g=>g.user_id===t))==null?void 0:p.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card",ref:ae,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:j,onClick:()=>G(Ee)},"Refresh cases")),Z&&e.createElement("div",{className:"error",role:"alert"},Ce(Z)),k==="checking"&&e.createElement("p",{role:"status"},"Checking Staff access and the security code…"),k!=="checking"&&k!=="authorized"&&e.createElement("p",{className:"note"},"Open Staff workspace to check account approval and enter the security code. Then return here and try again."),k==="authorized"&&e.createElement(e.Fragment,null,e.createElement("p",{className:"caption"},"Showing up to 500 cases available to this account. Open: ",Y.open," · Resolved / closed: ",Y.resolved," · Overdue: ",Y.overdue," · Average resolution: ",Y.averageResolutionHours===null?"No resolved cases":Y.averageResolutionHours.toFixed(1)+" hours",". Email delivery is separate from whether the case has been saved."),u&&!u.archived_at&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Create from inspection ",u.id.slice(0,8)),le?e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),G(async()=>{const p=await P(),g=await Te(p,"defectrag_create_corrective_action",{p_inspection:u.id,p_review:le.id,p_confirmed:F,p_owner:re,p_supervisor:me,p_priority:ne,p_description:_,p_due:new Date(D).toISOString()});I(g),W(""),n(!1)})}},e.createElement("label",{className:"field"},"What needs fixing?",e.createElement("textarea",{required:!0,minLength:10,maxLength:2e3,value:_,onChange:t=>W(t.target.value)})),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{required:!0,value:re,onChange:t=>H(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),M.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",{required:!0,value:me,onChange:t=>Q(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),M.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",{value:ne,onChange:t=>y(t.target.value)},["Low","Normal","High","Critical"].map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Due date and time",e.createElement("input",{type:"datetime-local",required:!0,value:D,onChange:t=>pe(t.target.value)})),e.createElement("label",null,e.createElement("input",{type:"checkbox",checked:F,onChange:t=>n(t.target.checked)})," A Staff review has confirmed a defect that needs fixing. An unusual inspection result alone is not enough."),e.createElement("button",{className:"primary",disabled:j||!F},"Create corrective action")):e.createElement("p",{className:"note"},"First open the shared inspection, set the review to Reviewed and Reject, and save it. Then confirm that the defect needs fixing before creating a case.")),!u&&e.createElement("p",{className:"caption"},"To create a case, choose a Team inspection and save its Staff review first. Use Choose a Team inspection above."),e.createElement("div",{className:"table-wrap"},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,w.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,B(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:()=>I(t.id)},"Details")))))),!w.length&&e.createElement("p",{className:"caption"},"No cases are available to this account yet.")),c&&e.createElement("div",{className:"cloud-message",ref:E,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:()=>I("")},"Close details")),e.createElement("p",null,c.description),e.createElement("p",null,"Supervisor: ",B(c.supervisor_id)," · Confirmed by: ",B(c.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>l(c.inspection_id)},"Open the linked photo and review"),xe(c.state).length>0&&!we&&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."),xe(c.state).length>0&&we&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),G(async()=>{const p=await P();await Te(p,"defectrag_update_corrective_action",{p_id:c.id,p_version:c.version,p_state:v,p_note:R,p_owner:$,p_supervisor:ye,p_due:he?new Date(he).toISOString():null}),S("")})}},e.createElement("label",{className:"field"},"Case status",e.createElement("select",{value:v,onChange:t=>h(t.target.value)},xe(c.state).map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Owner",e.createElement("select",{required:!0,value:$,onChange:t=>fe(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),M.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",{required:!0,value:ye,onChange:t=>ke(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),M.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Change due date and time (optional)",e.createElement("input",{type:"datetime-local",value:he,onChange:t=>be(t.target.value)})),e.createElement("label",{className:"field"},"What changed or was fixed?",e.createElement("textarea",{required:!0,minLength:3,maxLength:2e3,value:R,onChange:t=>S(t.target.value)})),e.createElement("button",{className:"primary",disabled:j||!v},"Save case update")),e.createElement("h3",null,"Status history"),K.map(t=>e.createElement("p",{key:t.id},e.createElement("strong",null,t.state)," · ",B(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: ",B(t.snapshot.owner_id)," · Supervisor: ",B(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."),ue.map(t=>e.createElement("p",{key:t.id},Oe(t.kind)," · ",Fe(t.status)," · attempts ",t.attempts,t.last_error?" · "+Ce(t.last_error):"")))))}function ot({client:o,user:u,onChange:b}){var F;const[l,s]=r.useState(null),[E,ae]=r.useState([]),[k,U]=r.useState([]),[w,O]=r.useState(null),[M,z]=r.useState(""),[de,I]=r.useState(""),[K,A]=r.useState(""),[ue,m]=r.useState(""),[Z,f]=r.useState(""),[j,C]=r.useState(""),[_,W]=r.useState(!1),[re,H]=r.useState([]),[me,Q]=r.useState([]),ne=((F=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:F.registrationEnabled)===!0;async function y(){if(!u){s(null),H([]),Q([]);return}const n=await Ue(o);s(n);const{data:v,error:h}=await o.auth.mfa.listFactors();if(h)throw h;const R=(v.totp||[]).filter(S=>S.status==="verified");if(ae(R),U((v.all||[]).filter(S=>S.factor_type==="totp"&&S.status==="unverified")),I(S=>{var x;return R.some(J=>J.id===S)?S:((x=R[0])==null?void 0:x.id)||""}),n.role==="developer"&&n.approved&&n.aal2){const[S,x]=await Promise.all([o.rpc("defectrag_access_directory"),o.rpc("defectrag_notification_status")]);if(S.error)throw S.error;if(x.error)throw x.error;H(S.data||[]),Q(x.data||[])}else H([]),Q([])}async function D(n){W(!0),C("");try{await n()}catch(v){C(v.message||"Security request failed.")}finally{W(!1)}}r.useEffect(()=>{let n=!0;return O(null),z(""),H([]),Q([]),o&&u?y().catch(v=>{n&&C(v.message)}):s(null),()=>{n=!1}},[o,u==null?void 0:u.id]);async function pe(){await We(o,(w==null?void 0:w.id)||de,M),z(""),O(null),await y(),b(),C("Security code verified. Staff access is available only after the account is approved.")}return e.createElement("div",{className:"section-gap"},e.createElement("h3",null,"Sign-in and account security"),j&&e.createElement("p",{className:"note",role:"status"},Ce(j)),u?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,l!=null&&l.revoked?"revoked":l!=null&&l.approved?"approved":(l==null?void 0:l.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,l!=null&&l.aal2?"security code verified":"enter security code")),e.createElement("button",{className:"secondary",disabled:_,onClick:()=>D(y)},"Refresh account status"),l&&!l.approved&&!l.revoked&&!l.request_status&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),D(async()=>{await ze(o,K),await y(),C("Request sent. Check back here for Developer approval. Team and private Staff work are not available while the request is waiting."),b()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:K,maxLength:80,onChange:n=>A(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:_||!l.registration_enabled||!l.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."),!w&&!E.length&&!k.length&&e.createElement("button",{className:"secondary",disabled:_,onClick:()=>D(async()=>O(await Ie(o)))},"Set up a security code app"),!w&&k.map(n=>e.createElement("p",{key:n.id,className:"caption"},"Authenticator setup was not finished. ",e.createElement("button",{className:"text-button",disabled:_,onClick:()=>D(async()=>{const{error:v}=await o.auth.mfa.unenroll({factorId:n.id});if(v)throw v;await y()})},"Cancel incomplete setup"))),w&&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:w.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:_,onClick:()=>D(async()=>{const{error:n}=await o.auth.mfa.unenroll({factorId:w.id});if(n)throw n;O(null),z("")})},"Cancel incomplete setup"))),(w||E.length>0)&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),D(pe)}},!w&&e.createElement("label",{className:"field"},"Security code app",e.createElement("select",{value:de,onChange:n=>I(n.target.value)},E.map(n=>e.createElement("option",{key:n.id,value:n.id},n.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:M,onChange:n=>z(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:_},"Verify security code")),(l==null?void 0:l.role)==="developer"&&l.approved&&l.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,re.map(n=>e.createElement("tr",{key:n.user_id},e.createElement("td",null,n.display_name,e.createElement("br",null),e.createElement("small",null,n.email)),e.createElement("td",null,n.status),e.createElement("td",null,n.role||"applicant"),e.createElement("td",null,n.user_id!==u.id&&(n.status==="pending"?["approve","reject"]:n.status==="approved"?["revoke"]:[]).map(v=>e.createElement("button",{key:v,className:"text-button",disabled:_,onClick:()=>{window.confirm(`${v[0].toUpperCase()+v.slice(1)} access for ${n.display_name}?`)&&D(async()=>{await je(o,n,v),await y(),b(),C("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"}[v])))))))),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,me.map(n=>e.createElement("tr",{key:n.id},e.createElement("td",null,Oe(n.kind)),e.createElement("td",null,Fe(n.status)),e.createElement("td",null,n.attempts),e.createElement("td",null,n.status==="dead"&&e.createElement("button",{className:"text-button",disabled:_,onClick:()=>D(async()=>{const{error:v}=await o.rpc("defectrag_retry_notification",{p_id:n.id});if(v)throw v;await y()})},"Retry delivery"))))))))):ne?e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),D(async()=>{await Me(o,{email:ue,password:Z,displayName:K,redirectTo:location.origin+location.pathname}),f(""),C("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:K,onChange:n=>A(n.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:ue,onChange:n=>m(n.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:Z,onChange:n=>f(n.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:_||!o},"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 ut({onOpenInspection:o,onOpenCorrectiveActions:u,onChooseInspection:b,casesView:l=!1,initialInspectionId:s=null}){var qe;const E=r.useRef(0),ae=r.useRef(null),k=r.useRef(0),U=r.useRef(null),w=r.useRef(0),O=r.useRef(null),M=r.useRef(null),[z,de]=r.useState(0),[I,K]=r.useState(!1),[A,ue]=r.useState({state:"refreshing"}),[m,Z]=r.useState(null),[f,j]=r.useState(null),[C,_]=r.useState([]),[W,re]=r.useState({}),[H,me]=r.useState(""),[Q,ne]=r.useState(""),[y,D]=r.useState(!1),[pe,F]=r.useState(""),[n,v]=r.useState(!1),[h,R]=r.useState(null),[S,x]=r.useState([]),[J,$]=r.useState([]),[fe,ye]=r.useState(""),[ke,he]=r.useState(!1),[be,c]=r.useState(""),[le,Y]=r.useState(!1),[we,Ee]=r.useState(null),G=He(),B=Be(window.DEFECTRAG_PUBLIC_CONFIG);r.useEffect(()=>()=>{S.filter(a=>a.startsWith("blob:")).forEach(a=>URL.revokeObjectURL(a))},[S]),r.useEffect(()=>{U.current=h},[h]),r.useEffect(()=>{h&&De(O.current)},[z]),r.useEffect(()=>{if(!m||!f||!s)return;const a=m.id+":"+s;M.current!==a&&(M.current=a,L({id:s},{focus:!l}))},[m==null?void 0:m.id,f==null?void 0:f.user_id,s]);const t=Ge();async function p(a){D(!0),F("");try{await a()}catch(i){F(i.message||"Team request failed.")}finally{D(!1)}}async function g(){var T;const a=++k.current,i=E.current,d=(T=U.current)==null?void 0:T.id,{client:q,staff:Se}=await Je();let N=q.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);N=n?N.not("archived_at","is",null):N.is("archived_at",null);const[{data:X,error:ce},{data:_e,error:V},ve]=await Promise.all([N,q.from("staff_members").select("*"),d?q.from("staff_notes").select("*").eq("inspection_id",d).order("created_at"):{data:[]}]);if(ce)throw ce;if(V)throw V;if(ve.error)throw ve.error;if(a===k.current&&(j(Se),F(""),_(X||[]),re(Object.fromEntries((_e||[]).map(ee=>[ee.user_id,ee.display_name]))),d&&i===E.current)){const ee=(X||[]).find(ie=>ie.id===d);if(!ee)E.current++,R(null),x([]),$([]);else if(R(ee),$(ve.data||[]),Date.now()-w.current>480*1e3)if(G){const ie=await Ae(q,ee);a===k.current&&i===E.current?(x(ie),w.current=Date.now()):ie.forEach(oe=>URL.revokeObjectURL(oe))}else{const ie=await Promise.all([ee.image_path,ee.heatmap_path].map(oe=>q.storage.from("team-inspections").createSignedUrl(oe,900)));if(a===k.current&&i===E.current){if(ie.some(oe=>oe.error))throw new Error("Shared image links could not refresh.");x(ie.map(oe=>oe.data.signedUrl)),w.current=Date.now()}}}}r.useEffect(()=>{if(!t)return;let a=!1,i;return P().then(async d=>{!a&&G&&Ee(d),i=d.auth.onAuthStateChange((Se,N)=>{var X;if(!a){const ce=((X=N==null?void 0:N.user)==null?void 0:X.id)||null;ae.current!==ce&&(E.current++,k.current++,R(null),_([]),x([]),$([]),j(null),ae.current=ce),Z((N==null?void 0:N.user)||null),Se==="PASSWORD_RECOVERY"&&he(!0)}}).data.subscription;const{data:q}=await d.auth.getUser();a||Z(q.user)}).catch(d=>{a||F(d.message)}),()=>{a=!0,E.current++,i==null||i.unsubscribe()}},[t]),r.useEffect(()=>{if(!m)return;const a=Pe(g,{onState:i=>{ue(i),i.error&&(F(i.error),G&&(E.current++,_([]),re({}),R(null),x([]),$([]),j(null)))}});return()=>{a.stop(),k.current++}},[m==null?void 0:m.id,n]);async function L(a,{focus:i=!0}={}){const d=++E.current;K(!0);try{await p(async()=>{if(d!==E.current)return;const q=await P(),Se=q.storage.from("team-inspections"),[{data:N,error:X},{data:ce,error:_e}]=await Promise.all([q.from("shared_inspections").select("*").eq("id",a.id).single(),q.from("staff_notes").select("*").eq("inspection_id",a.id).order("created_at")]);if(d!==E.current)return;if(X)throw X;if(_e)throw _e;const V=G?await Ae(q,N):null,ve=V?V.map(T=>({data:{signedUrl:T}})):await Promise.all([N.image_path,N.heatmap_path].map(T=>Se.createSignedUrl(T,900)));if(ve.some(T=>T.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(d!==E.current){V==null||V.forEach(T=>URL.revokeObjectURL(T));return}U.current=N,w.current=Date.now(),R(N),x(ve.map(T=>T.data.signedUrl)),$(ce||[]),i&&de(T=>T+1)})}finally{d===E.current&&K(!1)}}async function se(){await p(async()=>{const a=await P(),i=C.filter(d=>d.owner_id===m.id).map(d=>d.id);if(i.length){const{error:d}=await a.rpc("archive_team_inspections",{p_ids:i});if(d)throw d}E.current++,R(null),Y(!1),await g(),ge()})}return t?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(nt,{size:21})," ",l?"Corrective Actions access":"Staff workspace"),e.createElement("p",null,"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(Re,{size:13})," STAFF ACCESS")),pe&&e.createElement("div",{className:"error",role:"alert"},Ce(pe)),I&&e.createElement("p",{role:"status"},"Opening the shared photo and review…"),l&&!B&&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."),G&&we&&(!l||!f)&&e.createElement(ot,{key:(m==null?void 0:m.id)||"anonymous",client:we,user:m,onChange:()=>{ge(),m&&p(g)}}),m?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(Qe,{size:18}),e.createElement("strong",null,(f==null?void 0:f.display_name)||m.email),e.createElement("span",{className:"subtle-tag"},(f==null?void 0:f.role)||"CHECKING ACCESS")),e.createElement("button",{className:"secondary",disabled:y,onClick:()=>p(g)},e.createElement(at,{size:16})," Refresh"),!l&&f&&B&&e.createElement("button",{className:"secondary",onClick:()=>u==null?void 0:u()},"Open Corrective Actions"),l&&f&&e.createElement("button",{className:"secondary",onClick:()=>b==null?void 0:b()},"Choose a Team inspection"),e.createElement("button",{className:"secondary",onClick:()=>p(async()=>{await(await P()).auth.signOut(),_([]),R(null),j(null)})},e.createElement(tt,{size:16})," Sign out")),ke&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),p(async()=>{const i=await P(),{error:d}=await i.auth.updateUser({password:be});if(d)throw d;c(""),he(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:be,onChange:a=>c(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},"Save password")),!l&&e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",C.length," shared inspections · ",A.state==="synced"?"updated at "+new Date(A.at).toLocaleTimeString():A.state==="offline"?"offline; shown results may be out of date":A.state==="stale"?"update failed; shown results may be out of date":"refreshing…"," · checks for changes every 15 seconds"),(f==null?void 0:f.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{v(!n),R(null)}},e.createElement(Xe,{size:16}),n?"Active history":"Restore archived team work"),!n&&e.createElement("button",{className:"secondary danger",disabled:y||!C.some(a=>a.owner_id===m.id),onClick:()=>Y(!0)},e.createElement($e,{size:16})," Archive my shared inspections")),le&&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:y,onClick:se},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>Y(!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,C.map(a=>{var i;return e.createElement("tr",{key:a.id},e.createElement("td",null,e.createElement("strong",null,a.id.slice(0,8))),e.createElement("td",null,a.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((i=a.payload.verdict)==null?void 0:i.toLowerCase())},Le(a.payload.verdict))),e.createElement("td",null,W[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:y,onClick:()=>L(a)},"Review"),n&&(f==null?void 0:f.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:y,onClick:()=>p(async()=>{const d=await P(),{error:q}=await d.rpc("restore_team_inspections",{p_ids:[a.id]});if(q)throw q;await g(),ge()})},"Restore")))}))),!C.length&&e.createElement("div",{className:"empty"},e.createElement(Re,{size:30}),e.createElement("p",null,n?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with team."))))):e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),p(async()=>{const i=await P(),{error:d}=await i.auth.signInWithPassword({email:H,password:Q});if(d)throw d;ne("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:H,onChange:a=>me(a.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:Q,onChange:a=>ne(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},y?e.createElement(Ke,{className:"spin",size:17}):e.createElement(et,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!H||y,onClick:()=>p(async()=>{const a=await P(),{error:i}=await a.auth.resetPasswordForEmail(H,{redirectTo:location.origin+location.pathname});if(i)throw i;F("Password reset requested. Check the inbox and Spam folder.")})},"Reset password"),e.createElement("p",{className:"caption"},G?"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."))),l&&m&&f&&B&&e.createElement(it,{key:m.id,user:m,inspection:h,notes:J,onEvidence:a=>L({id:a})}),m&&h&&e.createElement("section",{className:"card",ref:O,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 ",W[h.owner_id]||"a colleague",". These are saved results. Opening them does not run another inspection.")),e.createElement("div",{className:"button-row"},o&&!h.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>o(h)},"Open full result and assistant"),!l&&B&&!h.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>u==null?void 0:u(h)},"Create or view corrective actions"),e.createElement("button",{className:"text-button",onClick:()=>{E.current++,U.current=null,R(null),x([]),$([])}},"Close"))),e.createElement("div",{className:"shared-images"},S.map((a,i)=>e.createElement("img",{key:a,src:a,alt:i?"Saved highlighted areas":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED RESULT"),e.createElement("span",null,Le(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"),(qe=h.conversation)!=null&&qe.length?h.conversation.map((a,i)=>e.createElement("p",{className:"cloud-message",key:i},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(Ye,{key:h.id+String(J.length),current:J.map(a=>Ne(a,W)).filter(Boolean).at(-1),disabled:y,onSave:async a=>{const i=await P(),{error:d}=await i.from("staff_notes").insert({inspection_id:h.id,author_id:m.id,body:Ze(a.status,a.decision,a.note)});if(d)throw d;await L(h),ge()}}),e.createElement("h3",{className:"section-gap"},"Team notes"),J.filter(a=>!Ne(a,W)).map(a=>e.createElement("div",{className:"cloud-message",key:a.id},e.createElement("strong",null,W[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(),p(async()=>{const i=await P(),{error:d}=await i.from("staff_notes").insert({inspection_id:h.id,author_id:m.id,body:fe.trim()});if(d)throw d;ye(""),await L(h),ge()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a note for the team…",value:fe,onChange:a=>ye(a.target.value)}),e.createElement("button",{className:"primary",disabled:y||!fe.trim()},e.createElement(rt,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(Re,{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,i,d])=>e.createElement("div",{key:a},e.createElement("b",null,a),e.createElement("h3",null,i),e.createElement("p",null,d)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Administrator setup ",e.createElement(Ve,{size:16})),e.createElement("p",{className:"caption"},"Contact the workspace administrator for help. The public demo can be used without Staff access."))}export{ut as default};
|
frontend/dist/assets/index-D5pBAfRX.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="#132e32"/><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-
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.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="#132e32"/><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-D5pBAfRX.js"></script>
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|