import{r as v,o as p,a as i,b as d,d as e,g as m,w as f,h as w,t as a,y as k,F as D,j as C,k as n,m as E}from"./app-kAt5lVqd.js";const O={class:"min-h-screen bg-gray-50"},F={class:"bg-white shadow"},N={class:"max-w-7xl mx-auto px-4 py-4 flex justify-between"},S={class:"max-w-7xl mx-auto px-4 py-8"},$={class:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-8"},j={class:"bg-white rounded-lg shadow p-6"},B={class:"text-3xl font-bold text-red-600"},T={class:"bg-white rounded-lg shadow p-6"},V={class:"text-3xl font-bold text-green-600"},A={class:"bg-white rounded-lg shadow p-6"},G={class:"flex items-center gap-2"},P={class:"font-bold"},R={class:"bg-white rounded-lg shadow p-6"},z={key:0,class:"text-gray-500 text-center py-8"},L={key:1,class:"space-y-4"},M={class:"flex justify-between items-start mb-3"},q={class:"font-bold text-lg"},H={class:"text-sm text-gray-600"},I={class:"text-right"},J={class:"text-green-600 font-bold"},K={class:"text-sm text-gray-600"},Q={class:"text-sm text-gray-600 mb-3"},U=["onClick"],Z={__name:"Dashboard",setup(W){const r=v({todayDeliveries:0,todayEarnings:0}),l=v(!1),c=v([]),u=async()=>{try{const s=await n.get("/delivery-boy/earnings");r.value.todayDeliveries=s.data.total_deliveries,r.value.todayEarnings=s.data.today_earnings;const t=await n.get("/delivery-boy/available");c.value=t.data}catch(s){console.error("Error:",s)}},b=async()=>{try{const s=l.value?"offline":"available";await n.post("/delivery-boy/status",{status:s}),l.value=!l.value}catch{alert("Failed to update status")}},x=async s=>{try{await n.post(`/deliveries/${s}/accept`),alert("Delivery accepted!"),await u()}catch{alert("Failed to accept delivery")}};return p(u),(s,t)=>{const h=w("router-link");return d(),i("div",O,[e("nav",F,[e("div",N,[t[1]||(t[1]=e("h1",{class:"text-2xl font-bold text-red-600"},"Delivery Dashboard",-1)),m(h,{to:"/profile",class:"text-gray-700 hover:text-red-600"},{default:f(()=>[...t[0]||(t[0]=[E("Profile",-1)])]),_:1})])]),e("div",S,[e("div",$,[e("div",j,[t[2]||(t[2]=e("div",{class:"text-gray-600 mb-2"},"Today's Deliveries",-1)),e("div",B,a(r.value.todayDeliveries),1)]),e("div",T,[t[3]||(t[3]=e("div",{class:"text-gray-600 mb-2"},"Today's Earnings",-1)),e("div",V,"$"+a(r.value.todayEarnings),1)]),e("div",A,[t[4]||(t[4]=e("div",{class:"text-gray-600 mb-2"},"Status",-1)),e("div",G,[e("div",{class:k([l.value?"bg-green-500":"bg-gray-400","w-3 h-3 rounded-full"])},null,2),e("span",P,a(l.value?"Online":"Offline"),1)]),e("button",{onClick:b,class:"mt-2 w-full bg-red-600 text-white py-2 rounded hover:bg-red-700"},a(l.value?"Go Offline":"Go Online"),1)])]),e("div",R,[t[5]||(t[5]=e("h2",{class:"text-xl font-bold mb-4"},"Available Deliveries",-1)),c.value.length===0?(d(),i("div",z," No deliveries available ")):(d(),i("div",L,[(d(!0),i(D,null,C(c.value,o=>{var _,g,y;return d(),i("div",{key:o.id,class:"border rounded-lg p-4"},[e("div",M,[e("div",null,[e("div",q,"Order #"+a((_=o.order)==null?void 0:_.order_number),1),e("div",H,a((y=(g=o.order)==null?void 0:g.restaurant)==null?void 0:y.name),1)]),e("div",I,[e("div",J,"$"+a(o.delivery_fee),1),e("div",K,a(o.distance_km)+" km",1)])]),e("div",Q,[e("div",null,"📍 Pickup: "+a(o.pickup_address),1),e("div",null,"📍 Delivery: "+a(o.delivery_address),1)]),e("button",{onClick:X=>x(o.id),class:"w-full bg-red-600 text-white py-2 rounded hover:bg-red-700"}," Accept Delivery ",8,U)])}),128))]))])])])}}};export{Z as default};
