import{r as t,c as N,E as y,a as p,b as e}from"./app-DTeOhhdM.js";import{A as D,a as v}from"./AuthenticatedLayout-DNj-hWy1.js";import{T as S}from"./toast.esm-CLj0hUIX.js";import{C as x}from"./calendar.esm-DqUk2xOX.js";import{a as _}from"./helper-Gzy5oJm-.js";import"./html2canvas.esm-CBrSDip1.js";import"./postcss-Dq8Tz5-x.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";import"./postcss-B8mRKTCC.js";function J({auth:l}){const{permission:a,warehouseList:u}=t.useContext(N),[C,E]=t.useState("All"),[r,h]=t.useState(),[n,g]=t.useState(),[i,d]=t.useState([]),[o,m]=t.useState(!1),[R,F]=t.useState([]),[k,f]=t.useState([]);t.useRef();const b=t.useRef(null);new y,t.useEffect(()=>{p.get(route("sales.report.shop")).then(s=>{f(s.data.shop)}),a.includes("report_super_admin_access")||d(l.user.shop_id)},[]);const w=async()=>{m(!0);let s=new FormData;return s.append("start",r),s.append("end",n),s.append("location_id",i),(await p.post("damage-search",s)).data},j=async()=>{const s=await w(),c=await window.generatePDFView(s,window.reportModes.damageEntry,!1,"Damage Entry Report",r,n);_(c,"damageEntry.pdf"),m(!1)};return e.jsxs(D,{user:l.user,header:e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-skin-header font-medium ",children:"Damage Report"})," ",e.jsxs("p",{className:"text-skin-sub-header font-semibold text-xs",children:[" ","Home - Damage"]})]}),headerButton:e.jsx(e.Fragment,{}),children:[e.jsx(S,{ref:b}),e.jsx("div",{className:"card min-h-screen",children:e.jsx("div",{className:"bg-gray-100  flex items-center justify-center py-12 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 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(x,{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(x,{value:n,onChange:s=>g(s.value),className:"w-full h-[41px] text-[14px] rounded-lg shadow-sm"})]}),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(v,{value:i,options:u,optionLabel:"name",optionValue:"id",placeholder:"Select a Warehouse",showClear:!0,disabled:!a.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:j,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{J as default};
