import{q as f,R as b,v,j as e,$ as N,Y as P}from"./app-BGey7YPf.js";import{h as n,A as T}from"./app-layout-mnJEmZ7X.js";import{H as w}from"./header-D0w47C-P.js";import{T as y,a as k,b as A,c as C,d as o,e as t,f as D,g as H,h as r}from"./table-C3FnqSRz.js";import{B}from"./button-D5r5edT8.js";import{B as l}from"./badge-BVty0UEZ.js";import{C as M,A as E,M as R,P as F}from"./page-pagination-D1u9TBBY.js";import"./chevron-right-CE_1krjA.js";import"./separator-Di-l93J0.js";import"./input-CGSIKYsG.js";import"./icons-hx7HvmR4.js";import"./index-BFyaOBDQ.js";import"./x-C4WIHhXm.js";import"./index-Q2wK6uZI.js";import"./index-CwO5dfCw.js";import"./theme-provider-NKMbg-kV.js";import"./use-toast-DGElh_6W.js";import"./select-BqSuhmAT.js";import"./index-BuSoVzfP.js";import"./chevron-down-DOZGaFlM.js";import"./dialog-OAe1w9Cd.js";import"./trash-Blc6Iqr5.js";import"./chevron-left-7ssMp1N3.js";function S(){const{users:s,currentPage:c,perPage:m}=f().props,[p,d]=b.useState(!1),{data:x,setData:h}=v({id:""}),u=a=>{d(!0),h(i=>({...i,id:a.id}))};return e.jsxs(e.Fragment,{children:[e.jsx(N,{title:"Pengguna"}),e.jsx(w,{title:"Pengguna",subtitle:"Halaman ini digunakan untuk mengelola data pengguna",children:n(["users-create"])&&e.jsx(B,{asChild:!0,variant:"outline",children:e.jsxs(P,{href:route("apps.users.create"),children:[e.jsx(M,{className:"size-4"})," ",e.jsx("span",{className:"hidden sm:inline-flex",children:"Tambah Pengguna"})]})})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-5",children:e.jsx(y,{withFilterPage:!0,currentPage:c,perPage:m,url:route("apps.users.index"),placeholder:"Cari data pengguna berdasarkan nama, email, atau username"})}),e.jsx(k,{children:e.jsxs(A,{children:[e.jsx(C,{children:e.jsxs(o,{children:[e.jsx(t,{className:"w-[10px] text-center",children:"No"}),e.jsx(t,{children:"Nama"}),e.jsx(t,{children:"Username"}),e.jsx(t,{children:"Email"}),e.jsx(t,{children:"Akses Group"}),e.jsx(t,{className:"w-[10px] text-center",children:"Status"}),e.jsx(t,{className:"w-[10px] text-center",children:"Aksi"})]})}),e.jsx(D,{children:s.data.length===0?e.jsx(H,{colSpan:4,message:"data akses group"}):s.data.map((a,i)=>e.jsxs(o,{children:[e.jsx(r,{className:"text-center",children:++i+(s.current_page-1)*s.per_page}),e.jsx(r,{children:a.name}),e.jsx(r,{children:a.username}),e.jsx(r,{children:a.email}),e.jsx(r,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.roles.slice(0,3).map((j,g)=>e.jsx(l,{variant:"destructive",children:j.name},g)),a.roles.length>4&&e.jsxs(l,{variant:"destructive",children:["+ ",a.roles.length-4," lainnya"]})]})}),e.jsx(r,{className:"text-center",children:a.is_active?e.jsx(l,{variant:"default",children:"Aktif"}):e.jsx(l,{variant:"secondary",children:"Nonaktif"})}),e.jsx(r,{children:e.jsx("div",{className:"flex items-center justify-center",children:(n(["users-update"])||n(["users-delete"])||n(["users-show"]))&&e.jsx(E,{permissionPrefix:"users",withDetail:!0,actionDetailHref:route("apps.users.show",a.id),actionEditHref:route("apps.users.edit",a.id),actionDelete:()=>u(a)})})})]},i))})]})}),e.jsx(R,{open:p,onOpenChange:d,url:route("apps.users.destroy",x.id)}),e.jsx(F,{data:s})]})]})}S.layout=s=>e.jsx(T,{children:s});export{S as default};
