import{q as b,U as f,v as g,j as e,$ as N,Y as P}from"./app-CffHYkHW.js";import{A as T,u as n}from"./app-layout-D-VS7nVU.js";import{P as k}from"./page-pagination-haDwcr6r.js";import{T as C,a as v,b as w,c as y,d,e as s,f as D,g as B,h as r}from"./table-DVZTgtP_.js";import{B as H}from"./button-qhe8lrPU.js";import{B as S}from"./badge-soq0-NVD.js";import{A,M}from"./modal-delete-CrQxv22H.js";import{H as _}from"./heading-YfudWo2z.js";import{C as z}from"./trash-o9eyCj69.js";import{C as E}from"./circle-x-BunZhULO.js";import{C as F}from"./circle-pause-CtbvhSKE.js";import{C as L}from"./circle-check-big-l4qrcNdU.js";import"./utils-C8zp8JNC.js";import"./sheet-Bisw0FSz.js";import"./index-C0loMkA3.js";import"./index-Cy5bElus.js";import"./index-DPkgfxsD.js";import"./x-BfabuQJD.js";import"./createLucideIcon-DAR-hy5d.js";import"./index-C9NeyPdJ.js";import"./index-CjqRk3xD.js";import"./truck-DnoS8QCL.js";import"./package-BHw0cifz.js";import"./shopping-bag-AryJS2XX.js";import"./app-logo-icon-D3Jzt_fn.js";import"./bluetooth-context-CLrE8g1i.js";import"./index-Dw4sHwMN.js";import"./sonner-CPUj7IiR.js";import"./pagination-DsNVVp24.js";import"./chevron-left-D6h0rvW2.js";import"./select-ClrGyhQo.js";import"./chevron-down-C5A3yn87.js";import"./input-Bw4IOOzt.js";import"./dialog-Djfc3pyN.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(L,{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(E,{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(_,{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(z,{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(v,{className:"mt-5",children:e.jsxs(w,{children:[e.jsx(y,{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(D,{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(A,{permissionPrefix:"orders",withDetail:!0,actionDetailHref:route("apps.orders.show",a.id),actionEditHref:route("apps.orders.edit",a.id),actionDelete:()=>u(a)})})})]},t))})]})}),e.jsx(M,{open:m,onOpenChange:l,url:route("apps.orders.destroy",p.id)}),e.jsx(k,{data:i})]})]})]})}export{Ne as default};
