import{r as s,c as N,b as e,a as p}from"./app-DTeOhhdM.js";import{A as D}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as F}from"./toast.esm-CLj0hUIX.js";import{A as C}from"./autocomplete.esm-wKYwH1zm.js";import{C as d}from"./calendar.esm-DqUk2xOX.js";import{a as P}from"./helper-Gzy5oJm-.js";import"./createLucideIcon-0QtVMxKe.js";import"./defualtLogo-C0dU5cUD.js";import"./index.esm-xhUioO7y.js";import"./inputtext.esm-DvYkLvTo.js";import"./index.esm-DydXoyuW.js";import"./index.esm-BlFJNgmX.js";import"./asyncToGenerator-BfWTt6ZC.js";function z({auth:c}){const{permission:I,warehouseList:L}=s.useContext(N),[r,m]=s.useState(),[l,u]=s.useState(),[T,k]=s.useState([]),x=s.useRef(null),[h,g]=s.useState([]),[j,i]=s.useState(null),[n,o]=s.useState(!1),[b,f]=s.useState({supplier:""}),w=async()=>{o(!0);let t=new FormData;return t.append("start",r),t.append("end",l),t.append("supplierId",j),(await p.post("supplier-payment-history-search",t)).data},y=async()=>{const t=await w(),a=await window.generatePDFView(t,window.reportModes.supplierPayment,!1,"Supplier Payment Details",r,l);P(a,"Supplier Payment .pdf"),o(!1)},v=t=>{setTimeout(()=>{p.post(route("supplier.search"),{data:t.query}).then(a=>{g(a.data)})},250)},S=t=>e.jsx("div",{className:"country-item",children:e.jsx("div",{children:t.name})});return e.jsxs(D,{user:c.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium ",children:"Supplier Payment Details"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Supplier Payment Details"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(F,{ref:x}),e.jsx("div",{className:"card p-5",children:e.jsx("div",{className:"min-h-screen  bg-gray-100  py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto bg-white rounded-2xl shadow-lg p-10 border border-gray-200",children:[e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-800 mb-10 tracking-tight",children:"Filter Report Criteria"}),e.jsxs("div",{className:"grid  grid-cols-12  gap-6",children:[e.jsxs("div",{className:"col-span-12 md:col-span-4",children:[e.jsx("label",{htmlFor:"type",children:"Starting Date"}),e.jsx(d,{value:r,onChange:t=>{m(t.value)},className:"h-[41px]  text-[14px]"})]}),e.jsxs("div",{className:"col-span-12 md:col-span-4",children:[e.jsx("label",{htmlFor:"type",children:"End Date"}),e.jsx(d,{value:l,onChange:t=>{u(t.value)},className:"h-[41px]  text-[14px]"})]}),e.jsxs("div",{className:"col-span-12 sm:col-span-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Search Supplier"}),e.jsx(C,{value:b.supplier,suggestions:h,completeMethod:v,"aria-label":"supplier_id",dropdown:!0,itemTemplate:S,onChange:t=>{t.value.name?i(t.value.id):i(null),f(a=>({...a,supplier:t.value.name?`${t.value.name}`:t.value}))},dropdownAriaLabel:"Select supplier",className:"w-full h-10 rounded-lg"})]})]}),e.jsx("div",{className:"mt-10 flex justify-center",children:e.jsx("button",{type:"button",onClick:y,disabled:n,className:`px-6 py-3 rounded-xl font-semibold text-sm min-w-[160px] flex items-center justify-center gap-2 transition duration-200
                    ${n?"bg-blue-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"}
                    text-white shadow-md`,children:n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-5 h-5 border-2 border-white border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-medium",children:"Generating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"img","aria-label":"View Report",children:"🔍"}),"View Report"]})})})]})})})]})}export{z as default};
