import{r as i,o as w,a,b as l,d as e,f as h,g as b,w as g,h as _,t as d,F as k,j as F,y as C,q as A,v as D,k as c,m as y}from"./app-kAt5lVqd.js";const N={class:"min-h-screen bg-gray-50"},V={class:"bg-white shadow"},j={class:"max-w-7xl mx-auto px-4 py-4 flex justify-between"},B={class:"max-w-4xl mx-auto px-4 py-8"},$={class:"bg-gradient-to-r from-red-500 to-red-600 rounded-lg shadow-lg p-8 text-white mb-8"},E={class:"text-5xl font-bold mb-4"},M={class:"bg-white rounded-lg shadow p-6"},S={key:0,class:"text-center py-8 text-gray-500"},T={key:1,class:"space-y-3"},W={class:"font-medium"},z={class:"text-sm text-gray-500"},L={key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},R={class:"bg-white rounded-lg p-6 w-full max-w-md"},U={class:"flex gap-3"},P={__name:"Wallet",setup(q){const x=i({}),u=i([]),n=i(!1),r=i(0),m=async()=>{try{const o=await c.get("/wallet/balance");x.value=o.data;const t=await c.get("/wallet/transactions");u.value=t.data.data}catch(o){console.error("Error:",o)}},f=async()=>{try{await c.post("/wallet/add-funds",{amount:r.value}),n.value=!1,r.value=0,await m()}catch{alert("Failed to add funds")}},p=o=>new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return w(m),(o,t)=>{const v=_("router-link");return l(),a("div",N,[e("nav",V,[e("div",j,[b(v,{to:"/",class:"text-2xl font-bold text-red-600"},{default:g(()=>[...t[3]||(t[3]=[y("Food Delivery",-1)])]),_:1}),b(v,{to:"/profile",class:"text-gray-700 hover:text-red-600"},{default:g(()=>[...t[4]||(t[4]=[y("Profile",-1)])]),_:1})])]),e("div",B,[t[7]||(t[7]=e("h1",{class:"text-3xl font-bold mb-8"},"My Wallet",-1)),e("div",$,[t[5]||(t[5]=e("div",{class:"text-sm mb-2"},"Available Balance",-1)),e("div",E,"$"+d(x.value.balance||0),1),e("button",{onClick:t[0]||(t[0]=s=>n.value=!0),class:"bg-white text-red-600 px-6 py-2 rounded-lg font-bold hover:bg-gray-100"}," + Add Funds ")]),e("div",M,[t[6]||(t[6]=e("h2",{class:"text-xl font-bold mb-4"},"Transaction History",-1)),u.value.length===0?(l(),a("div",S," No transactions yet ")):(l(),a("div",T,[(l(!0),a(k,null,F(u.value,s=>(l(),a("div",{key:s.id,class:"flex justify-between items-center border-b pb-3"},[e("div",null,[e("div",W,d(s.description),1),e("div",z,d(p(s.created_at)),1)]),e("div",{class:C([s.type==="credit"?"text-green-600":"text-red-600","font-bold"])},d(s.type==="credit"?"+":"-")+"$"+d(s.amount),3)]))),128))]))])]),n.value?(l(),a("div",L,[e("div",R,[t[8]||(t[8]=e("h3",{class:"text-xl font-bold mb-4"},"Add Funds",-1)),A(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>r.value=s),type:"number",placeholder:"Enter amount",class:"w-full px-4 py-2 border rounded-lg mb-4"},null,512),[[D,r.value,void 0,{number:!0}]]),e("div",U,[e("button",{onClick:f,class:"flex-1 bg-red-600 text-white py-2 rounded-lg hover:bg-red-700"}," Add Funds "),e("button",{onClick:t[2]||(t[2]=s=>n.value=!1),class:"flex-1 bg-gray-300 text-gray-700 py-2 rounded-lg hover:bg-gray-400"}," Cancel ")])])])):h("",!0)])}}};export{P as default};
