import{_ as y,r as u,o as m,H as h,a as l,b as n,d as e,g as w,w as k,h as N,F as O,j as S,t as r,k as f,m as C}from"./app-kAt5lVqd.js";const j={class:"p-6 max-w-4xl mx-auto"},B={class:"flex justify-between items-center mb-6"},F={key:0,class:"text-center py-12"},I={key:1,class:"bg-white rounded-xl p-12 text-center"},V={key:2,class:"space-y-4"},D={class:"flex justify-between items-start mb-4"},E={class:"text-2xl font-bold text-orange-600"},R={class:"text-gray-600"},$={class:"text-right"},A={class:"text-2xl font-bold"},H={class:"text-sm text-gray-600"},L={class:"bg-gray-50 rounded-lg p-4 mb-4"},M={class:"font-semibold"},P={class:"text-sm text-gray-600"},T=["onClick"],U={__name:"Notifications",setup(W){const d=u(!0),a=u([]),i=u(null);let c=null;const _=async()=>{try{const{data:s}=await f.get("/delivery-boy/orders/available"),t=s.data||[];t.length>a.value.length&&b(),a.value=t,d.value=!1}catch(s){console.error("Error loading orders:",s),d.value=!1}},x=async s=>{try{await f.post(`/delivery-boy/orders/${s}/accept`),a.value=a.value.filter(t=>t.id!==s),alert("Order accepted!")}catch{alert("Failed to accept order")}},b=()=>{i.value&&i.value.play().catch(s=>console.log("Sound play failed:",s))};return m(()=>{_(),c=setInterval(_,5e3)}),h(()=>{c&&clearInterval(c)}),(s,t)=>{const g=N("router-link");return n(),l("div",j,[e("div",B,[t[1]||(t[1]=e("h1",{class:"text-3xl font-bold"},"🔔 New Orders",-1)),w(g,{to:"/delivery-boy/profile",class:"bg-blue-600 text-white px-4 py-2 rounded-lg font-semibold hover:bg-blue-700"},{default:k(()=>[...t[0]||(t[0]=[C(" 👤 Profile ",-1)])]),_:1})]),d.value?(n(),l("div",F,[...t[2]||(t[2]=[e("div",{class:"animate-spin rounded-full h-12 w-12 border-4 border-orange-500 border-t-transparent mx-auto"},null,-1)])])):a.value.length===0?(n(),l("div",I,[...t[3]||(t[3]=[e("div",{class:"text-6xl mb-4"},"📭",-1),e("h3",{class:"text-xl font-bold mb-2"},"No new orders",-1),e("p",{class:"text-gray-600"},"Waiting for orders...",-1)])])):(n(),l("div",V,[(n(!0),l(O,null,S(a.value,o=>{var p,v;return n(),l("div",{key:o.id,class:"bg-white rounded-xl shadow-lg p-6 border-2 border-orange-500 animate-pulse-slow"},[e("div",D,[e("div",null,[e("h3",E,r(o.order_number),1),e("p",R,r((p=o.restaurant)==null?void 0:p.name),1)]),e("div",$,[e("p",A,"Rs "+r(o.total_amount),1),e("p",H,"Delivery: Rs "+r(o.delivery_fee),1)])]),e("div",L,[e("p",M,r((v=o.user)==null?void 0:v.name),1),e("p",P,r(o.delivery_address),1)]),e("button",{onClick:q=>x(o.id),class:"w-full bg-green-600 text-white py-3 rounded-lg font-bold text-lg hover:bg-green-700"}," ✅ Accept Order ",8,T)])}),128))])),e("audio",{ref_key:"notificationSound",ref:i,src:"/notification.mp3",preload:"auto"},null,512)])}}},G=y(U,[["__scopeId","data-v-d2918251"]]);export{G as default};
