import{r as t,c as L,b as e,a as x}from"./app-DTeOhhdM.js";import{A as R,a as h}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as A}from"./toast.esm-CLj0hUIX.js";import{A as V}from"./autocomplete.esm-wKYwH1zm.js";import{C as b}from"./calendar.esm-DqUk2xOX.js";import{a as B}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 Q({auth:o}){const{permission:i,warehouseList:g}=t.useContext(L),[l,j]=t.useState(),[r,f]=t.useState(),[m,c]=t.useState([]),y=t.useRef(null),[v,w]=t.useState([]),[N,d]=t.useState(null),[n,u]=t.useState(!1),[C,D]=t.useState({customer:""}),S=[{label:"All",value:"all"},{label:"Cash",value:"cash"},{label:"Bank",value:"Bank"},{label:"Mobile Bank",value:"Mobile Bank"}],[p,F]=t.useState("all");t.useEffect(()=>{i.includes("report_super_admin_access")||c(o.user.shop_id)},[]);const T=async()=>{u(!0);let a=new FormData;return a.append("start",l),a.append("end",r),a.append("customer",N),a.append("location_id",m),a.append("payment_type",p),(await x.post("customer-payment-details-search-report",a)).data},_=async()=>{const a=await T(),s=await window.generatePDFView(a,window.reportModes.clientPayment,!1,"Customer Payment Details",l,r);B(s,"clientPayment.pdf"),u(!1)},k=a=>{setTimeout(()=>{x.post(route("customer-search"),{data:a.query}).then(s=>{w(s.data.customer)})},250)},P=a=>e.jsx("div",{className:"country-item",children:e.jsxs("div",{children:[a.name," (",a.code,") (",a.user_type,")"]})});return e.jsxs(R,{user:o.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium ",children:"Customer/Retailer Payment Details"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Customer/Retailer Payment Details"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(A,{ref:y}),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(b,{value:l,onChange:a=>{j(a.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(b,{value:r,onChange:a=>{f(a.value)},className:"h-[41px]  text-[14px]"})]}),e.jsxs("div",{className:"col-span-12 md:col-span-4",children:[e.jsx("label",{htmlFor:"type",children:"Search Customer/Retailer"}),e.jsx(V,{value:C.customer,suggestions:v,completeMethod:k,"aria-label":"customer_id",dropdown:!0,itemTemplate:P,onChange:a=>{a.value.name?d(a.value.id):d(null),D(s=>({...s,customer:a.value.name?a.value.name+" ("+a.value.code+")":a.value}))},dropdownAriaLabel:"Select Coustomer",className:"w-full h-10"})]}),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:"Payment Type"}),e.jsx(h,{value:p,options:S,optionLabel:"label",optionValue:"value",placeholder:"Select Payment Type",onChange:a=>F(a.value),className:"w-full rounded-lg shadow-sm",inputClassName:"h-11 px-4 text-sm"})]}),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(h,{value:m,options:g,optionLabel:"name",optionValue:"id",placeholder:"Select a Warehouse",showClear:!0,disabled:!i.includes("report_super_admin_access"),onChange:a=>c(a.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:_,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{Q as default};
