import{r as t,c as y,E as D,b as e,a as S}from"./app-DTeOhhdM.js";import{A as _,a as R}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as P}from"./toast.esm-CLj0hUIX.js";import{C as p}from"./calendar.esm-DqUk2xOX.js";import{C as k}from"./CustomerDropdown-D5NzJHSa.js";import{S as F}from"./ProductDropdown-CIH7Yk36.js";import{a as q}from"./helper-Gzy5oJm-.js";import"./index-CL55CtA3.js";import"./createLucideIcon-0QtVMxKe.js";import"./defualtLogo-C0dU5cUD.js";import"./index.esm-xhUioO7y.js";import"./index.esm-DydXoyuW.js";import"./index.esm-BlFJNgmX.js";import"./inputtext.esm-DvYkLvTo.js";import"./autocomplete.esm-wKYwH1zm.js";import"./asyncToGenerator-BfWTt6ZC.js";function Y({auth:l}){const{permission:a,warehouseList:x}=t.useContext(y),[r,h]=t.useState(),[o,f]=t.useState(),[w,b]=t.useState(null),[g,i]=t.useState(null),[d,c]=t.useState([]),[n,m]=t.useState(!1),[j,I]=t.useState(!1),N=t.useRef(null);new D,t.useRef();const[E,L]=t.useState(!1);t.useEffect(()=>{a.includes("report_super_admin_access")||c(l.user.shop_id)},[]);const C=async()=>{m(!0);let s=new FormData;return s.append("start",r),s.append("end",o),s.append("customer_id",w),s.append("attribute_id",g),s.append("location_id",d),s.append("show_product_details",j),(await S.post("requisition-client-report",s)).data},v=async()=>{const s=await C(),u=await window.generatePDFView(s,window.reportModes.requisitionByProduct,!1,"Requisition reports Details",r,o);q(u,"requisitionByProduct.pdf"),m(!1)};return e.jsxs(_,{user:l.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium",children:"Requisition Client Report"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Requisition Client Report"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(P,{ref:N}),e.jsx("div",{className:"card min-h-screen",children:e.jsx("div",{className:"bg-gray-100 flex items-center justify-center py-8 px-2 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"w-full max-w-5xl bg-white rounded-2xl shadow-lg border border-gray-200 p-4 sm:p-8 md:p-10",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-center text-gray-800 mb-8 md:mb-10 tracking-tight",children:"Filter Report Criteria"}),e.jsxs("div",{className:"grid grid-cols-12 md:gap-6",children:[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:"Starting Date"}),e.jsx(p,{value:r,onChange:s=>h(s.value),className:"w-full h-[41px] text-[14px] rounded-lg shadow-sm"})]}),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:"End Date"}),e.jsx(p,{value:o,onChange:s=>f(s.value),className:"w-full h-[41px] text-[14px] rounded-lg shadow-sm"})]}),e.jsx("div",{className:"col-span-12 sm:col-span-4",children:e.jsx(k,{onSelect:s=>b(s.id),className:"w-full",inputClassName:"w-full h-10 rounded-lg"})}),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:"Product"}),e.jsx(F,{className:"w-full",inputClassName:"w-full h-10 rounded-lg",reportMode:!0,selectedItem:s=>{s!=null&&s.id?i(s.id):i(null)}})]}),a.includes("report_super_admin_access")&&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:"Warehouse/Shop"}),e.jsx(R,{value:d,options:x,optionLabel:"name",optionValue:"id",placeholder:"Select a Warehouse",showClear:!0,disabled:!a.includes("report_super_admin_access"),onChange:s=>c(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: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{Y as default};
