1import{q as L,c as i,b as e,F as C,r as M,f as l,x as c,t as a,g as S,w as u,v as m,G as A,p as E,m as b,d,n as K}from"./BiSZ_CVW.js";const P={class:"max-w-6xl mx-auto p-6 space-y-8"},V={class:"flex justify-between items-center border-b pb-4"},I={class:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden"},$={class:"w-full text-left border-collapse"},F={class:"divide-y divide-gray-100 text-sm"},T={class:"p-4 font-mono font-bold text-indigo-600"},U={class:"p-4 font-medium text-gray-700"},N={key:0},j={key:1},D={class:"p-4 text-gray-600"},Z={class:"p-4 text-gray-600"},B={key:0},q={key:1,class:"text-gray-400"},G={class:"p-4"},O={class:"p-4 text-right space-x-3"},H=["onClick"],R=["onClick"],X={key:0},J={key:0,class:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4 z-50"},Q={class:"bg-white rounded-2xl max-w-md w-full p-6 shadow-xl space-y-4"},W={class:"flex justify-between items-center border-b pb-3"},Y={class:"text-xl font-bold text-gray-800"},ee={class:"grid grid-cols-2 gap-4"},te=["disabled"],se=["disabled"],le={key:0,class:"text-[11px] text-gray-400 mt-1"},ne={class:"flex items-center space-x-2 pt-2"},oe={class:"flex justify-end space-x-3 pt-4 border-t"},ie=["disabled"],re={__name:"index",async setup(ae){let g,f;const{data:v,refresh:h}=([g,f]=L(()=>E("/api/admin/coupons","$yzC_N5aEas")),g=await g,f(),g),x=b(!1),r=b(null),p=b(!1),n=b({title:"",percentage:null,amount:null,minPrice:0,isAvailable:!0,usageLimit:null,usedCount:0}),k=(o=null)=>{o?(r.value=o.id,n.value={title:o.title,percentage:o.percentage??null,amount:o.amount??null,minPrice:o.minPrice??0,isAvailable:o.isAvailable,usageLimit:o.usageLimit??null,usedCount:o.usedCount??0}):(r.value=null,n.value={title:"",percentage:null,amount:null,minPrice:0,isAvailable:!0,usageLimit:null,usedCount:0}),x.value=!0},y=()=>{x.value=!1,r.value=null},_=async()=>{p.value=!0;const o={...n.value,percentage:n.value.percentage||null,amount:n.value.amount||null,usageLimit:n.value.usageLimit||null};try{r.value?await $fetch(`/api/admin/coupons/${r.value}`,{method:"PUT",body:o}):await $fetch("/api/admin/coupons",{method:"POST",body:o}),y(),h()}catch(t){alert(t.data?.message||"Hiba történt a mentés során.")}finally{p.value=!1}},w=async o=>{if(confirm("Biztosan törölni szeretnéd ezt a kupont?"))try{await $fetch(`/api/admin/coupons/${o}`,{method:"DELETE"}),h()}catch{alert("Nem sikerült törölni a kupont.")}};return(o,t)=>(d(),i("div",P,[e("div",V,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold text-gray-900"},"Kuponok Kezelése"),e("p",{class:"text-sm text-gray-500"},"Promóciós kuponok létrehozása, szerkesztése és törlése")],-1)),e("button",{onClick:t[0]||(t[0]=s=>k()),class:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg font-medium transition shadow-sm"}," + Ãj Kupon ")]),e("div",I,[e("table",$,[t[9]||(t[9]=e("thead",null,[e("tr",{class:"bg-gray-50 border-b text-xs font-semibold text-gray-500 uppercase tracking-wider"},[e("th",{class:"p-4"},"Kód (Title)"),e("th",{class:"p-4"},"Kedvezmény"),e("th",{class:"p-4"},"Min. Vásárlás"),e("th",{class:"p-4"},"Limit"),e("th",{class:"p-4"},"Státusz"),e("th",{class:"p-4 text-right"},"Műveletek")])],-1)),e("tbody",F,[(d(!0),i(C,null,M(l(v),s=>(d(),i("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",T,a(s.title),1),e("td",U,[s.percentage?(d(),i("span",N,a(s.percentage)+"%",1)):s.amount?(d(),i("span",j,a(s.amount?.toLocaleString())+" Ft",1)):c("",!0)]),e("td",D,a(s.minPrice?.toLocaleString())+" Ft",1),e("td",Z,[s.usageLimit?(d(),i("span",B,a(s.usedCount)+" / "+a(s.usageLimit),1)):(d(),i("span",q,"Korlátlan"))]),e("td",G,[e("span",{class:K([s.isAvailable?"bg-green-100 text-green-700":"bg-red-100 text-red-700","px-2.5 py-1 rounded-full text-xs font-semibold"])},a(s.isAvailable?"AktÃv":"InaktÃv"),3)]),e("td",O,[e("button",{onClick:z=>k(s),class:"text-indigo-600 hover:text-indigo-900 font-medium"}," Szerkesztés ",8,H),e("button",{onClick:z=>w(s.id),class:"text-red-500 hover:text-red-700 font-medium"}," Törlés ",8,R)])]))),128)),l(v)?.length?c("",!0):(d(),i("tr",X,[...t[8]||(t[8]=[e("td",{colspan:"6",class:"p-8 text-center text-gray-400"},"Még nincs felvéve kupon.",-1)])]))])])]),l(x)?(d(),i("div",J,[e("div",Q,[e("div",W,[e("h2",Y,a(l(r)?`Kupon szerkesztése (#${l(r)})`:"Ãj Kupon Létrehozása"),1),e("button",{onClick:y,class:"text-gray-400 hover:text-gray-600"},"â")]),e("form",{onSubmit:S(_,["prevent"]),class:"space-y-4"},[e("div",null,[t[10]||(t[10]=e("label",{class:"block text-xs font-semibold text-gray-600 mb-1"},"KUPON KÃD",-1)),u(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>l(n).title=s),type:"text",required:"",placeholder:"PL: SUMMER2026",class:"w-full border rounded-lg p-2.5 text-sm uppercase font-mono focus:ring-2 focus:ring-indigo-500 outline-none"},null,512),[[m,l(n).title]])]),e("div",ee,[e("div",null,[t[11]||(t[11]=e("label",{class:"block text-xs font-semibold text-gray-600 mb-1"},"SZÃZALÃK (%)",-1)),u(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>l(n).percentage=s),type:"number",min:"1",max:"100",disabled:l(n).amount>0,placeholder:"pl: 15",class:"w-full border rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-500 outline-none disabled:bg-gray-100 disabled:cursor-not-allowed"},null,8,te),[[m,l(n).percentage,void 0,{number:!0}]])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-xs font-semibold text-gray-600 mb-1"},"FIX ÃSSZEG (FT)",-1)),u(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>l(n).amount=s),type:"number",min:"1",disabled:l(n).percentage>0,placeholder:"pl: 3000",class:"w-full border rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-500 outline-none disabled:bg-gray-100 disabled:cursor-not-allowed"},null,8,se),[[m,l(n).amount,void 0,{number:!0}
1]])])]),t[16]||(t[16]=e("p",{class:"text-[11px] text-gray-400"},"Válassz egyet: Vagy százalékos, vagy fix összegű kedvezmény.",-1)),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-xs font-semibold text-gray-600 mb-1"},"MINIMÃLIS RENDELÃSI ÃSSZEG (FT)",-1)),u(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>l(n).minPrice=s),type:"number",required:"",placeholder:"0",class:"w-full border rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-500 outline-none"},null,512),[[m,l(n).minPrice,void 0,{number:!0}]])]),e("div",null,[t[14]||(t[14]=e("label",{class:"block text-xs font-semibold text-gray-600 mb-1"},"FELHASZNÃLÃSI LIMIT",-1)),u(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>l(n).usageLimit=s),type:"number",min:"1",placeholder:"Ãresen hagyva = korlátlan (pl. 1 = egyszer)",class:"w-full border rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-500 outline-none"},null,512),[[m,l(n).usageLimit,void 0,{number:!0}]]),l(r)?(d(),i("p",le," Eddigi felhasználás: "+a(l(n).usedCount??0),1)):c("",!0)]),e("div",ne,[u(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>l(n).isAvailable=s),type:"checkbox",id:"available",class:"w-4 h-4 text-indigo-600 rounded cursor-pointer"},null,512),[[A,l(n).isAvailable]]),t[15]||(t[15]=e("label",{for:"available",class:"text-sm font-medium text-gray-700 cursor-pointer"},"Kupon aktÃv és használható",-1))]),e("div",oe,[e("button",{type:"button",onClick:y,class:"px-4 py-2 border rounded-lg text-sm text-gray-600 hover:bg-gray-50"}," Mégse "),e("button",{type:"submit",disabled:l(p),class:"px-4 py-2 bg-indigo-600 text-white rounded-lg text-sm font-medium hover:bg-indigo-700 disabled:opacity-50"},a(l(p)?"Mentés...":l(r)?"MódosÃtások mentése":"Létrehozás"),9,ie)])],32)])])):c("",!0)]))}};export{re as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.