import{u as _,c as C,w as m,a as e,o as i,b as r,F as S,r as h,t as d,l as A,e as M,f as a,g as N,h as u,v as p,i as D,j as v,k as U}from"./app-C3b5PNmt.js";import{_ as $}from"./Layout-CoWQewh6.js";import{_ as x}from"./Modal-Dd-zhKqp.js";const V={class:"panel"},B={key:0,class:"badge b-green"},E={key:1,class:"badge b-grey"},T={class:"row-actions"},F=["onClick"],R=["onClick"],q={class:"field"},I={class:"field"},L={class:"field"},j={class:"modal-actions"},z=["disabled"],K={__name:"Index",props:{users:Array},setup(c){const o=U(!1),s=_({id:null,name:"",role:"technician",department:"Telecom & Navigation"}),b=l=>({technician:"Technician",supervisor:"Supervisor",management:"Management",administrator:"Administrator"})[l]||l,f=()=>{s.reset(),s.id=null,o.value=!0},g=l=>{s.id=l.id,s.name=l.name,s.role=l.role,s.department=l.department,o.value=!0},w=()=>{s.id?s.put(window.route("users.update",s.id),{onSuccess:()=>o.value=!1}):s.post(window.route("users.store"),{onSuccess:()=>o.value=!1})},k=l=>{l.active?confirm("Deactivate this user?")&&v.delete(window.route("users.destroy",l.id)):v.put(window.route("users.update",l.id),{active:!0})};return(l,t)=>(i(),C($,null,{default:m(()=>[t[10]||(t[10]=e("h2",{class:"page-title"},"User & Role Management",-1)),t[11]||(t[11]=e("p",{class:"page-sub"},"Add, edit, or deactivate users.",-1)),e("div",{class:"toolbar"},[e("button",{class:"btn-primary",onClick:f},"+ New user")]),e("div",V,[e("table",null,[t[5]||(t[5]=e("thead",null,[e("tr",null,[e("th",null,"Name"),e("th",null,"Role"),e("th",null,"Department"),e("th",null,"Status"),e("th")])],-1)),e("tbody",null,[(i(!0),r(S,null,h(c.users,n=>(i(),r("tr",{key:n.id},[e("td",null,d(n.name),1),e("td",null,d(b(n.role)),1),e("td",null,d(n.department),1),e("td",null,[n.active?(i(),r("span",B,"Active")):(i(),r("span",E,"Inactive"))]),e("td",T,[e("button",{class:"btn-sm",onClick:y=>g(n)},"Edit",8,F),e("button",{class:A(["btn-sm",n.active?"red":"green"]),onClick:y=>k(n)},d(n.active?"Deactivate":"Activate"),11,R)])]))),128))])])]),M(x,{show:o.value,title:a(s).id?"Edit User":"New User",onClose:t[4]||(t[4]=n=>o.value=!1)},{default:m(()=>[e("form",{onSubmit:N(w,["prevent"])},[e("div",q,[t[6]||(t[6]=e("label",null,"Name",-1)),u(e("input",{"onUpdate:modelValue":t[0]||(t[0]=n=>a(s).name=n),required:""},null,512),[[p,a(s).name]])]),e("div",I,[t[8]||(t[8]=e("label",null,"Role",-1)),u(e("select",{"onUpdate:modelValue":t[1]||(t[1]=n=>a(s).role=n),required:""},[...t[7]||(t[7]=[e("option",{value:"technician"},"Technician",-1),e("option",{value:"supervisor"},"Supervisor",-1),e("option",{value:"management"},"Management",-1),e("option",{value:"administrator"},"Administrator",-1)])],512),[[D,a(s).role]])]),e("div",L,[t[9]||(t[9]=e("label",null,"Department",-1)),u(e("input",{"onUpdate:modelValue":t[2]||(t[2]=n=>a(s).department=n)},null,512),[[p,a(s).department]])]),e("div",j,[e("button",{type:"button",class:"btn-sm",onClick:t[3]||(t[3]=n=>o.value=!1)},"Cancel"),e("button",{type:"submit",class:"btn-primary",disabled:a(s).processing},"Save",8,z)])],32)]),_:1},8,["show","title"])]),_:1}))}};export{K as default};
