'use client' import { useRouter } from 'next/navigation' import React, { useState } from 'react' import { Label } from '../ui/label' import { Input } from '../ui/input' import { Button } from '../ui/button' interface Props { invite: { token: string email: string role: 'COUPLE' | 'PLANNER' | 'GUEST' } } export default function SignUpForm({ invite }: Props) { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const router = useRouter() async function handleSubmit(e: React.FormEvent) { e.preventDefault() const res = await fetch('/api/signup/from-invite', { method: 'POST', body: JSON.stringify({ token: invite.token, username, password }), headers: { 'Content-Type': 'application/json' }, }) if (res.ok) { router.push('/login') } else { const { message } = await res.json() setError(message || 'Signup failed') } } return (
) }