2 lines
37 KiB
JavaScript
2 lines
37 KiB
JavaScript
import{e as X,o as a,c as i,a as e,k as H,t as h,F as V,r as A,b as W,j as C,l as y,B as we,N as D,x as N,m as R,h as ge,O as ze,v as Ce,g as $e,d as I,P as Ve,y as j,z as T,I as Se,J as je,D as Ae,K as Ie,L as Te,Q as He}from"./BsgqXOrB.js";import{_ as be}from"./DlAUqK2U.js";const Me={class:"flex items-center gap-2 py-1"},Ne={class:"flex items-center gap-2 cursor-pointer flex-1"},Be=["checked"],Le={class:"text-sm text-slate-300"},Ke={class:"text-xs text-slate-500"},Fe={key:0,class:"ml-6 border-l border-slate-700 pl-3"},fe=X({__name:"TreeNode",props:{node:{},selectedIds:{},expandedIds:{}},emits:["toggle","toggle-expand"],setup(r){return(S,u)=>{const $=fe;return a(),i("div",null,[e("div",Me,[e("button",{onClick:u[0]||(u[0]=k=>S.$emit("toggle-expand",r.node.id)),class:"text-slate-500 hover:text-slate-300 transition w-4 h-4 flex items-center justify-center"},[(a(),i("svg",{class:H(["w-3 h-3 transition-transform",r.expandedIds.has(r.node.id)?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...u[4]||(u[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))]),e("label",Ne,[e("input",{type:"checkbox",checked:r.selectedIds.includes(r.node.id),onChange:u[1]||(u[1]=k=>S.$emit("toggle",r.node.id)),class:"w-4 h-4 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"},null,40,Be),e("span",Le,h(r.node.name_hu||r.node.name_en||r.node.key),1),e("span",Ke,"(Szint "+h(r.node.level)+")",1)])]),r.expandedIds.has(r.node.id)&&r.node.children?.length?(a(),i("div",Fe,[(a(!0),i(V,null,A(r.node.children,k=>(a(),i("div",{key:k.id},[W($,{node:k,"selected-ids":r.selectedIds,"expanded-ids":r.expandedIds,onToggle:u[2]||(u[2]=g=>S.$emit("toggle",g)),onToggleExpand:u[3]||(u[3]=g=>S.$emit("toggle-expand",g))},null,8,["node","selected-ids","expanded-ids"])]))),128))])):C("",!0)])}}}),Oe={class:"relative"},Ue={key:0,class:"block text-sm font-medium text-slate-300 mb-1"},De={class:"relative"},Ee=["value","onKeydown","placeholder"],Pe={key:0,class:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 animate-spin text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Je={key:1,class:"absolute z-50 mt-1 w-full bg-slate-800 border border-slate-600 rounded-lg shadow-xl max-h-60 overflow-y-auto"},Re=["onMousedown"],qe={class:"font-mono text-indigo-400"},Ye={class:"text-xs text-slate-500 ml-auto"},Ge={key:2,class:"absolute z-50 mt-1 w-full bg-slate-800 border border-slate-600 rounded-lg shadow-xl p-3 text-sm text-slate-400"},We=X({__name:"SmartLocationInput",props:{modelValue:{default:null},label:{default:""},placeholder:{default:"Kezdj el gépelni (irányítószám vagy város)..."},minChars:{default:2},countryCode:{default:"HU"},debounceMs:{default:300}},emits:["update:modelValue","select"],setup(r,{emit:S}){const u=r,$=S,k=y(null),g=y(""),m=y(u.modelValue),v=y([]),n=y(!1),b=y(!1),d=y(0);let E=null;const P=R(()=>m.value?`${m.value.zip_code} ${m.value.city}`:g.value),_=R(()=>{if(!g.value||g.value.length<u.minChars)return[];const f=g.value.toLowerCase();return v.value.filter(x=>x.zip_code.toLowerCase().includes(f)||x.city.toLowerCase().includes(f))});we(()=>u.modelValue,f=>{m.value=f});function B(f){const x=f.target;g.value=x.value,m.value&&(m.value=null,$("update:modelValue",null)),E&&clearTimeout(E),g.value.length>=u.minChars?E=setTimeout(()=>{L(g.value)},u.debounceMs):(v.value=[],b.value=!1)}async function L(f){if(!(!f||f.length<u.minChars)){n.value=!0;try{const x=await $fetch("/api/v1/locations/autocomplete",{params:{q:f,country_code:u.countryCode,limit:15},headers:K()});v.value=x||[],d.value=0,b.value=v.value.length>0}catch(x){console.error("Location autocomplete error:",x),v.value=[]}finally{n.value=!1}}}function K(){const f=ge("access_token").value,x={"Content-Type":"application/json"};return f&&(x.Authorization=`Bearer ${f}`),x}function s(f){m.value=f,g.value="",b.value=!1,$("update:modelValue",f),$("select",f)}function q(){m.value=null,g.value="",v.value=[],b.value=!1,$("update:modelValue",null),ze(()=>{k.value?.focus()})}function J(){b.value=!1}function Y(){_.value.length>0&&(b.value=!0)}function Z(){setTimeout(()=>{b.value=!1},200)}function Q(){_.value.length>0&&(d.value=(d.value+1)%_.value.length)}function G(){_.value.length>0&&(d.value=(d.value-1+_.value.length)%_.value.length)}function ee(){_.value.length>0&&d.value>=0&&s(_.value[d.value])}return(f,x)=>(a(),i("div",Oe,[r.label?(a(),i("label",Ue,h(r.label),1)):C("",!0),e("div",De,[e("input",{ref_key:"inputRef",ref:k,value:P.value,onInput:B,onFocus:Y,onBlur:Z,onKeydown:[D(N(Q,["prevent"]),["down"]),D(N(G,["prevent"]),["up"]),D(N(ee,["prevent"]),["enter"]),D(J,["escape"])],placeholder:r.placeholder,class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,Ee),n.value?(a(),i("svg",Pe,[...x[0]||(x[0]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])])):C("",!0),m.value&&!n.value?(a(),i("button",{key:1,onClick:q,class:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition",type:"button"},[...x[1]||(x[1]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])):C("",!0)]),b.value&&_.value.length>0?(a(),i("div",Je,[(a(!0),i(V,null,A(_.value,(M,te)=>(a(),i("button",{key:M.id,onMousedown:N(ae=>s(M),["prevent"]),class:H(["w-full text-left px-3 py-2 text-sm transition flex items-center gap-2",te===d.value?"bg-indigo-500/20 text-white":"text-slate-300 hover:bg-slate-700"])},[e("span",qe,h(M.zip_code),1),e("span",null,h(M.city),1),e("span",Ye,h(M.country_code),1)],42,Re))),128))])):C("",!0),b.value&&g.value.length>=r.minChars&&_.value.length===0&&!n.value?(a(),i("div",Ge," Nincs találat ")):C("",!0)]))}}),Xe=be(We,[["__scopeId","data-v-b43e13ca"]]),Ze={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},Qe={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},et={class:"md:col-span-2"},tt=["value"],st=["value"],ot=["value"],lt=["value"],nt=["value"],at=["value"],it=["value"],rt=X({__name:"SharedAddressForm",props:{modelValue:{default:()=>({zip:null,city:null,street_name:null,street_type:null,house_number:null,stairwell:null,floor:null,door:null,parcel_id:null,full_address_text:null,latitude:null,longitude:null})}},emits:["update:modelValue"],setup(r,{emit:S}){const u=r,$=S,k=R(()=>u.modelValue?.zip&&u.modelValue?.city?{id:0,zip_code:u.modelValue.zip,city:u.modelValue.city,country_code:"HU"}:null);function g(v){const n={...u.modelValue};v?(n.zip=v.zip_code,n.city=v.city):(n.zip=null,n.city=null),$("update:modelValue",n)}function m(v,n){const b={...u.modelValue};b[v]=n||null,$("update:modelValue",b)}return(v,n)=>{const b=Xe;return a(),i("div",null,[e("div",Ze,[n[15]||(n[15]=e("h2",{class:"text-lg font-semibold text-white mb-4"},"Cím adatok",-1)),e("div",Qe,[e("div",et,[W(b,{"model-value":k.value,"onUpdate:modelValue":g,label:"Irányítószám / Város",placeholder:"Kezdj el gépelni (pl. 1011 vagy Budapest)..."},null,8,["model-value"])]),e("div",null,[n[7]||(n[7]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Utca neve",-1)),e("input",{value:r.modelValue.street_name,onInput:n[0]||(n[0]=d=>m("street_name",d.target.value)),placeholder:"pl. Egressy",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,tt)]),e("div",null,[n[9]||(n[9]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Közterület jellege",-1)),e("select",{value:r.modelValue.street_type,onChange:n[1]||(n[1]=d=>m("street_type",d.target.value)),class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},[...n[8]||(n[8]=[Ce('<option value="">Válassz...</option><option value="utca">utca</option><option value="út">út</option><option value="tér">tér</option><option value="körút">körút</option><option value="sugárút">sugárút</option><option value="köz">köz</option><option value="sétány">sétány</option><option value="lakópark">lakópark</option><option value="liget">liget</option><option value="erdő">erdő</option><option value="dűlő">dűlő</option><option value="major">major</option><option value="puszta">puszta</option><option value="sziget">sziget</option><option value="telep">telep</option>',16)])],40,st)]),e("div",null,[n[10]||(n[10]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Házszám",-1)),e("input",{value:r.modelValue.house_number,onInput:n[2]||(n[2]=d=>m("house_number",d.target.value)),placeholder:"pl. 4/b",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,ot)]),e("div",null,[n[11]||(n[11]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Lépcsőház",-1)),e("input",{value:r.modelValue.stairwell,onInput:n[3]||(n[3]=d=>m("stairwell",d.target.value)),placeholder:"pl. 1",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,lt)]),e("div",null,[n[12]||(n[12]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Emelet",-1)),e("input",{value:r.modelValue.floor,onInput:n[4]||(n[4]=d=>m("floor",d.target.value)),placeholder:"pl. 3",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,nt)]),e("div",null,[n[13]||(n[13]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Ajtó",-1)),e("input",{value:r.modelValue.door,onInput:n[5]||(n[5]=d=>m("door",d.target.value)),placeholder:"pl. A",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,at)]),e("div",null,[n[14]||(n[14]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Helyrajzi szám (hrsz)",-1)),e("input",{value:r.modelValue.parcel_id,onInput:n[6]||(n[6]=d=>m("parcel_id",d.target.value)),placeholder:"pl. 12345/6",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,it)])])])])}}}),dt={class:"mb-8"},ut={class:"text-slate-400 mt-1"},ct={key:0,class:"flex items-center justify-center py-20"},pt={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},mt={key:2,class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},gt={class:"border-b border-slate-700 mb-6"},bt={class:"flex gap-6 -mb-px"},ft=["onClick"],vt={key:0,class:"max-w-3xl"},xt={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},yt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},ht={class:"md:col-span-2"},_t={class:"w-full px-3 py-2 bg-slate-700/50 border border-slate-600 rounded-lg text-slate-400 text-sm"},kt={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},wt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},zt={class:"md:col-span-2"},Ct={key:1,class:"max-w-4xl"},$t={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},Vt={class:"mb-8"},St={class:"grid grid-cols-2 md:grid-cols-4 gap-3"},jt=["value","checked","onChange"],At={class:"text-sm"},It={class:"mb-8"},Tt={key:0,class:"flex items-center gap-2 text-sm text-slate-400 py-4"},Ht={key:1,class:"space-y-1 max-h-96 overflow-y-auto pr-2"},Mt={class:"flex items-center gap-2 py-1"},Nt=["onClick"],Bt={class:"flex items-center gap-2 cursor-pointer flex-1"},Lt=["checked","onChange"],Kt={class:"text-sm font-medium text-white"},Ft={class:"text-xs text-slate-500"},Ot={key:0,class:"ml-6 border-l border-slate-700 pl-3"},Ut={key:2,class:"mt-4 flex flex-wrap gap-2"},Dt=["onClick"],Et={class:"mb-4"},Pt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Jt={class:"flex flex-wrap gap-2 mb-2"},Rt=["onClick"],qt={class:"flex gap-2"},Yt=["onKeydown"],Gt=["disabled"],Wt={class:"flex flex-wrap gap-2 mb-2"},Xt=["onClick"],Zt={class:"flex gap-2"},Qt=["onKeydown"],es=["disabled"],ts={key:2,class:"max-w-3xl"},ss={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},os={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},ls={class:"md:col-span-2"},ns={class:"md:col-span-2"},as={key:3,class:"max-w-3xl"},is={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},rs={class:"mb-6 p-4 rounded-lg border bg-indigo-500/5 border-indigo-500/20"},ds={class:"flex items-center gap-3 cursor-pointer"},us={class:"flex items-center gap-2 w-36 flex-shrink-0 cursor-pointer"},cs=["checked","onChange","disabled"],ps={class:"text-sm font-medium text-white"},ms={key:0,class:"flex items-center gap-2"},gs=["value","onInput","disabled"],bs=["value","onInput","disabled"],fs={key:1,class:"text-sm text-slate-500 italic"},vs={class:"sticky bottom-0 bg-slate-900/90 backdrop-blur-sm border-t border-slate-700 -mx-6 px-6 py-4 mt-8"},xs={class:"flex items-center justify-between max-w-4xl"},ys={class:"text-sm text-slate-400"},hs={key:0,class:"text-amber-400"},_s={key:1,class:"text-slate-500"},ks={class:"flex gap-3"},ws=["disabled"],zs={key:0,class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Cs={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},$s=X({__name:"edit",setup(r){const S=[{key:"car",label:"Személyautó"},{key:"motorcycle",label:"Motorkerékpár"},{key:"truck",label:"Teherautó"},{key:"hgv",label:"Nehézgépjármű (HGV)"},{key:"light_commercial",label:"Kishaszonjármű"},{key:"personal",label:"Személyes"},{key:"boat",label:"Csónak/Vízi"},{key:"other",label:"Egyéb"}],u=Ie(),$=Ae(),k=R(()=>Number(u.params.id)),g=y(!0),m=y(!1),v=y(null),n=y(!1),b=y(null),d=y("basic"),E=[{key:"basic",label:"Alapadatok & Kapcsolat",icon:"svg"},{key:"matrix",label:"Szolgáltatások & Járművek",icon:"svg"},{key:"location",label:"Helyszín & Lokáció",icon:"svg"},{key:"hours",label:"Nyitvatartás",icon:"svg"}],P=y([]),_=y(!1),B=y(new Set),L=y(""),K=y(""),s=je({name:"",address:"",city:"",address_zip:"",address_street_name:"",address_street_type:"",address_house_number:"",plus_code:"",contact_phone:"",contact_email:"",website:"",category:"",category_ids:[],supported_vehicle_classes:[],specializations:{brands:[],propulsion:[]},opening_hours:{},is_always_open:!1,address:{zip:"",city:"",street_name:"",street_type:"",house_number:"",stairwell:"",floor:"",door:"",parcel_id:"",full_address_text:"",latitude:null,longitude:null}}),q=R(()=>{if(!v.value)return!1;const o=v.value;if(s.name!==(o.name||"")||s.address!==(o.address||"")||s.plus_code!==(o.plus_code||"")||s.address.zip!==(o.address_zip||"")||s.address.city!==(o.city||"")||s.address.street_name!==(o.address_street_name||"")||s.address.street_type!==(o.address_street_type||"")||s.address.house_number!==(o.address_house_number||"")||s.contact_phone!==(o.contact_phone||"")||s.contact_email!==(o.contact_email||"")||s.website!==(o.website||"")||s.category!==(o.category||""))return!0;const t=[...s.category_ids].sort(),p=[...o.category_ids||[]].sort();if(JSON.stringify(t)!==JSON.stringify(p))return!0;const z=[...s.supported_vehicle_classes].sort(),l=[...o.supported_vehicle_classes||[]].sort();if(JSON.stringify(z)!==JSON.stringify(l))return!0;const c=w=>({brands:Array.isArray(w?.brands)?[...w.brands].sort():[],propulsion:Array.isArray(w?.propulsion)?[...w.propulsion].sort():[]});if(JSON.stringify(c(s.specializations))!==JSON.stringify(c(o.specializations)))return!0;const F=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],O=w=>{const le={},ke=w?.days||w;for(const ne of F){const U=ke?.[ne];U&&typeof U=="object"&&U.open&&U.close?le[ne]={open:U.open,close:U.close}:le[ne]=null}return le};return JSON.stringify(O(s.opening_hours))!==JSON.stringify(O(o.opening_hours))||s.is_always_open!==(o.opening_hours?.always_open===!0)});function J(){const o=ge("access_token").value,t={"Content-Type":"application/json"};return o&&(t.Authorization=`Bearer ${o}`),t}async function Y(){g.value=!0,m.value=!1;try{const o=await $fetch(`/api/v1/admin/providers/${k.value}`,{headers:J()});v.value=o,Z(o)}catch(o){console.error("Failed to fetch provider:",o),m.value=!0}finally{g.value=!1}}function Z(o){s.name=o.name||"",s.address=o.address||"",s.city=o.city||"",s.address_zip=o.address_zip||"",s.address_street_name=o.address_street_name||"",s.address_street_type=o.address_street_type||"",s.address_house_number=o.address_house_number||"",s.plus_code=o.plus_code||"",s.address.zip=o.address_zip||"",s.address.city=o.city||"",s.address.street_name=o.address_street_name||"",s.address.street_type=o.address_street_type||"",s.address.house_number=o.address_house_number||"",s.address.full_address_text=o.address||"",s.contact_phone=o.contact_phone||"",s.contact_email=o.contact_email||"",s.website=o.website||"",s.category=o.category||"",s.category_ids=o.category_ids||[],s.supported_vehicle_classes=o.supported_vehicle_classes||[];const t=o.specializations||{};s.specializations={brands:Array.isArray(t.brands)?t.brands:[],propulsion:Array.isArray(t.propulsion)?t.propulsion:[]};const p=o.opening_hours||{},z=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],l=p.always_open===!0,c=p.days||p;s.is_always_open=l;const F={};for(const O of z){const w=c[O];w&&typeof w=="object"&&w.open&&w.close?F[O]={open:w.open,close:w.close}:F[O]=null}s.opening_hours=F}async function Q(){_.value=!0;try{const o=await $fetch("/api/v1/providers/categories/tree",{headers:J()});P.value=o||[]}catch(o){console.error("Failed to fetch category tree:",o)}finally{_.value=!1}}function G(o,t){for(const p of t){if(p.id===o)return p;if(p.children?.length){const z=G(o,p.children);if(z)return z}}return null}function ee(o){const t=G(o,P.value);return t?t.name_hu||t.name_en||t.key:`#${o}`}function f(o){const t=s.supported_vehicle_classes.indexOf(o);t>=0?s.supported_vehicle_classes.splice(t,1):s.supported_vehicle_classes.push(o)}function x(o){const t=s.category_ids.indexOf(o);t>=0?s.category_ids.splice(t,1):s.category_ids.push(o)}function M(o){const t=new Set(B.value);t.has(o)?t.delete(o):t.add(o),B.value=t}function te(o){return s.category_ids.includes(o)}function ae(o){const t=s.category_ids.indexOf(o);t>=0&&s.category_ids.splice(t,1)}function ie(){const o=L.value.trim();o&&!s.specializations.brands.includes(o)&&s.specializations.brands.push(o),L.value=""}function ve(o){s.specializations.brands.splice(o,1)}function re(){const o=K.value.trim();o&&!s.specializations.propulsion.includes(o)&&s.specializations.propulsion.push(o),K.value=""}function xe(o){s.specializations.propulsion.splice(o,1)}const se=[{key:"monday",label:"Hétfő"},{key:"tuesday",label:"Kedd"},{key:"wednesday",label:"Szerda"},{key:"thursday",label:"Csütörtök"},{key:"friday",label:"Péntek"},{key:"saturday",label:"Szombat"},{key:"sunday",label:"Vasárnap"}];function ye(){s.is_always_open?ue("00:00","23:59"):ce()}function he(o){s.opening_hours[o]?s.opening_hours[o]=null:s.opening_hours[o]={open:"08:00",close:"17:00"}}function de(o,t,p){const z=s.opening_hours[o];z&&(z[t]=p)}function ue(o,t){for(const p of se)s.opening_hours[p.key]={open:o,close:t}}function _e(){const o=s.opening_hours.monday;if(!o)return;const t=["tuesday","wednesday","thursday","friday"];for(const p of t)s.opening_hours[p]={open:o.open,close:o.close}}function ce(){for(const o of se)s.opening_hours[o.key]=null}async function oe(){if(n.value)return;n.value=!0;const o=s.address?.full_address_text?.trim()||s.name,t={name:s.name,address:o,category:s.category||null,contact_phone:s.contact_phone||null,contact_email:s.contact_email||null,website:s.website||null,plus_code:s.plus_code||null,category_ids:s.category_ids,supported_vehicle_classes:s.supported_vehicle_classes,specializations:s.specializations,opening_hours:s.opening_hours,is_always_open:s.is_always_open,address_detail:{zip:s.address.zip||null,city:s.address.city||null,street_name:s.address.street_name||null,street_type:s.address.street_type||null,house_number:s.address.house_number||null,stairwell:s.address.stairwell||null,floor:s.address.floor||null,door:s.address.door||null,parcel_id:s.address.parcel_id||null,full_address_text:o,latitude:s.address.latitude,longitude:s.address.longitude}};try{await $fetch(`/api/v1/admin/providers/${k.value}`,{method:"PATCH",headers:J(),body:t}),me("success","Szolgáltató sikeresen frissítve!"),setTimeout(()=>{$.push(`/providers/${k.value}`)},1200)}catch(p){console.error("Failed to save provider:",p);const z=p?.data?.detail||p?.message||"Ismeretlen hiba történt mentés közben.";me("error",`Hiba: ${z}`)}finally{n.value=!1}}function pe(){$.push(`/providers/${k.value}`)}function me(o,t){b.value={type:o,message:t},setTimeout(()=>{b.value=null},3e3)}return $e(async()=>{await Y(),await Q()}),(o,t)=>{const p=fe,z=rt;return a(),i("div",null,[e("div",dt,[e("button",{onClick:pe,class:"inline-flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition mb-4"},[...t[12]||(t[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1),I(" Vissza a szolgáltatóhoz ",-1)])]),t[13]||(t[13]=e("h1",{class:"text-2xl font-bold text-white"},"Szolgáltató szerkesztése",-1)),e("p",ut,"Szolgáltató #"+h((o._.provides[Ve]||o.$route).params.id),1)]),g.value?(a(),i("div",ct,[...t[14]||(t[14]=[e("div",{class:"text-slate-400 flex items-center gap-3"},[e("svg",{class:"w-5 h-5 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})]),e("span",null,"Szolgáltató betöltése...")],-1)])])):m.value?(a(),i("div",pt,[t[15]||(t[15]=e("p",{class:"text-rose-400"},"Hiba történt a szolgáltató betöltése közben.",-1)),e("button",{onClick:Y,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},"Újrapróbálkozás")])):v.value?(a(),i(V,{key:3},[e("div",gt,[e("nav",bt,[(a(),i(V,null,A(E,l=>e("button",{key:l.key,onClick:c=>d.value=l.key,class:H(["pb-3 text-sm font-medium border-b-2 transition flex items-center gap-2",d.value===l.key?"text-indigo-400 border-indigo-400":"text-slate-400 border-transparent hover:text-slate-300"])},[(a(),Te(He(l.icon),{class:"w-4 h-4"})),I(" "+h(l.label),1)],10,ft)),64))])]),d.value==="basic"?(a(),i("div",vt,[e("form",{onSubmit:N(oe,["prevent"])},[e("div",xt,[t[20]||(t[20]=e("h2",{class:"text-lg font-semibold text-white mb-4"},"Alapadatok",-1)),e("div",yt,[e("div",ht,[t[17]||(t[17]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Név *",-1)),j(e("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>s.name=l),required:"",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.name]])]),e("div",null,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Kategória",-1)),j(e("input",{"onUpdate:modelValue":t[1]||(t[1]=l=>s.category=l),placeholder:"pl. Autószerviz, Gumiszerviz",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.category]])]),e("div",null,[t[19]||(t[19]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Forrás",-1)),e("div",_t,h(v.value.source),1)])])]),e("div",kt,[t[24]||(t[24]=e("h2",{class:"text-lg font-semibold text-white mb-4"},"Elérhetőség",-1)),e("div",wt,[e("div",null,[t[21]||(t[21]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Telefon",-1)),j(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>s.contact_phone=l),placeholder:"+36 30 123 4567",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.contact_phone]])]),e("div",null,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Email",-1)),j(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>s.contact_email=l),type:"email",placeholder:"info@example.com",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.contact_email]])]),e("div",zt,[t[23]||(t[23]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Weboldal",-1)),j(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>s.website=l),placeholder:"https://...",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.website]])])])])],32)])):C("",!0),d.value==="matrix"?(a(),i("div",Ct,[e("div",$t,[t[38]||(t[38]=e("h2",{class:"text-lg font-semibold text-white mb-2"},"3D Képesség Mátrix",-1)),t[39]||(t[39]=e("p",{class:"text-sm text-slate-400 mb-6"}," Állítsd be, hogy a szolgáltató milyen járműosztályokhoz, szolgáltatási kategóriákhoz és specializációkhoz tartozik. ",-1)),e("div",Vt,[t[25]||(t[25]=e("h3",{class:"text-md font-medium text-white mb-3 flex items-center gap-2"},[e("span",{class:"w-6 h-6 rounded-full bg-indigo-500/20 text-indigo-400 flex items-center justify-center text-xs font-bold"},"A"),I(" Járműosztályok (Vehicle Classes) ")],-1)),t[26]||(t[26]=e("p",{class:"text-xs text-slate-500 mb-3"},"Mely járműtípusokat szervizeli a szolgáltató?",-1)),e("div",St,[(a(),i(V,null,A(S,l=>e("label",{key:l.key,class:H(["flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition",s.supported_vehicle_classes.includes(l.key)?"bg-indigo-500/10 border-indigo-500/40 text-indigo-300":"bg-slate-700/50 border-slate-600 hover:border-slate-500 text-slate-300"])},[e("input",{type:"checkbox",value:l.key,checked:s.supported_vehicle_classes.includes(l.key),onChange:c=>f(l.key),class:"w-4 h-4 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"},null,40,jt),e("span",At,h(l.label),1)],2)),64))])]),e("div",It,[t[30]||(t[30]=e("h3",{class:"text-md font-medium text-white mb-3 flex items-center gap-2"},[e("span",{class:"w-6 h-6 rounded-full bg-emerald-500/20 text-emerald-400 flex items-center justify-center text-xs font-bold"},"B"),I(" Szolgáltatási Kategóriák (Expertise Tags) ")],-1)),t[31]||(t[31]=e("p",{class:"text-xs text-slate-500 mb-3"},"Válaszd ki a szolgáltatóhoz tartozó kategóriákat a hierarchikus fából.",-1)),_.value?(a(),i("div",Tt,[...t[27]||(t[27]=[e("svg",{class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1),e("span",null,"Kategóriák betöltése...",-1)])])):(a(),i("div",Ht,[(a(!0),i(V,null,A(P.value,l=>(a(),i("div",{key:l.id,class:"ml-0"},[e("div",Mt,[e("button",{onClick:c=>M(l.id),class:"text-slate-500 hover:text-slate-300 transition w-4 h-4 flex items-center justify-center"},[(a(),i("svg",{class:H(["w-3 h-3 transition-transform",B.value.has(l.id)?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...t[28]||(t[28]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))],8,Nt),e("label",Bt,[e("input",{type:"checkbox",checked:te(l.id),onChange:c=>x(l.id),class:"w-4 h-4 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"},null,40,Lt),e("span",Kt,h(l.name_hu||l.name_en||l.key),1),e("span",Ft,"(Szint "+h(l.level)+")",1)])]),B.value.has(l.id)&&l.children?.length?(a(),i("div",Ot,[(a(!0),i(V,null,A(l.children,c=>(a(),i("div",{key:c.id},[W(p,{node:c,"selected-ids":s.category_ids,"expanded-ids":B.value,onToggle:x,onToggleExpand:M},null,8,["node","selected-ids","expanded-ids"])]))),128))])):C("",!0)]))),128))])),s.category_ids.length>0?(a(),i("div",Ut,[(a(!0),i(V,null,A(s.category_ids,l=>(a(),i("span",{key:l,class:"inline-flex items-center gap-1 px-2 py-1 bg-indigo-500/10 text-indigo-300 rounded-full text-xs"},[I(h(ee(l))+" ",1),e("button",{onClick:c=>ae(l),class:"hover:text-white transition"},[...t[29]||(t[29]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Dt)]))),128))])):C("",!0)]),e("div",Et,[t[36]||(t[36]=e("h3",{class:"text-md font-medium text-white mb-3 flex items-center gap-2"},[e("span",{class:"w-6 h-6 rounded-full bg-amber-500/20 text-amber-400 flex items-center justify-center text-xs font-bold"},"C"),I(" Specializációk ")],-1)),t[37]||(t[37]=e("p",{class:"text-xs text-slate-500 mb-3"},"Adj meg speciális márkákat, hajtáslánc típusokat vagy egyéb címkéket.",-1)),e("div",Pt,[e("div",null,[t[33]||(t[33]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Márkák (Brands)",-1)),e("div",Jt,[(a(!0),i(V,null,A(s.specializations.brands,(l,c)=>(a(),i("span",{key:c,class:"inline-flex items-center gap-1 px-2 py-1 bg-amber-500/10 text-amber-300 rounded-full text-xs"},[I(h(l)+" ",1),e("button",{onClick:F=>ve(c),class:"hover:text-white transition"},[...t[32]||(t[32]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Rt)]))),128))]),e("div",qt,[j(e("input",{"onUpdate:modelValue":t[5]||(t[5]=l=>L.value=l),onKeydown:D(N(ie,["prevent"]),["enter"]),placeholder:"pl. Volvo, Scania",class:"flex-1 px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,Yt),[[T,L.value]]),e("button",{onClick:ie,disabled:!L.value.trim(),class:"px-3 py-2 bg-indigo-600 hover:bg-indigo-500 disabled:bg-indigo-600/50 text-white rounded-lg text-sm transition"}," Hozzáad ",8,Gt)])]),e("div",null,[t[35]||(t[35]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Hajtáslánc (Propulsion)",-1)),e("div",Wt,[(a(!0),i(V,null,A(s.specializations.propulsion,(l,c)=>(a(),i("span",{key:c,class:"inline-flex items-center gap-1 px-2 py-1 bg-emerald-500/10 text-emerald-300 rounded-full text-xs"},[I(h(l)+" ",1),e("button",{onClick:F=>xe(c),class:"hover:text-white transition"},[...t[34]||(t[34]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Xt)]))),128))]),e("div",Zt,[j(e("input",{"onUpdate:modelValue":t[6]||(t[6]=l=>K.value=l),onKeydown:D(N(re,["prevent"]),["enter"]),placeholder:"pl. EV, Hybrid, Diesel",class:"flex-1 px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,Qt),[[T,K.value]]),e("button",{onClick:re,disabled:!K.value.trim(),class:"px-3 py-2 bg-indigo-600 hover:bg-indigo-500 disabled:bg-indigo-600/50 text-white rounded-lg text-sm transition"}," Hozzáad ",8,es)])])])])])])):C("",!0),d.value==="location"?(a(),i("div",ts,[e("form",{onSubmit:N(oe,["prevent"])},[W(z,{modelValue:s.address,"onUpdate:modelValue":t[7]||(t[7]=l=>s.address=l)},null,8,["modelValue"]),e("div",ss,[t[42]||(t[42]=e("h2",{class:"text-lg font-semibold text-white mb-4"},"További helyszín adatok",-1)),e("div",os,[e("div",ls,[t[40]||(t[40]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Teljes cím szövege",-1)),j(e("input",{"onUpdate:modelValue":t[8]||(t[8]=l=>s.address.full_address_text=l),placeholder:"Teljes cím szövege",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.address.full_address_text]])]),e("div",ns,[t[41]||(t[41]=e("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Plus Code",-1)),j(e("input",{"onUpdate:modelValue":t[9]||(t[9]=l=>s.plus_code=l),placeholder:"8FVC9X8V+XV",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,512),[[T,s.plus_code]])])])])],32)])):C("",!0),d.value==="hours"?(a(),i("div",as,[e("div",is,[t[45]||(t[45]=e("h2",{class:"text-lg font-semibold text-white mb-2"},"Nyitvatartás",-1)),t[46]||(t[46]=e("p",{class:"text-sm text-slate-400 mb-6"}," Állítsd be a szolgáltató nyitvatartási idejét napokra bontva. ",-1)),e("div",rs,[e("label",ds,[j(e("input",{type:"checkbox","onUpdate:modelValue":t[10]||(t[10]=l=>s.is_always_open=l),onChange:ye,class:"w-5 h-5 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"},null,544),[[Se,s.is_always_open]]),t[43]||(t[43]=e("div",null,[e("span",{class:"text-sm font-medium text-white"},"Folyamatos (0-24) nyitvatartás"),e("p",{class:"text-xs text-slate-400 mt-0.5"},"A szolgáltató a hét minden napján 0-24 óráig nyitva van")],-1))])]),e("div",{class:H(["flex flex-wrap gap-2 mb-6",{"opacity-50 pointer-events-none":s.is_always_open}])},[e("button",{onClick:t[11]||(t[11]=l=>ue("00:00","23:59")),class:"px-3 py-1.5 text-xs font-medium rounded-lg border border-emerald-600/30 text-emerald-400 hover:bg-emerald-600/10 transition"}," 24/7 Folyamatos nyitvatartás "),e("button",{onClick:_e,class:"px-3 py-1.5 text-xs font-medium rounded-lg border border-indigo-600/30 text-indigo-400 hover:bg-indigo-600/10"}," Hétköznapok másolása (Hétfő → K-P) "),e("button",{onClick:ce,class:"px-3 py-1.5 text-xs font-medium rounded-lg border border-rose-600/30 text-rose-400 hover:bg-rose-600/10"}," Összes törlése ")],2),e("div",{class:H(["space-y-3",{"opacity-50 pointer-events-none":s.is_always_open}])},[(a(),i(V,null,A(se,l=>e("div",{key:l.key,class:H(["flex items-center gap-4 p-4 rounded-lg border",s.opening_hours[l.key]?"bg-indigo-500/5 border-indigo-500/20":"bg-slate-700/30 border-slate-600"])},[e("label",us,[e("input",{type:"checkbox",checked:!!s.opening_hours[l.key],onChange:c=>he(l.key),disabled:s.is_always_open,class:"w-4 h-4 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"},null,40,cs),e("span",ps,h(l.label),1)]),s.opening_hours[l.key]?(a(),i("div",ms,[e("input",{type:"time",value:s.opening_hours[l.key]?.open||"08:00",onInput:c=>de(l.key,"open",c.target.value),disabled:s.is_always_open,class:"w-28 px-2 py-1.5 bg-slate-700 border border-slate-600 rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 disabled:opacity-50"},null,40,gs),t[44]||(t[44]=e("span",{class:"text-slate-500 text-sm"},"–",-1)),e("input",{type:"time",value:s.opening_hours[l.key]?.close||"17:00",onInput:c=>de(l.key,"close",c.target.value),disabled:s.is_always_open,class:"w-28 px-2 py-1.5 bg-slate-700 border border-slate-600 rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 disabled:opacity-50"},null,40,bs)])):(a(),i("span",fs,"Zárva"))],2)),64))],2)])])):C("",!0),e("div",vs,[e("div",xs,[e("div",ys,[q.value?(a(),i("span",hs,"● Módosítások el nem mentve")):(a(),i("span",_s,"Nincs változás"))]),e("div",ks,[e("button",{onClick:pe,class:"px-4 py-2 text-sm text-slate-400 hover:text-white transition"}," Mégse "),e("button",{onClick:oe,disabled:n.value||!q.value,class:"px-6 py-2 bg-indigo-600 hover:bg-indigo-500 disabled:bg-indigo-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"},[n.value?(a(),i("svg",zs,[...t[47]||(t[47]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])])):(a(),i("svg",Cs,[...t[48]||(t[48]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])])),t[49]||(t[49]=I(" Mentés ",-1))],8,ws)])])])],64)):(a(),i("div",mt,[...t[16]||(t[16]=[e("p",{class:"text-slate-400 text-center py-12"},"A szolgáltató nem található.",-1)])])),b.value?(a(),i("div",{key:4,class:H(["fixed top-4 right-4 z-50 px-4 py-3 rounded-lg shadow-xl text-sm font-medium transition-all duration-300",b.value.type==="success"?"bg-emerald-600 text-white":"bg-rose-600 text-white"])},h(b.value.message),3)):C("",!0)])}}}),js=be($s,[["__scopeId","data-v-ab22d560"]]);export{js as default};
|