import{r as t,c as D,E as _,b as e,a as p}from"./app-DTeOhhdM.js";import{A as F,a as I}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as R}from"./toast.esm-CLj0hUIX.js";import{A as L}from"./autocomplete.esm-wKYwH1zm.js";import{a as T}from"./helper-Gzy5oJm-.js";import"./createLucideIcon-0QtVMxKe.js";import"./defualtLogo-C0dU5cUD.js";import"./index.esm-xhUioO7y.js";import"./inputtext.esm-DvYkLvTo.js";import"./asyncToGenerator-BfWTt6ZC.js";function J({auth:o}){const{permission:n,warehouseList:x}=t.useContext(D),[l,k]=t.useState(),[i,A]=t.useState(),[u,m]=t.useState([]),h=t.useRef(null);new _;const[f,b]=t.useState([]),[g,d]=t.useState(null),[j,w]=t.useState({customer:"",supplier:""}),[E,V]=t.useState([]),[S,M]=t.useState(null),[r,c]=t.useState(!1);t.useEffect(()=>{n.includes("report_super_admin_access")||m(o.user.shop_id)},[]);const y=async()=>{c(!0);let s=new FormData;return s.append("start",l),s.append("end",i),s.append("supplierId",S),s.append("client_id",g),s.append("location_id",u),(await p.post("customer-due-summary-search-report",s)).data},v=async()=>{const s=await y(),a=await window.generatePDFView(s,window.reportModes.CustomerDueSummary,!1,"Customer Due Summary",l,i);T(a,"customerDueSummary.pdf"),c(!1)},N=s=>{setTimeout(()=>{p.post(route("customer-search"),{data:s.query}).then(a=>{b(a.data.customer)})},250)},C=s=>e.jsx("div",{className:"country-item",children:e.jsxs("div",{children:[s.name," (",s.code,") (",s.user_type,")"]})});return e.jsxs(F,{user:o.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium ",children:"Customer/Retailer Due Summary"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Customer/Retailer Due Summary"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(R,{ref:h}),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:"Search Customer/Retailer"}),e.jsx(L,{value:j.customer,suggestions:f,completeMethod:N,"aria-label":"customer_id",dropdown:!0,itemTemplate:C,onChange:s=>{s.value.name?d(s.value.id):d(null),w(a=>({...a,customer:s.value.name?s.value.name+" ("+s.value.code+")":s.value}))},dropdownAriaLabel:"Select Coustomer",className:"w-full h-10"})]}),e.jsx("div",{className:"col-span-12 md:col-span-4",children:e.jsxs("div",{className:"col-span-12 md:col-span-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Warehouse/Shop"}),e.jsx(I,{value:u,options:x,optionLabel:"name",optionValue:"id",placeholder:"Select a Warehouse",showClear:!0,disabled:!n.includes("report_super_admin_access"),onChange:s=>m(s.target.value??null),className:"w-full rounded-lg shadow-sm",inputClassName:"h-11 px-4 text-sm"})]})})]}),e.jsx("div",{className:"mt-10 flex justify-center",children:e.jsx("button",{type:"button",onClick:v,disabled:r,className:`px-6 py-3 rounded-xl font-semibold text-sm min-w-[160px] flex items-center justify-center gap-2 transition duration-200
                    ${r?"bg-blue-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"}
                    text-white shadow-md`,children:r?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{J as default};
