129991cfb7
FASE 3 - Frontend (22 paginas): - Leads (listado, detalle, nuevo), Cotizaciones, Arqueo - Cursos, Alumnos, Empresas (listado, detalle, ventas) - Reportes (ventas, ventas-empresas, reimpresion) - Autorizador, Contacto FASE 4 - Contenedores: - docker-compose.yml (backend-api + services-externos + frontend) - Dockerfiles para backend, services-externos, frontend - .env.example con secretos FASE 5 - Pruebas E2E: - Playwright config + 3 spec files (login, leads, dashboard) - 7 escenarios: login, error, sidebar, crear lead, dashboard cards, timeout, reportes
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
'use client';
|
|
|
|
import { useState, FormEvent } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { api } from '@/services/api';
|
|
import toast from 'react-hot-toast';
|
|
|
|
export default function NuevoLeadPage() {
|
|
const router = useRouter();
|
|
const [nombre, setNombre] = useState('');
|
|
const [mail, setMail] = useState('');
|
|
const [fono, setFono] = useState('');
|
|
const [producto, setProducto] = useState('');
|
|
|
|
const handleSubmit = async (e: FormEvent) => {
|
|
e.preventDefault();
|
|
try {
|
|
await api.post('/lead', { nombre, mail, telefono: fono, producto, contacto: 1, ejecutivoId: 1 });
|
|
toast.success('Lead creado');
|
|
router.push('/leads');
|
|
} catch {
|
|
toast.error('Error al crear lead');
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="card shadow p-4">
|
|
<h3 className="mb-4">Nuevo Lead</h3>
|
|
<form onSubmit={handleSubmit}>
|
|
<div className="mb-3">
|
|
<label className="form-label">Nombre</label>
|
|
<input className="form-control" value={nombre} onChange={e => setNombre(e.target.value)} required />
|
|
</div>
|
|
<div className="mb-3">
|
|
<label className="form-label">Mail</label>
|
|
<input type="email" className="form-control" value={mail} onChange={e => setMail(e.target.value)} />
|
|
</div>
|
|
<div className="mb-3">
|
|
<label className="form-label">Teléfono</label>
|
|
<input className="form-control" value={fono} onChange={e => setFono(e.target.value)} />
|
|
</div>
|
|
<div className="mb-3">
|
|
<label className="form-label">Producto</label>
|
|
<input className="form-control" value={producto} onChange={e => setProducto(e.target.value)} />
|
|
</div>
|
|
<button type="submit" className="btn btn-primary">Guardar</button>
|
|
<button type="button" className="btn btn-secondary ms-2" onClick={() => router.back()}>Cancelar</button>
|
|
</form>
|
|
</div>
|
|
);
|
|
}
|