import{d as _,q as h,m as y,c as n,a as e,F as V,x as z,b as r,v as u,s as B,e as g,r as p,t as o,n as f,p as k,o as i}from"./index-CgM2qJ96.js";const D={class:"p-6"},F={class:"flex justify-between items-center mb-6"},M={key:0,class:"text-center py-12"},j={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},C={key:2,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},S={class:"flex justify-between items-start"},E={class:"font-semibold text-lg"},K={class:"text-gray-600"},U={key:0,class:"text-sm text-gray-400"},L={class:"mt-4 grid grid-cols-2 gap-2 text-sm"},N={key:3,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},T={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},A={class:"space-y-4"},W={class:"grid grid-cols-2 gap-4"},$={class:"grid grid-cols-2 gap-4"},q={class:"flex justify-end space-x-2 mt-6"},P=_({__name:"VehiclesView",setup(H){const c=p(!0),m=p([]),d=p(!1),s=p({license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"});h(async()=>{await v()});async function v(){c.value=!0;try{const a=await y.get("/vehicles");m.value=a.data.vehicles||[]}catch(a){console.error(a)}c.value=!1}async function w(){try{await y.post("/vehicles",s.value),d.value=!1,s.value={license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"},await v()}catch(a){alert("Fehler: "+a.message)}}function b(a){return{available:{text:"Verfügbar",class:"bg-green-100 text-green-700",icon:"✅"},in_use:{text:"Im Einsatz",class:"bg-blue-100 text-blue-700",icon:"🚗"},maintenance:{text:"Wartung",class:"bg-yellow-100 text-yellow-700",icon:"🔧"},retired:{text:"Stillgelegt",class:"bg-gray-100 text-gray-700",icon:"⛔"}}[a]||{text:a,class:"bg-gray-100",icon:""}}return(a,t)=>(i(),n("div",D,[e("div",F,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"🚗 Fahrzeuge"),e("p",{class:"text-gray-500"},"Fuhrpark verwalten")],-1)),e("button",{onClick:t[0]||(t[0]=l=>d.value=!0),class:"btn btn-primary"},"+ Fahrzeug")]),c.value?(i(),n("div",M,"Laden...")):m.value.length===0?(i(),n("div",j,[...t[8]||(t[8]=[e("p",{class:"text-4xl mb-4"},"🚗",-1),e("p",null,"Keine Fahrzeuge vorhanden",-1)])])):(i(),n("div",C,[(i(!0),n(V,null,z(m.value,l=>{var x;return i(),n("div",{key:l.id,class:"bg-white rounded-lg shadow p-4"},[e("div",S,[e("div",null,[e("h3",E,o(l.license_plate),1),e("p",K,o(l.brand)+" "+o(l.model),1),l.year?(i(),n("p",U,"Baujahr "+o(l.year),1)):g("",!0)]),e("span",{class:f(["px-2 py-1 text-xs rounded",b(l.status).class])},o(b(l.status).icon)+" "+o(b(l.status).text),3)]),e("div",L,[e("div",null,[t[9]||(t[9]=e("span",{class:"text-gray-500"},"KM-Stand:",-1)),k(" "+o(((x=l.current_mileage)==null?void 0:x.toLocaleString())||"-"),1)]),e("div",null,[t[10]||(t[10]=e("span",{class:"text-gray-500"},"Kraftstoff:",-1)),k(" "+o(l.fuel_type),1)]),l.tuev_expires?(i(),n("div",{key:0,class:f(["col-span-2",new Date(l.tuev_expires)<new Date?"text-red-600":""])}," TÜV: "+o(new Date(l.tuev_expires).toLocaleDateString("de-DE")),3)):g("",!0)])])}),128))])),d.value?(i(),n("div",N,[e("div",T,[t[17]||(t[17]=e("h2",{class:"text-xl font-bold mb-4"},"Neues Fahrzeug",-1)),e("div",A,[e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium mb-1"},"Kennzeichen *",-1)),r(e("input",{"onUpdate:modelValue":t[1]||(t[1]=l=>s.value.license_plate=l),class:"input",placeholder:"B-AB 1234"},null,512),[[u,s.value.license_plate]])]),e("div",W,[e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"Marke",-1)),r(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>s.value.brand=l),class:"input",placeholder:"VW"},null,512),[[u,s.value.brand]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Modell",-1)),r(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>s.value.model=l),class:"input",placeholder:"Passat"},null,512),[[u,s.value.model]])])]),e("div",$,[e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Baujahr",-1)),r(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>s.value.year=l),type:"number",class:"input"},null,512),[[u,s.value.year,void 0,{number:!0}]])]),e("div",null,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-1"},"Kraftstoff",-1)),r(e("select",{"onUpdate:modelValue":t[5]||(t[5]=l=>s.value.fuel_type=l),class:"input"},[...t[15]||(t[15]=[e("option",{value:"diesel"},"Diesel",-1),e("option",{value:"petrol"},"Benzin",-1),e("option",{value:"electric"},"Elektro",-1),e("option",{value:"hybrid"},"Hybrid",-1)])],512),[[B,s.value.fuel_type]])])])]),e("div",q,[e("button",{onClick:t[6]||(t[6]=l=>d.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:w,class:"btn btn-primary"},"Erstellen")])])])):g("",!0)]))}});export{P as default};
