1import{r as s,j as e}from"./index-9RYYQKcH.js";const x="https://crm-ia-production-c247.up.railway.app/api",u=()=>typeof window<"u"&&localStorage.getItem("chef_pass")||"",M="inline-flex items-center gap-1.5 rounded-lg border border-neutral-300 bg-white px-3.5 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-100";function J(){const[a,n]=s.useState(u()),[r,o]=s.useState(""),[c,l]=s.useState(""),[D,N]=s.useState(""),[I,d]=s.useState([]),[L,y]=s.useState(!1),[h,w]=s.useState(""),[k,S]=s.useState(""),[z,K]=s.useState(""),[b,B]=s.useState(""),[P,A]=s.useState(""),[C,R]=s.useState("3.95"),[$,_]=s.useState("");s.useEffect(()=>{a&&fetch(`${x}/providers`,{headers:{"x-chef-pass":u()}}).then(t=>{t.status===401&&(localStorage.removeItem("chef_pass"),n(""))})},[a]);const T=async()=>{l("");try{if(!(await fetch(`${x}/providers`,{headers:{"x-chef-pass":r}})).ok)throw new Error;localStorage.setItem("chef_pass",r),n(r)}catch{l("Contraseña incorrecta")}},q=async t=>{if(N(t),t.trim().length<2){d([]);return}y(!0);try{const g=await fetch(`${x}/chef-requests/kommo-leads?q=${encodeURIComponent(t)}`,{headers:{"x-chef-pass":u()}});d(g.ok?await g.json():[])}catch{d([])}y(!1)},H=async t=>{d([]),N("");try{const v=await(await fetch(`${x}/providers/lead/${t}`,{headers:{"x-chef-pass":u()}})).json();w((v.name||"").trim()),S(v.email||""),K(v.phone||"")}catch{}},E=Number(P)||0,m=Number(C)||0,f=E*(1+m/100),j=t=>`$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,U=`Hi ${h||"[client]"}! Here's your secure payment link for ${b||"your service"}: 2${$||"[paste the PlaceToPay link here]"} 3 4Total: ${j(f)} (includes ${m}% card processing fee). 5Please let us know once it's completed. Thank you! â Fix a Trip`;return a?e.jsx("div",{className:"min-h-screen bg-neutral-50 text-neutral-900",children:e.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("a",{href:"/admin",className:"mb-2 "+M,children:"â Menú admin"}),e.jsx("h1",{className:"text-xl font-bold",children:"Link de pago"}),e.jsx("p",{className:"text-sm text-neutral-500",children:"Calcula el monto con el fee y arma todo para PlaceToPay + el mensaje al cliente."})]}),e.jsx("button",{onClick:()=>{localStorage.removeItem("chef_pass"),n("")},className:"rounded-lg border border-neutral-200 px-3 py-2 text-sm text-neutral-500",children:"Salir"})]}),e.jsxs("div",{className:"mb-4 rounded-2xl border border-neutral-200 bg-white p-4",children:[e.jsx("div",{className:"text-sm font-bold uppercase tracking-wide text-neutral-600",children:"1 · Cliente (Kommo)"}),e.jsx("input",{value:D,onChange:t=>q(t.target.value),placeholder:"Buscar por nombre, teléfono o emailâ¦",className:"mt-2 w-full rounded-lg border border-neutral-200 px-3 py-2 text-sm outline-none focus:border-neutral-900"}),L&&e.jsx("div",{className:"py-2 text-center text-xs text-neutral-400",children:"Buscando en Kommoâ¦"}),I.map(t=>e.jsxs("button",{onClick:()=>H(t.id),className:"flex w-full items-center justify-between border-b border-neutral-100 py-2 text-left text-sm hover:bg-neutral-50",children:[e.jsx("span",{className:"font-medium",children:t.name||`Lead #${t.id}`}),e.jsxs("span",{className:"text-xs text-neutral-400",children:["Kommo #",t.id]})]},t.id)),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{label:"Nombre (referencia)",v:h,set:w}),e.jsx(i,{label:"Email",v:k,set:S})]})]}),e.jsxs("div",{className:"mb-4 rounded-2xl border border-neutral-200 bg-white p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-bold uppercase tracking-wide text-neutral-600",children:"2 · Monto y servicio"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(i,{label:"Monto factura ($)",v:P,set:A,type:"number",placeholder:"0.00"}),e.jsx(i,{label:"Fee %",v:C,set:R,type:"number"}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(i,{label:"Descripción / servicio",v:b,set:B,placeholder:"Transportation, Chef service, Tourâ¦"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between rounded-xl bg-neutral-900 px-4 py-3 text-white",children:[e.jsxs("span",{className:"text-sm",children:["Monto final (con ",m,"% fee)"]}),e.jsx("span",{className:"text-2xl font-bold",children:j(f)})]}),e.jsxs("p",{className:"mt-1 text-right text-xs text-neutral-400",children:[j(E)," à ",(1+m/100).toFixed(2)]})]}),e.jsxs("div",{className:"mb-4 rounded-2xl border border-neutral-200 bg-white p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-bold uppercase tracking-wide text-neutral-600",children:"3 · Datos para PlaceToPay (copiar)"}),e.jsx(p,{label:"Referencia",value:h}),e.jsx(p,{label:"Descripción",value:b}),e.jsx(p,{label:"Monto",value:f.toFixed(2)}),e.jsx(p,{label:"Email",value:k}),e.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:'Pega estos datos al crear el link en PlaceToPay, activa "uso múltiple" y expiración mÃnima 1 dÃa.'})]}),e.jsxs("div",{className:"rounded-2xl border border-neutral-200 bg-white p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-bold uppercase tracking-wide text-neutral-600",children:"4 · Mensaje al cliente"}),e.jsx(i,{label:"Pega aquà el link generado en PlaceToPay",v:$,set:_,placeholder:"https://â¦"}),e.jsx(Q,{text:U})]})]})}):e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-neutral-50 px-6",children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl bg-white p-6 shadow-sm",children:[e.jsx("a",{href:"/admin",className:"mb-3 "+M,children:"â Menú admin"}),e.jsx("h1",{className:"text-lg font-bold",children:"Link de pago · Panel interno"}),e.jsx("p",{className:"mt-1 text-sm text-neutral-500",children:"Ingresa con la contraseña del panel."}),e.jsx("input",{type:"password",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.key==="Enter"&&T(),placeholder:"Contraseña",className:"mt-4 w-full rounded-lg border border-neutral-200 px-3 py-2 text-sm outline-none focus:border-neutral-900"}),c&&e.jsx("p",{className:"mt-2 text-xs text-red-600",children:c}),e.jsx("button",{onClick:T,className:"mt-4 w-full rounded-lg bg-neutral-900 py-2.5 text-sm font-semibold text-white",children:"Entrar"})]})})}function i({label:a,v:n,set:r,type:o="text",placeholder:c}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-neutral-400",children:a}),e.jsx("input",{type:o,value:n,onChange:l=>r(l.target.value),placeholder:c,className:"mt-0.5 w-full rounded-lg border border-neutral-200 px-2.5 py-1.5 text-sm outline-none focus:border-neutral-900"})]})}function p({label:a,value:n}){return e.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-100 py-2 text-sm last:border-0",children:[e.jsxs("span",{children:[e.jsxs("span",{className:"text-neutral-400",children:[a,":"]})," ",e.jsx("b",{children:n||"â"})]}),e.jsx(F,{text:n,label:"copiar"})]})}function Q({text:a}){return e.jsxs("div",{className:"mt-3 rounded-xl border border-neutral-200 bg-neutral-50 p-3",children:[e.jsx("div",{className:"mb-1.5 flex items-center justify-end",children:e.jsx(F,{text:a,label:"Copiar mensaje"})}),e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm text-neutral-800",children:a})]})}function F({text:a,label:n}){const[r,o]=s.useState(!1),c=()=>{var l;(l=navigator.clipboard)==null||l.writeText(a),o(!0),setTimeout(()=>
5o(!1),1500)};return e.jsx("button",{onClick:c,className:`rounded-lg bg-neutral-900 px-2.5 py-1 text-xs font-semibold text-white ${r?"opacity-70":""}`,children:r?"â Copiado":n})}export{J 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.