import{q as w,j as a,J as b}from"./app-DB4YCWeF.js";import{A as j}from"./AuthenticatedLayout-DqLtl3fm.js";import{d as D,T as _,D as g,R as y,a as v,b as S}from"./DetailModalContent-CbTh58kC.js";import{M as u}from"./WithModal-BI-p938E.js";import{u as f,g as o}from"./BaseForm-CkSb_d40.js";import{b as k,s as M}from"./lib-C9iOZMGt.js";import"./clsx-B-dksMZM.js";import"./Select-DXXQNVxU.js";import"./index-D_LogWT2.js";function L(e){var r,n,s,x;const c=N(),m=A(),[t,h]=k(M),i=l=>{h(l)};return a.jsxs(j,{title:e==null?void 0:e.title,children:[a.jsx(_,{search:!0,filter:!0,filterOptions:m,tableHeader:c,tableBody:((n=e==null?void 0:e[(r=e==null?void 0:e.page)==null?void 0:r.name])==null?void 0:n.data)??[],tablePage:(x=e==null?void 0:e[(s=e==null?void 0:e.page)==null?void 0:s.name])==null?void 0:x.links,headerButton:()=>{var l,d;return a.jsx(a.Fragment,{children:a.jsxs(b,{href:`${(l=e==null?void 0:e.page)==null?void 0:l.url}/create`,className:"btn btn-primary w-max btn-sm text-white",children:["Tambah ",(d=e==null?void 0:e.page)==null?void 0:d.label]})})},tableAction:l=>{var d;return a.jsxs(a.Fragment,{children:[a.jsx("li",{children:a.jsx(u,{id:`detail_${l==null?void 0:l.id}`,onClick:()=>i(l),children:a.jsx("span",{children:"Lihat Detail"})})}),l.deleted_at?a.jsx("li",{children:a.jsx(u,{id:`modal_restore_${l==null?void 0:l.id}`,onClick:()=>i(l),children:"Pulihkan Data"})}):a.jsx("li",{children:a.jsx(b,{href:`${(d=e==null?void 0:e.page)==null?void 0:d.url}/${l.id}/edit`,className:"",children:"Edit"})}),a.jsx("li",{children:a.jsxs(u,{id:`modal_delete_${l==null?void 0:l.id}`,onClick:()=>i(l),children:["Hapus ",l.deleted_at?"Permanen":""]})})]})}}),t?a.jsxs(a.Fragment,{children:[a.jsx(g,{id:t==null?void 0:t.id,label:t.name,isForceDelete:t.deleted_at!=null,handleClick:()=>i(null)}),a.jsx(y,{id:t==null?void 0:t.id,label:t.name,handleClick:()=>i(null)}),a.jsx(v,{id:t==null?void 0:t.id,tableHeader:c,data:t,handleClick:()=>i(null),content:l=>S(l,c),size:"max-w-2xl"})]}):null]})}const N=()=>{const{page:e,isAdmin:c,location:m}=w().props,{params:t}=f(m);return[{label:"#",value:"id",type:"numbering"},{label:"Nama",value:"name",isSearchable:!0,isModalDetail:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"No. Hp",value:"phone",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Tanggal Lahir",value:"birth_date",type:"date",dateFormat:"DD MMM YYYY",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Umur",value:"birth_date",className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre",isDetail:!1,isSortable:!1,custom:({data:i,key:r,header:n,defaultClassName:s})=>a.jsx("td",{className:`${s==null?void 0:s.tdBodyClassName} ${(n==null?void 0:n.className)??""}`,children:a.jsx("p",{children:o(i.birth_date)})},r)},{label:"Umur",value:"birth_date",isDetail:!0,custom:({data:i,key:r,header:n,defaultClassName:s})=>a.jsx("div",{children:a.jsx(D,{label:n==null?void 0:n.label,...s,children:a.jsx("p",{children:o(i.birth_date)})})},r)},{label:"Jenis Kelamin",value:"gender",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Alamat",value:"address",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[300px] !whitespace-pre"},{label:"Riwayat Penyakit",value:"medical_history",type:"list",isSearchable:!0,isDetail:!0},{label:"Alergi Obat",value:"medication_allergy",type:"list",isSearchable:!0,isDetail:!0},{label:"Ditambahkan",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:t.get("deleted_at")!="show"},{label:"Aksi",value:"id",type:"action"}]},A=()=>{const{props:e}=w();return[{name:"deleted_at",label:"Filter Data Terhapus"}]};export{L as default,N as useTableHeader};
