import{r as t,c as D,E as v,a as p,b as e}from"./app-DTeOhhdM.js";import{A as _,a as C}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as R}from"./toast.esm-CLj0hUIX.js";import{C as u}from"./calendar.esm-DqUk2xOX.js";import{a as F}from"./helper-Gzy5oJm-.js";import{l as E}from"./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"./asyncToGenerator-BfWTt6ZC.js";function X({auth:l}){const{permission:n,warehouseList:x}=t.useContext(D),[i,d]=t.useState([]),[h,k]=t.useState("All"),[r,f]=t.useState(),[a,g]=t.useState(),[L,P]=t.useState([]),[T,A]=t.useState([]),[V,b]=t.useState([]),[o,c]=t.useState(!1),[H,w]=t.useState(!1),j=t.useRef(),S=t.useRef(null);new v,t.useEffect(()=>{p.get(route("sales.report.shop")).then(s=>{b(s.data.shop)}),n.includes("report_super_admin_access")||d(l.user.shop_id)},[]);const N=async()=>{c(!0);let s=new FormData;return s.append("type",h),s.append("start",r),s.append("end",a),s.append("location_id",i),(await p.post("salsesearch",s)).data},y=async()=>{const s=await N(),m=await window.generatePDFView(s.salesInfo,window.reportModes.saleSummary,!1,"Sale Summary",r,a,s.discount);F(m,"saleSummary.pdf"),c(!1)};return E.useReactToPrint({content:()=>j.current,onAfterPrint:()=>{w(!1)}}),`${new Date(r).toLocaleDateString("en-US")}`,a&&`${new Date(a).toLocaleDateString("en-US")}`,e.jsxs(_,{user:l.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium ",children:"Sales Report"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Sales Report"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(R,{ref:S}),e.jsx("div",{className:"card min-h-screen",children:e.jsx("div",{className:"bg-gray-100 py-12 px-2 sm:px-6 lg:px-8 flex justify-center",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 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(u,{value:r,onChange:s=>f(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(u,{value:a,onChange:s=>g(s.value),className:"w-full h-[41px] text-[14px] rounded-lg shadow-sm"})]}),n.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(C,{value:i,options:x,optionLabel:"name",optionValue:"id",placeholder:"Select a Warehouse",showClear:!0,disabled:!n.includes("report_super_admin_access"),onChange:s=>d(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:y,disabled:o,className:`px-6 py-3 rounded-xl font-semibold text-sm min-w-[160px] flex items-center justify-center gap-2 transition duration-200
                    ${o?"bg-blue-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"}
                    text-white shadow-md`,children:o?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{X as default};
