"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; export default function RegisterPage() { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); async function onSubmit(e) { e.preventDefault(); setError(""); setLoading(true); try { const r = await fetch("/api/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name, email, password }), }); const data = await r.json(); if (!r.ok) { setError(data.error || "Error al registrarse"); return; } router.push("/"); router.refresh(); } catch { setError("Error de conexión"); } finally { setLoading(false); } } return (
Unite a Nova Store en segundos.
¿Ya tenés cuenta? Iniciá sesión