PageSourceSearch

https://funsatecr.org/assets/DonacionMovil-NtxPHan6.js

js funsatecr.org collected 2026-10-05 22:08:07 UTC 8,793 bytes, 1 lines download raw bytes

1import{X as L,u as M,x as P,r,s as b,j as e,C as c,g as l,aJ as R,B as d,H as z,h as v,i as y,k as B,l as H}from"./index-DWPX63hm.js";import{I as g}from"./input-DcYAMhDB.js";import{L as h}from"./label-ww-6tmNz.js";import{C as Q}from"./checkbox-CjZpD--j.js";import{A as U}from"./arrow-left-BjP34Z-b.js";import"./index-B_gb8hAG.js";import"./check-CCjGdAru.js";const W=()=>{var N;const{qrCode:u}=L(),j=M(),{toast:m}=P(),[n,C]=r.useState(null),[f,w]=r.useState([]),[A,E]=r.useState(!0),[o,p]=r.useState("selection"),[i,S]=r.useState(""),[a,x]=r.useState({nombre:"",email:"",monto:"",consentimiento:!1}),[k,D]=r.useState("");r.useEffect(()=>{_(),F()},[u]);const _=async()=>{if(u)try{const{data:s,error:t}=await b.from("cea_comercios").select("*").eq("qr_code",u).single();if(t)throw t;C(s)}catch(s){console.error("Error fetching commerce:",s),m({title:"Error",description:"Código QR no válido o comercio no encontrado",variant:"destructive"})}finally{E(!1)}},F=async()=>{try{const{data:s,error:t}=await b.from("cea_asociaciones").select("*").eq("estado","activo").order("nombre");if(t)throw t;w(s||[])}catch(s){console.error("Error fetching associations:",s)}},I=()=>{if(!i||!a.monto||parseFloat(a.monto)<=0){m({title:"Campos requeridos",description:"Por favor selecciona una fundación e ingresa un monto válido",variant:"destructive"});return}p("confirmation")},T=async()=>{try{const{data:s,error:t}=await b.from("cea_donaciones").insert([{comercio_id:n==null?void 0:n.id,asociacion_id:i,donante_nombre:a.nombre||"Anónimo",donante_celular:"0000-0000",donante_email:a.email||"[email protected]",monto:parseFloat(a.monto),consentimiento_datos:a.consentimiento}]).select("id").single();if(t)throw t;const q=`CEA-${s.id.substring(0,6).toUpperCase()}-${Math.random().toString(36).substring(2,6).toUpperCase()}`;D(q),p("success"),m({title:"¡Donación registrada!",description:"Tu donación ha sido registrada exitosamente"})}catch(s){console.error("Error creating donation:",s),m({title:"Error",description:"No se pudo registrar la donación",variant:"destructive"})}};return A?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-teal-50 flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Cargando..."})]})}):n?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-teal-50",children:[e.jsx("div",{className:"bg-white shadow-sm border-b",children:e.jsx("div",{className:"max-w-md mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[o!=="selection"&&o!=="success"&&e.jsxs(d,{variant:"ghost",size:"sm",onClick:()=>p("selection"),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Atrás"]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx(z,{className:"w-6 h-6 text-red-500 mr-2"}),e.jsx("span",{className:"font-bold text-lg",children:"C.E.A"})]}),e.jsx("div",{className:"w-16"})]})})}),e.jsxs("div",{className:"max-w-md mx-auto px-4 py-6",children:[o==="selection"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(c,{className:"bg-orange-100 border-orange-200",children:e.jsxs(l,{className:"p-4",children:[e.jsx("div",{className:"text-center mb-4",children:e.jsx("div",{className:"bg-orange-400 text-white px-4 py-2 rounded-lg inline-block font-semibold",children:n.nombre})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"¡Tu compra genera un impacto!"}),e.jsxs("p",{className:"text-gray-700",children:["Gracias a ti, ",e.jsx("span",{className:"font-semibold",children:n.nombre})," donará un porcentaje de tu compra a una causa social."," ",e.jsx("span",{className:"font-semibold",children:"Esto no tiene costo adicional para ti."})]})]})]})}),e.jsxs(c,{children:[e.jsx(v,{children:e.jsx(y,{className:"text-center",children:"Por favor, elige a qué fundación destinar la ayuda:"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsx("div",{className:"space-y-3",children:f.map(s=>e.jsx("div",{className:`p-4 border-2 rounded-lg cursor-pointer transition-all ${i===s.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,onClick:()=>S(s.id),children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"w-12 h-12 bg-blue-500 rounded-full flex items-center justify-center text-white font-bold text-lg",children:s.nombre.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-gray-900",children:s.nombre}),e.jsx("p",{className:"text-sm text-gray-600 capitalize mb-1",children:s.tipo_asociacion.replace("_"," ")}),s.descripcion&&e.jsx("p",{className:"text-sm text-gray-500",children:s.descripcion})]})]})},s.id))}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(h,{htmlFor:"monto",className:"text-base font-semibold",children:"Monto sugerido (₡)"}),e.jsx(g,{id:"monto",type:"number",value:a.monto,onChange:s=>x({...a,monto:s.target.value}),placeholder:"187.50",min:"1",className:"mt-2 text-lg"})]}),e.jsx(d,{onClick:I,disabled:!i||!a.monto,className:"w-full bg-green-600 hover:bg-green-700 text-lg py-3",children:"Continuar"})]})]})]}),o==="confirmation"&&e.jsxs(c,{children:[e.jsxs(v,{className:"text-center",children:[e.jsx(y,{className:"text-2xl text-green-600",children:"¡Gran elección!"}),e.jsx(B,{className:"text-lg",children:"Confirma la donación de:"}),e.jsxs("div",{className:"text-3xl font-bold text-green-600",children:["₡",parseFloat(a.monto).toLocaleStr
1ing()]}),e.jsxs("p",{className:"text-gray-600",children:["a la fundación ",e.jsx("span",{className:"font-semibold",children:(N=f.find(s=>s.id===i))==null?void 0:N.nombre}),", aportados por ",e.jsx("span",{className:"font-semibold",children:n.nombre}),"."]})]}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg text-center",children:[e.jsx("h4",{className:"font-semibold text-blue-900 mb-2",children:"¡Ayúdanos a mantener el contacto!"}),e.jsx("p",{className:"text-sm text-blue-800 mb-3",children:"(Opcional)"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"nombre",children:"Nombre"}),e.jsx(g,{id:"nombre",value:a.nombre,onChange:s=>x({...a,nombre:s.target.value}),placeholder:"Tu nombre"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"email",children:"Correo Electrónico"}),e.jsx(g,{id:"email",type:"email",value:a.email,onChange:s=>x({...a,email:s.target.value}),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"flex items-start space-x-2 pt-2",children:[e.jsx(Q,{id:"consentimiento",checked:a.consentimiento,onCheckedChange:s=>x({...a,consentimiento:s})}),e.jsx(h,{htmlFor:"consentimiento",className:"text-sm leading-5",children:"Acepto la recolección de mis datos para recibir comunicaciones sobre el impacto y futuras encuestas."})]})]})]}),e.jsx(d,{onClick:T,className:"w-full bg-green-600 hover:bg-green-700 text-lg py-3",children:"Confirmar Donación"})]})]}),o==="success"&&e.jsx(c,{children:e.jsxs(l,{className:"pt-6 text-center space-y-6",children:[e.jsx("div",{className:"w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto",children:e.jsx(H,{className:"w-12 h-12 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"¡Muchísimas gracias, er!"}),e.jsx("p",{className:"text-gray-600",children:"Tu elección ha sido registrada con éxito. Cada pequeña acción suma para crear un gran cambio."})]}),e.jsxs("div",{className:"bg-gray-50 border-2 border-dashed border-gray-300 p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"ID de tu Donación:"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:k})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Puedes usar este ID para verificar el registro de tu donación en el portal de transparencia de FUNSATE."}),e.jsx(d,{onClick:()=>j("/"),variant:"outline",className:"w-full",children:"Finalizar"})]})})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-teal-50 flex items-center justify-center px-4",children:e.jsx(c,{className:"w-full max-w-md",children:e.jsxs(l,{className:"pt-6 text-center",children:[e.jsx("div",{className:"text-red-500 mb-4",children:e.jsx(R,{className:"w-16 h-16 mx-auto"})}),e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Código QR No Válido"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"El código QR escaneado no corresponde a ningún comercio registrado."}),e.jsx(d,{onClick:()=>j("/"),className:"w-full",children:"Volver al Inicio"})]})})})};export{W 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.