1import{h as N,i as v,r,j as e,L as y}from"./index-BVXfzIgM.js";import{u}from"./useServerFn-2jT0nyON.js";import{g as _,a as k}from"./ofertas.functions-CzGKfHTL.js";import{A}from"./arrow-left-DXRiW-DK.js";import{T as z}from"./truck-BNsi04_V.js";import{C}from"./clock-DHN_le_L.js";import{C as E}from"./check-D8M5KA8p.js";import{M as L}from"./message-circle-CTo5QE-0.js";import"./auth-middleware-CxFczgOs.js";import"./createServerFn-CqQsgiAH.js";import"./createLucideIcon-CHL6QdGL.js";function S(i,n="MXN"){return new Intl.NumberFormat("es-MX",{style:"currency",currency:n,maximumFractionDigits:0}).format(i)}function q(){const{solicitudId:i}=N.useParams(),n=v(),h=u(_),f=u(k),[s,g]=r.useState(null),[b,l]=r.useState(!0),[c,o]=r.useState(null),[d,m]=r.useState(null),x=async()=>{l(!0),o(null);try{const t=await h({data:{solicitud_id:i}});g(t)}catch(t){o(t?.message??"Error")}finally{l(!1)}};r.useEffect(()=>{x()},[i]);const j=async t=>{if(confirm("¿Aceptar esta oferta? Las demás se rechazarán automáticamente.")){m(t);try{await f({data:{oferta_id:t}}),await x(),n.invalidate()}catch(a){alert(a?.message??"No se pudo aceptar")}finally{m(null)}}};return e.jsx("div",{className:"min-h-screen px-4 py-10",style:{background:"#050d1a"},children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(y,{to:"/historial",className:"inline-flex items-center gap-2 text-white/60 hover:text-orange mb-8 text-sm",children:[e.jsx(A,{size:16})," Volver al historial"]}),b&&e.jsx("p",{className:"text-white/40 text-sm",children:"Cargando ofertas..."}),c&&e.jsx("p",{className:"text-red-400 text-sm",children:c}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:"Ofertas recibidas"}),e.jsxs("p",{className:"text-white/60 mt-2",children:[s.solicitud.numero_flete??s.solicitud.id.slice(0,8)," ·"," ",s.solicitud.origen_estado," â ",s.solicitud.destino_estado]}),e.jsx("span",{className:"inline-block mt-2 text-[10px] uppercase tracking-wider font-semibold px-2 py-1 rounded-full bg-white/10 text-white/70",children:s.solicitud.estatus})]}),s.solicitud.estatus==="cerrada_sin_ganador"&&e.jsx("div",{className:"rounded-xl p-4 mb-6 border border-yellow-500/30 bg-yellow-500/10 text-yellow-200 text-sm",children:"Esta solicitud venció sin que ninguna oferta fuera aceptada."}),s.ofertas.length===0?e.jsx("div",{className:"glass rounded-2xl p-8 text-center border border-white/10",children:e.jsx("p",{className:"text-white/60",children:"Aún no hay ofertas. Los transportistas las enviarán por WhatsApp."})}):e.jsx("div",{className:"space-y-3",children:s.ofertas.map(t=>{const a=t.ganadora&&t.estatus==="aceptada",p=t.estatus==="rechazada",w=s.solicitud.estatus==="publicada"&&(t.estatus==="enviada"||t.estatus==="vista_cliente");return e.jsxs("div",{className:`glass rounded-2xl p-5 border transition-all ${a?"border-green-500/40 bg-green-500/5":p?"border-white/5 opacity-50":"border-white/10 hover:border-orange/40"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:"w-11 h-11 shrink-0 rounded-full bg-orange/15 text-orange flex items-center justify-center",children:e.jsx(z,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-bold truncate",children:t.transportista.nombre_publico}),t.unidades_ofrecidas?e.jsx("p",{className:"text-white/50 text-xs mt-0.5",children:t.unidades_ofrecidas}):null,t.tiempo_estimado_horas!=null&&e.jsxs("p",{className:"text-white/40 text-xs mt-1 flex items-center gap-1",children:[e.jsx(C,{size:12})," ",t.tiempo_estimado_horas," h estimadas"]}),t.comentario&&e.jsxs("p",{className:"text-white/60 text-xs mt-2 italic",children:['"',t.comentario,'"']})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-orange font-bold text-2xl",children:S(t.monto,t.moneda)}),a&&e.jsxs("span",{className:"inline-flex items-center gap-1 mt-1 text-[10px] uppercase font-semibold text-green-400",children:[e.jsx(E,{size:12})," Aceptada"]}),p&&e.jsx("span",{className:"text-[10px] uppercase font-semibold text-white/40",children:"Rechazada"})]})]}),a&&t.whatsapp&&e.jsxs("a",{href:`https://wa.me/${t.whatsapp.replace(/[^\d]/g,"")}`,target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-flex items-center gap-2 bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-semibold",children:[e.jsx(L,{size:16})," Contactar por WhatsApp (",t.whatsapp,")"]}),w&&e.jsx("button",{onClick:()=>j(t.id),disabled:d===t.id,className:"mt-4 inline-flex items-center gap-2 bg-orange hover:bg-orange/90 disabled:opacity-50 text-white px-4 py-2 rounded-lg text-sm font-semibold",children:d===t.id?"Aceptando...":"Elegir esta oferta"})]},t.id)})})]})]})})}export{q as component};
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.