1import{bb as te,j as e,cn as ne}from"./index-D_txwql1.js";import{a as i}from"./i18n-vendor-DYmPQ2cw.js";import{u as re}from"./usePartnerAuth-C8q7Rqoy.js";/* empty css */import{g as se}from"./vehicleSwap-BaiRD7_y.js";import{g as oe,a as ie}from"./rentalPayment-ByuZDfU_.js";import{e as le,b as ae}from"./react-vendor-DY_e76sx.js";import"./firebase-vendor-DAxoB6-T.js";import"./returnHandover-0YDmv5qY.js";function de({collect:d,choice:l,paidAmount:c,paymentMethod:j,maxAmount:x}){const g={received:!1,paidAmount:null,paymentMethod:null,amountInvalid:!1};if(!d)return{ok:!0,...g};if(l==="none")return{ok:!0,...g};if(l!=="full"&&l!=="partial")return{ok:!1,...g};const n=Number(c),p=c!==""&&c!==null&&c!==void 0&&Number.isFinite(n),s=p&&n>0&&(x==null||n<=x+.005);return{ok:s&&!!j,received:!0,paidAmount:s?Math.round(n*100)/100:null,paymentMethod:j||null,amountInvalid:p&&!s}}const ce=[{key:"onsite_card",label:"Bankkártya (HelyszÃnen) ð³"},{key:"cash",label:"Készpénz (HelyszÃnen) ðµ"}],b=d=>Number(d||0).toLocaleString("hu-HU",{maximumFractionDigits:2});function je(){const{bookingId:d}=le(),l=ae(),{bookings:c=[],fleetVehicles:j=[],fleetLoading:x}=te(),{partnerUser:g}=re(),n=c.find(t=>t.id===d),p=n?j.find(t=>t.id===n.assignedVehicleId):null,[s,Z]=i.useState(""),[A,J]=i.useState("8/8"),[E,D]=i.useState(!1),[W,K]=i.useState(!1),[R,T]=i.useState(!1),[u,M]=i.useState(""),[P,H]=i.useState(""),[r,w]=i.useState("");if(x)return e.jsxs("div",{className:"partner-container",style:{textAlign:"center",marginTop:"40px"},children:[e.jsx("div",{style:{width:"30px",height:"30px",border:"3px solid #E5E7EB",borderTopColor:"#2563EB",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),e.jsx("p",{style:{color:"#6B7280",fontWeight:"700"},children:"Adatok betöltése... (Loading)"}),e.jsx("style",{children:"@keyframes spin { 100% { transform: rotate(360deg); } }"})]});if(!n||!p)return e.jsxs("div",{className:"partner-container",style:{textAlign:"center",marginTop:"40px"},children:[e.jsx("p",{children:"Hiba: A foglalás nem található."}),e.jsx("button",{className:"partner-btn",style:{marginTop:"20px"},onClick:()=>l(-1),children:"Vissza"})]});const Y=(t=>{const a=t.customerInfo;if(!a)return t.customerName||"Ãgyfél";const V=[a.firstNameEn,a.lastNameEn].filter(Boolean).join(" "),G=[a.lastName,a.firstName].filter(Boolean).join(" ");return V?`${V} / ${G}`:G||"Ãgyfél"})(n),{startKm:m,drivenKm:I,startKmUnknown:q}=se(n,s),f=!q&&m>0,Q=s!==""&&Number.isFinite(Number(s)),h=Number(s),z=Q&&h>0,B=z&&f&&h<m,L=z&&f&&h===m,y=oe(n),k=ie(y),O=k==="due"||k==="payLater",o=k==="due"?y.due:null,v=de({collect:O,choice:r,paidAmount:P,paymentMethod:u,maxAmount:o}),$=v.ok,S=r==="none",F=(t,a)=>{w(t),H(a)},X=t=>{w(t?"none":""),H(""),M("")},U=z&&(!B||W)&&(!L||R),_=!E&&U&&$,ee=async()=>{if(!z){alert("Kérjük, adja meg a km-óra állását.");return}if(!(!U||!$)){D(!0);try{await ne(d,{partnerReturnData:{staffName:g.name,km:h,fuelLevel:A,paymentMethod:v.paymentMethod,paidAmount:v.paidAmount,submittedAt:new Date().toISOString()},returnHandoverStatus:"partner_submitted",updatedAt:new Date().toISOString()}),alert("â
Adatok elküldve!"),l("/partner/dashboard")}catch(t){console.error(t),alert("â Hiba történt: "+t.message)}finally{D(!1)}}},N={display:"flex",alignItems:"center",gap:"10px",minHeight:"44px",marginTop:"8px",fontSize:"0.9rem",fontWeight:"700",color:"#1E293B",cursor:"pointer"},C={width:"22px",height:"22px",flexShrink:0};return e.jsxs("div",{className:"partner-container",style:{paddingBottom:"40px"},children:[e.jsx("div",{className:"partner-section-title",children:"Gépjármű Visszavétel"}),e.jsx("div",{className:"partner-section-subtitle",children:"Kérjük, ellenÅrizze a gépjármű állapotát."}),e.jsxs("div",{className:"partner-card",style:{marginBottom:"16px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{fontSize:"1.2rem",fontWeight:"800"},children:["Ãgyfél: ",Y]}),e.jsxs("div",{style:{fontSize:"1rem",fontWeight:"700"},children:["Gépjármű: ",e.jsx("span",{translate:"no",children:p.licensePlate})," (",p.name,")"]}),k==="corporate"?e.jsx("div",{style:{fontSize:"1rem",fontWeight:"800",color:"#475569"},children:"Céges számla"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:"1rem",fontWeight:"800",color:"#059669"},translate:"no",children:`Fizetve: â¬${b(y.paidTotal)}`}),k==="unknown"?e.jsx("div",{style:{fontSize:"0.9rem",fontWeight:"700",color:"#475569"},children:"A fizetés nincs rögzÃtve â az iroda ellenÅrzi."}):y.due>0&&e.jsx("div",{style:{fontSize:"1rem",fontWeight:"800",color:"#DC2626"},translate:"no",children:`Hátralék: â¬${b(y.due)}`})]}),e.jsxs("div",{style:{fontSize:"0.9rem",color:"#6B7280"},children:["Ãtadáskor (KM): ",e.jsx("span",{translate:"no",children:f?`${m.toLocaleStr
1ing("hu-HU")} km`:"â (ismeretlen)"})]})]}),e.jsxs("div",{className:"partner-card",style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"1rem",fontWeight:"700",marginBottom:"8px"},children:"Jelenlegi KM állás *"}),e.jsx("input",{type:"number",inputMode:"numeric",value:s,placeholder:f?`min. ${m}`:"km",onChange:t=>{Z(t.target.value),K(!1),T(!1)},className:"partner-login__input",style:{width:"100%",padding:"16px",fontSize:"1.2rem",fontWeight:"bold",textAlign:"center"}}),f&&I>0&&!B&&e.jsxs("div",{style:{fontSize:"0.85rem",color:"#059669",fontWeight:"600",marginTop:"8px",textAlign:"center"},children:["Megtett távolság: ",I.toLocaleString("hu-HU")," km"]}),B&&e.jsxs("div",{role:"alert",style:{marginTop:"8px",padding:"10px 12px",borderRadius:"10px",border:"1px solid #DC2626",background:"#FEF2F2"},children:[e.jsxs("div",{style:{fontSize:"0.9rem",fontWeight:"800",color:"#991B1B",lineHeight:1.4},children:["A megadott km (",h.toLocaleString("hu-HU"),") kisebb, mint az átadáskori (",m.toLocaleString("hu-HU"),"). EllenÅrizze a km-órát!"]}),e.jsxs("label",{style:N,children:[e.jsx("input",{type:"checkbox",checked:W,onChange:t=>K(t.target.checked),style:C}),e.jsx("span",{children:"EllenÅriztem, a km-óra valóban ezt mutatja"})]})]}),L&&e.jsxs("div",{style:{marginTop:"8px",padding:"10px 12px",borderRadius:"10px",border:"1px solid #D97706",background:"#FFFBEB"},children:[e.jsx("div",{style:{fontSize:"0.9rem",fontWeight:"800",color:"#92400E",lineHeight:1.4},children:"0 km megtett távolság â ugyanaz, mint átadáskor."}),e.jsxs("label",{style:N,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:t=>T(t.target.checked),style:C}),e.jsx("span",{children:"MegerÅsÃtem: a jármű nem ment"})]})]})]}),e.jsxs("div",{className:"partner-card",style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"1rem",fontWeight:"700",marginBottom:"8px"},children:"Ãzemanyag szint"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:["0","1/8","2/8","3/8","4/8","5/8","6/8","7/8","8/8"].map(t=>e.jsx("button",{onClick:()=>J(t),style:{flex:"1 0 20%",padding:"12px 0",minHeight:"44px",borderRadius:"8px",border:"none",fontSize:"0.9rem",fontWeight:"700",background:A===t?"#DC2626":"#F3F4F6",color:A===t?"#fff":"#374151"},children:t},t))})]}),O&&e.jsxs("div",{className:"partner-card",style:{marginBottom:"16px",background:"#EFF6FF",border:"2px solid #3B82F6"},children:[e.jsx("div",{style:{fontSize:"1.2rem",fontWeight:"800",color:"#1D4ED8",marginBottom:"16px",textAlign:"center"},children:"ð³ Kérjük, vegye át az összeget!"}),e.jsxs("div",{style:{fontSize:"0.9rem",color:"#1E3A8A",marginBottom:"8px"},children:["1. Befizetett Ãsszeg",o!==null?e.jsxs(e.Fragment,{children:[" (FizetendÅ: ",e.jsx("span",{translate:"no",children:`â¬${b(o)}`}),")"]}):" (az összeget az iroda erÅsÃti meg)"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px",marginBottom:"20px"},children:[o!==null&&e.jsxs("button",{onClick:()=>F("full",String(o)),style:{flex:1,padding:"16px 20px",borderRadius:"12px",cursor:"pointer",fontSize:"1.1rem",fontWeight:"700",background:r==="full"?"#ECFDF5":"#fff",border:r==="full"?"2px solid #059669":"1px solid #93C5FD",color:r==="full"?"#065F46":"#1E3A8A"},children:["â
Teljes összeg (",e.jsx("span",{translate:"no",children:`â¬${b(o)}`}),")"]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"number",inputMode:"decimal",value:r==="partial"?P:"",onChange:t=>F("partial",t.target.value),placeholder:"Ãsszeg",style:{flex:1,minWidth:0,padding:"16px",borderRadius:"12px",border:r==="partial"?"2px solid #2563EB":"1px solid #93C5FD",fontSize:"1.1rem",outline:"none"}}),e.jsx("button",{onClick:()=>F("partial",""),style:{padding:"16px 20px",borderRadius:"12px",fontWeight:"700",fontSize:"1.1rem",background:r==="partial"?"#DBEAFE":"#fff",border:r==="partial"?"2px solid #2563EB":"1px solid #93C5FD",color:r==="partial"?"#1D4ED8":"#1E3A8A"},children:"Részösszeg"})]}),r==="partial"&&v.amountInvalid&&e.jsx("div",{role:"alert",style:{fontSize:"0.85rem",fontWeight:"700",color:"#DC2626"},children:o!==null?`Az összeg 0-nál nagyobb és legfeljebb â¬${b(o)} lehet.`:"Az összegnek 0-nál nagyobbnak kell lennie."})]}),e.jsx("div",{style:{fontSize:"0.9rem",color:"#1E3A8A",marginBottom:"8px"},children:"2. Fizetési Mód"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:ce.map(t=>e.jsxs("button",{onClick:()=>M(t.key),disabled:S,style:{flex:1,padding:"16px 12px",borderRadius:"12px",cursor:S?"not-allowed":"pointer",opacity:S?.5:1,fontSize:"1.1rem",fontWeight:"700",background:u===t.key?"#DCFCE7":"#fff",border:u===t.key?"2px solid #059669":"1px solid #93C5FD",color:u===t.key?"#065F46":"#1E3A8A"},children:[t.label," ",u===t.key&&"â"]},t.key))}),e.jsxs("label",{style:{...N,marginTop:"16px",color:"#1E3A8A"},children:[e.jsx("input",{type:"checkbox",checked:S,onChange:t=>X(t.target.checked),style:C}),e.jsx("span",{children:"Nem vettem át fizetést â az iroda rendezi"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"16px"},children:[e.jsx("button",{onClick:()=>l(-1),className:"partner-btn",style:{flex:1,background:"#6B7280"},disabled:E,children:"Mégsem"}),e.jsx("button",{onClick:ee,className:"partner-btn",style:{flex:2,..._?{background:"#1A1A2E"}:{}},disabled:!_,children:E?"Mentés...":"Adatok Küldése"})]})]})}export{je 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.