"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Image from "next/image"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export default function RegisterPage() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [invitationCode, setInvitationCode] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); async function handleRegister(e: React.FormEvent) { e.preventDefault(); setError(""); setLoading(true); const res = await fetch("https://internal-api.inboxi.ng/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password, invitationCode }), }); const data = await res.json(); if (res.ok) { console.log("Registered successfully:", data); router.push("/login"); } else { setError(data.error || "Registration failed"); } setLoading(false); } return (
Sign up to start selling
{error}
}Already have an account?{" "} Sign in