import{j as e,q as m}from"./app-Bup04Qnx.js";import{A as j}from"./AuthenticatedLayout-BdDF4YYO.js";import{T as v}from"./Table-B-yOTLCP.js";import{M as g}from"./WithModal-CbKxT3eW.js";import{u as N}from"./format-CisCU4Rs.js";import{D as w,a as T}from"./DetailModalContent-BPB3mCJa.js";import{u as C,s as D}from"./index-Dy_g3AZ5.js";import{E as P}from"./eye-COhjizRe.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 u(t){return e.jsx(j,{title:t==null?void 0:t.title,children:e.jsx(h,{})})}const h=t=>{var c,r,i;let{tableHeader:n=null}=t;const{props:l}=m();n||(n=b());const x=f(),[s,o]=C(D),d=a=>{o(a)};return e.jsxs(e.Fragment,{children:[e.jsx(v,{search:!0,filter:!0,filterOptions:x,tableHeader:n,addButton:!1,tableBody:((r=l==null?void 0:l[(c=l==null?void 0:l.page)==null?void 0:c.name])==null?void 0:r.data)??[],tablePage:l==null?void 0:l[(i=l==null?void 0:l.page)==null?void 0:i.name],tableAction:a=>e.jsx(e.Fragment,{children:e.jsx("li",{className:"mb-1",children:e.jsxs(g,{id:`detail_${a==null?void 0:a.id}`,onClick:()=>d(a),className:"menu-item-action",children:[e.jsx(P,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{children:"Lihat Selengkapnya"})]})})}),...t}),s?e.jsx(e.Fragment,{children:e.jsx(w,{id:s==null?void 0:s.id,tableHeader:n,data:s,handleClick:()=>d(null),content:a=>T(a,n),size:"max-w-2xl"})}):null]})},b=()=>{const{page:t,isAdmin:n,location:l}=m().props;return N(l),[{label:"#",value:"id",type:"numbering"},{value:"code",label:"Kode Transaksi",isSearchable:!0},{value:"name",label:"Nama Barang/Jasa",isSearchable:!0},{value:"description",label:"Keterangan",type:"text"},{value:"price",label:"Harga",type:"currency"},{value:"quantity_units.quantity",label:"Kuantitas & Satuan",className:"w-[10%]",isDefaultLabel:!0,wrapperClassName:"flex flex-wrap justify-between",custom:({data:s,key:o,header:d,defaultClassName:c,isTable:r=!0})=>{var a;const i=r?"td":"div";return e.jsx(i,{children:e.jsx("ul",{className:"list-disc list-inside",children:(a=s==null?void 0:s.quantity_units)==null?void 0:a.map((p,y)=>e.jsxs("li",{children:[p.quantity," ",p.unit_type.name]},y))})},o)}},{value:"price_total",label:"Total Pembelian",type:"currency"},{value:"status",label:"Status",prefix:"transaction.status",type:"status"},{value:"status_message",label:"Catatan Penolakan",isDetail:!0,isHidden:"not null"},{label:"Disubmit Pada",value:"created_at",type:"date",isDetail:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{value:"vendor",label:"Vendor",isDefaultLabel:!0,isHidden:"not null",wrapperClassName:"flex flex-col justify-between",custom:({data:s,key:o,header:d,defaultClassName:c,isTable:r=!0})=>{const i=r?"td":"div",a=s==null?void 0:s.vendor;return a?e.jsx(i,{className:r?c:"",children:e.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px] p-2 rounded border border-gray-100",children:[e.jsx("div",{className:"font-bold text-gray-800 text-sm",children:a.company_name||"-"}),e.jsxs("div",{className:"text-sm text-gray-600 flex items-center gap-1",children:[e.jsx("span",{className:"font-semibold w-8",children:"PIC:"}),e.jsx("span",{children:a.name||"-"})]}),e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-2 mt-1 border-t border-gray-200 pt-1",children:[e.jsx("span",{children:a.phone||"-"}),e.jsx("span",{children:"•"}),e.jsx("span",{children:a.city||"-"})]})]})},o):e.jsx(i,{children:"-"},o)}},{value:"attachments",label:"Lampiran",type:"gallery",wrapperClassName:"flex flex-col",valueClassName:"border py-2 px-4",isDetail:!0,isHidden:"not null"}]},f=()=>{const{props:t}=m();return[{name:"status",data:(t==null?void 0:t.status)??[],label:"Filter Status",prefix:"transaction.status"},{name:"type",data:(t==null?void 0:t.type)??[],label:"Filter Tipe Transaksi",prefix:"transaction.type"}]},S=({children:t})=>{const n=b();return t(n)},F=({children:t})=>{const n=f();return t(n)};u.Table=h;u.HeaderProvider=S;u.FilterProvider=F;const $=u;export{$ as default};
