import{j as e,q as c,J as v}from"./app-Bup04Qnx.js";import{A as D}from"./AuthenticatedLayout-BdDF4YYO.js";import{M as u}from"./WithModal-CbKxT3eW.js";import{T as w}from"./Table-B-yOTLCP.js";import{D as _,R as S}from"./RestoreModal-DxRPbH67.js";import{u as g}from"./format-CisCU4Rs.js";import{u as y,s as k}from"./index-Dy_g3AZ5.js";import{D as C,a as F}from"./DetailModalContent-BPB3mCJa.js";import"./index-DdNKWgRS.js";import"./clsx-B-dksMZM.js";import"./index-CtjruoRR.js";import"./floating-ui.dom-CwWDmSD9.js";import"./Select-Cs0aMrtU.js";import"./BaseForm-wkPKZ5Eg.js";import"./table-2-B1MKhBGJ.js";import"./DetailModalItem-BOaAAJ7m.js";function d(a){return e.jsx(D,{title:a==null?void 0:a.title,children:e.jsx(p,{})})}const p=a=>{var m,h,x;let{tableHeader:r=null}=a;const{props:l}=c();r||(r=j());const o=f(),[i,n]=y(k),s=t=>{n(t)};return e.jsxs(e.Fragment,{children:[e.jsx(w,{search:!0,filter:!0,filterOptions:o,tableHeader:r,tableBody:((h=l==null?void 0:l[(m=l==null?void 0:l.page)==null?void 0:m.name])==null?void 0:h.data)??[],tablePage:l==null?void 0:l[(x=l==null?void 0:l.page)==null?void 0:x.name],tableAction:t=>{var b;return e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx(u,{id:`detail_${t==null?void 0:t.id}`,onClick:()=>s(t),children:e.jsx("span",{children:"Lihat Selengkapnya"})})}),t.deleted_at?e.jsx("li",{children:e.jsx(u,{id:`modal_restore_${t==null?void 0:t.id}`,onClick:()=>s(t),children:"Pulihkan Data"})}):e.jsx("li",{children:e.jsx(v,{href:`${(b=l==null?void 0:l.page)==null?void 0:b.url}/${t.id}/edit`,className:"",children:"Edit"})}),e.jsx("li",{children:e.jsxs(u,{id:`modal_delete_${t==null?void 0:t.id}`,onClick:()=>s(t),children:["Hapus ",t.deleted_at?"Permanen":""]})})]})},...a}),i?e.jsxs(e.Fragment,{children:[e.jsx(_,{id:i==null?void 0:i.id,label:i.name,isForceDelete:i.deleted_at!=null,handleClick:()=>s(null)}),e.jsx(S,{id:i==null?void 0:i.id,label:i.name,handleClick:()=>s(null)}),e.jsx(C,{id:i==null?void 0:i.id,tableHeader:r,data:i,handleClick:()=>s(null),content:t=>F(t,r),size:"max-w-2xl"})]}):null]})},j=()=>{var n;const{page:a,location:r,auth:l}=c().props,{params:o}=g(r);return[{label:"#",value:"id",type:"numbering"},{label:"Nama",value:"name",isSearchable:!0,isModalDetail:!0},{label:"Email",value:"email",isSearchable:!0},{label:"Username",value:"username",isDetail:!0},{label:"WhatsApp",value:"phone"},{label:"Role",value:"role"},{isHidden:!["director"].includes((n=l==null?void 0:l.user)==null?void 0:n.role),label:"Dibuat Oleh",value:"owner.name",isSearchable:!0,isSortable:!1,defaultValue:"-"},{label:"Status",value:"status",type:"status",typeCase:"lowerCase",className:"w-[10%]"},{label:"Dibuat",value:"created_at",type:"date",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Diperbarui",value:"updated_at",type:"date",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Dihapus",value:"deleted_at",type:"date",isHidden:o.get("deleted_at")!="show",className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Aksi",value:"id",type:"action",className:"w-[10%]"}]},f=()=>{const{props:a}=c();return[{name:"role",data:a==null?void 0:a.roles,label:"Pilih Role"},{name:"status",data:a==null?void 0:a.status,label:"Filter Status"},{name:"deleted_at",label:"Filter Data Terhapus"}]},M=({children:a})=>{const r=j();return a(r)},P=({children:a})=>{const r=f();return a(r)};d.Table=p;d.HeaderProvider=M;d.FilterProvider=P;const W=d;export{W as default};
