import{u as b,G as f,a as g,j as e,H as N,L as P}from"./app-CyJEXGyv.js";import{A as T,u as n}from"./app-layout-DbUGBUec.js";import{P as k}from"./page-pagination-f8WRSjxd.js";import{T as C,a as w,b as y,c as D,d,e as s,f as v,g as B,h as r}from"./table-fuaFg2Mm.js";import{B as H}from"./button-COEJSQkW.js";import{B as S}from"./badge-BSEA-Kjk.js";import{A as _,M as A}from"./modal-delete-CUfNw5Hz.js";import{H as L}from"./heading-BLley4b9.js";import{C as M}from"./trash-BflsAFp1.js";import{C as z}from"./circle-x-DtHfKmuw.js";import{C as F}from"./circle-pause-By97QX3L.js";import{C as E}from"./circle-check-big-D2NZJssq.js";import"./utils-D3rN0LeJ.js";import"./sheet-D9YCjyPN.js";import"./index-JbHgsFAK.js";import"./index-BiS8IM9B.js";import"./x-CEXz2EER.js";import"./createLucideIcon-DqnlFWer.js";import"./index-CeYyXWc4.js";import"./index-D448AvbX.js";import"./truck-DSNzHzca.js";import"./package-Ca-wQg6n.js";import"./shopping-bag-kX2qM3ec.js";import"./app-logo-icon-bwP4qd8Q.js";import"./bluetooth-context-DlC5mQaA.js";import"./index-BtT9Eyya.js";import"./index-l-_2VD5G.js";import"./sonner-DMUJNVEP.js";import"./pagination-7aOfsluw.js";import"./chevron-left-O9iIxqlL.js";import"./select-787Dhddj.js";import"./chevron-down-CelnyKCC.js";import"./input-De4RhZu7.js";import"./dialog-C64V63Fe.js";const R=[{title:"Pembelian",href:route("apps.orders.index")}];function Ne(){const{orders:i,perPage:o,currentPage:c}=b().props,[m,l]=f.useState(!1),{data:p,setData:x}=g({id:""}),u=a=>{l(!0),x(t=>({...t,id:a.id}))},h=a=>{switch(a){case"paid":return e.jsxs("div",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(E,{className:"size-4"})," Lunas"]});case"partial":return e.jsxs("div",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(F,{className:"size-4"})," Belum Lunas"]});case"unpaid":return e.jsxs("div",{className:"flex items-center gap-1 text-rose-500",children:[e.jsx(z,{className:"size-4"})," Belum Dibayar"]});default:return"Status Tidak Dikenal"}},j=a=>{switch(a){case"confirmed":return"Dipesan";case"received":return"Diterima";case"pending":return"Tertunda";default:return"Status Tidak Dikenal"}};return e.jsxs(T,{breadcrumbs:R,children:[e.jsx(N,{title:"Pembelian"}),e.jsxs("div",{className:"p-4 bg-background text-foreground transition-colors",children:[e.jsx(L,{title:"Pembelian",description:"Halaman ini digunakan untuk mengelola data pembelian"}),e.jsxs("div",{className:"border border-border bg-card text-card-foreground shadow-sm rounded-xl p-4",children:[n(["orders-create"])&&e.jsx(H,{asChild:!0,variant:"outline",children:e.jsxs(P,{href:route("apps.orders.create"),children:[e.jsx(M,{className:"size-4"})," ",e.jsx("span",{className:"hidden sm:inline-flex font-semibold",children:"Tambah Pembelian"})]})}),e.jsx("div",{className:"mt-6",children:e.jsx(C,{withFilterPage:!0,currentPage:c,perPage:o,url:route("apps.orders.index"),placeholder:"Cari data pembelian berdasarkan nomor faktur pembelian"})}),e.jsx(w,{className:"mt-5",children:e.jsxs(y,{children:[e.jsx(D,{children:e.jsxs(d,{children:[e.jsx(s,{className:"w-[10px]",children:"No"}),e.jsx(s,{children:"Nomor Faktur"}),e.jsx(s,{children:"Supplier"}),e.jsx(s,{children:"Tanggal Pembelian"}),e.jsx(s,{className:"w-[10px] text-center",children:"Jenis Pembelian"}),e.jsx(s,{className:"w-[10px] text-center",children:"Status Pembelian"}),e.jsx(s,{className:"w-[10px] text-center",children:"Status Pembayaran"}),e.jsx(s,{children:"Total Pembelian"}),e.jsx(s,{className:"w-[10px] text-center",children:"Aksi"})]})}),e.jsx(v,{children:i.data.length===0?e.jsx(B,{colSpan:9,message:"data pembelian"}):i.data.map((a,t)=>e.jsxs(d,{children:[e.jsx(r,{className:"text-center",children:t+1}),e.jsx(r,{children:a.order_code}),e.jsxs(r,{children:["[",a.supplier.code,"] ",a.supplier.name]}),e.jsx(r,{children:a.order_date}),e.jsx(r,{className:"text-center",children:a.type=="products"?"Produk":"Bahan Baku"}),e.jsx(r,{className:"text-center",children:e.jsx(S,{variant:"secondary",children:j(a.order_status)})}),e.jsx(r,{children:e.jsx("div",{className:"flex items-center gap-1 justify-center",children:h(a.payment_status)})}),e.jsxs(r,{className:"text-right font-semibold",children:[e.jsx("sup",{children:"Rp"})," ",a.grand_total]}),e.jsx(r,{children:e.jsx("div",{className:"text-center",children:(n(["orders-update"])||n(["orders-delete"]))&&e.jsx(_,{permissionPrefix:"orders",withDetail:!0,actionDetailHref:route("apps.orders.show",a.id),actionEditHref:route("apps.orders.edit",a.id),actionDelete:()=>u(a)})})})]},t))})]})}),e.jsx(A,{open:m,onOpenChange:l,url:route("apps.orders.destroy",p.id)}),e.jsx(k,{data:i})]})]})]})}export{Ne as default};
