Files
rm-ventas/frontend/src/app/contacto/page.tsx
T
Nurfog 235f15e1e7 fix: audit 89 bugs - critical fixes
CRITICAL:
- JwtMiddleware orden (antes de UseAuthentication)
- JWT Secret en appsettings.json (no vacio)
- Transbank MySQL connection string (User=root + placeholder)
- package-lock generado + Dockerfile usa npm install
- Tests E2E: selectores corregidos con name attributes
- Tests: rut invalido reemplazado, casos sin auth
- Contacto page: apunta a services-externos (no backend)
- .env.example: credenciales reales -> placeholders

HIGH:
- extra_hosts agregado a services-externos en compose
- Dockerfile frontend: npm ci -> npm install
2026-07-08 11:30:16 -04:00

50 lines
1.5 KiB
TypeScript

'use client';
import { useState, FormEvent } from 'react';
const SERVICES_URL = process.env.NEXT_PUBLIC_SERVICES_URL || 'http://localhost:5001/api';
export default function ContactoPage() {
const [mail, setMail] = useState('');
const [mensaje, setMensaje] = useState('');
const [enviando, setEnviando] = useState(false);
const handleSubmit = async (e: FormEvent) => {
e.preventDefault();
setEnviando(true);
try {
await fetch(`${SERVICES_URL}/email/send`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ to: mail, subject: 'Contacto desde SAM', body: mensaje }),
});
alert('Correo enviado');
setMail('');
setMensaje('');
} catch {
alert('Error al enviar');
} finally {
setEnviando(false);
}
};
return (
<div>
<h3 className="mb-3">Contacto</h3>
<div className="card shadow p-4">
<form onSubmit={handleSubmit}>
<div className="mb-3">
<label className="form-label">Correo</label>
<input type="email" className="form-control" value={mail} onChange={e => setMail(e.target.value)} required />
</div>
<div className="mb-3">
<label className="form-label">Mensaje</label>
<textarea className="form-control" rows={4} value={mensaje} onChange={e => setMensaje(e.target.value)} required />
</div>
<button type="submit" className="btn btn-primary">Enviar</button>
</form>
</div>
</div>
);
}