import{r as u,o as C,a as n,b as r,d as e,q as x,v as D,z as y,F as v,j as g,t as o,f as M,G as S}from"./app-kAt5lVqd.js";const N={class:"p-6"},O={class:"bg-white rounded-lg shadow p-4 mb-6 flex gap-4"},V=["value"],A=["value"],F={class:"bg-white rounded-lg shadow overflow-hidden"},U={class:"w-full"},B={class:"px-4 py-3"},J={class:"font-bold text-red-600"},j={class:"px-4 py-3"},E={class:"font-semibold"},L={class:"text-xs text-gray-500"},P={class:"px-4 py-3"},R={class:"font-bold"},T={class:"px-4 py-3"},$={class:"text-sm text-red-600"},q={class:"px-4 py-3 text-sm"},z={key:0,class:"p-4 flex justify-between items-center border-t"},G={class:"text-sm text-gray-600"},I={class:"flex gap-2"},Y=["disabled"],H=["disabled"],W={__name:"CancelledOrders",setup(K){const a=u({data:[]}),i=u(""),c=u(""),p=u(new Date().getFullYear()),f=u([2024,2025,2026]),d=async(l=1)=>{try{const{data:s}=await S.get("/api/manager/cancelled-orders",{params:{search:i.value,month:c.value,year:p.value,page:l}});a.value=s.data}catch(s){console.error("Error loading cancelled orders:",s)}},_=l=>{l>0&&d(l)},w=l=>["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][l-1],k=l=>new Date(l).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return C(()=>d()),(l,s)=>{var h;return r(),n("div",N,[s[7]||(s[7]=e("h1",{class:"text-3xl font-bold mb-6"},"🚫 Cancelled Orders",-1)),e("div",O,[x(e("input",{"onUpdate:modelValue":s[0]||(s[0]=t=>i.value=t),onInput:d,placeholder:"Search order #, customer...",class:"px-4 py-2 border rounded-lg flex-1"},null,544),[[D,i.value]]),x(e("select",{"onUpdate:modelValue":s[1]||(s[1]=t=>c.value=t),onChange:d,class:"px-4 py-2 border rounded-lg"},[s[5]||(s[5]=e("option",{value:""},"All Months",-1)),(r(),n(v,null,g(12,t=>e("option",{key:t,value:t},o(w(t)),9,V)),64))],544),[[y,c.value]]),x(e("select",{"onUpdate:modelValue":s[2]||(s[2]=t=>p.value=t),onChange:d,class:"px-4 py-2 border rounded-lg"},[(r(!0),n(v,null,g(f.value,t=>(r(),n("option",{key:t,value:t},o(t),9,A))),128))],544),[[y,p.value]])]),e("div",F,[e("table",U,[s[6]||(s[6]=e("thead",{class:"bg-red-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase"},"Order"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase"},"Customer"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase"},"Total"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase"},"Reason"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase"},"Date")])],-1)),e("tbody",null,[(r(!0),n(v,null,g(a.value.data,t=>{var b,m;return r(),n("tr",{key:t.id,class:"border-b hover:bg-gray-50"},[e("td",B,[e("div",J,o(t.order_number),1)]),e("td",j,[e("div",E,o((b=t.user)==null?void 0:b.name),1),e("div",L,o((m=t.user)==null?void 0:m.phone),1)]),e("td",P,[e("div",R,"Rs "+o(t.total),1)]),e("td",T,[e("div",$,o(t.cancellation_reason||"N/A"),1)]),e("td",q,o(k(t.created_at)),1)])}),128))])]),(h=a.value.data)!=null&&h.length?(r(),n("div",z,[e("div",G," Showing "+o(a.value.from)+" to "+o(a.value.to)+" of "+o(a.value.total)+" orders ",1),e("div",I,[e("button",{onClick:s[3]||(s[3]=t=>_(a.value.current_page-1)),disabled:!a.value.prev_page_url,class:"px-4 py-2 bg-gray-200 rounded-lg hover:bg-gray-300 disabled:opacity-50"}," Previous ",8,Y),e("button",{onClick:s[4]||(s[4]=t=>_(a.value.current_page+1)),disabled:!a.value.next_page_url,class:"px-4 py-2 bg-gray-200 rounded-lg hover:bg-gray-300 disabled:opacity-50"}," Next ",8,H)])])):M("",!0)])])}}};export{W as default};
