'use client'; import { Button, buttonVariants } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { useAppForm } from '@/components/ui/tanstack-form'; import { cn } from '@/lib/utils'; import { signIn } from 'next-auth/react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useTransition } from 'react'; import { toast } from 'sonner'; import * as z from 'zod'; import { InteractiveGridPattern } from './interactive-grid'; const signUpSchema = z.object({ name: z.string().min(2, 'Name must be at least 2 characters'), email: z.string().email('Enter a valid email address'), password: z.string().min(8, 'Password must be at least 8 characters'), workspaceName: z.string().min(2, 'Workspace name must be at least 2 characters') }); export default function SignUpViewPage() { const router = useRouter(); const [isPending, startTransition] = useTransition(); const form = useAppForm({ defaultValues: { name: '', email: '', password: '', workspaceName: '' }, validators: { onSubmit: signUpSchema }, onSubmit: ({ value }) => { startTransition(async () => { const response = await fetch('/api/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(value) }); if (!response.ok) { const data = (await response.json().catch(() => null)) as { message?: string } | null; toast.error(data?.message ?? 'Unable to create account'); return; } const result = await signIn('credentials', { email: value.email, password: value.password, redirect: false }); if (result?.error) { toast.error('Account created, but sign-in failed. Please sign in manually.'); router.push('/auth/sign-in'); return; } toast.success('Account created successfully'); router.push('/dashboard'); router.refresh(); }); } }); return (
Sign in
Create your first workspace

“Own the auth boundary, own the org model, and keep your feature modules stable.”

Training System

Create an account

We'll create your user, your first workspace, and sign you in.

( Full name field.handleChange(event.target.value)} placeholder='Jane Doe' disabled={isPending} /> )} /> ( Workspace name field.handleChange(event.target.value)} placeholder='Acme Studio' disabled={isPending} /> )} /> ( Email field.handleChange(event.target.value)} placeholder='you@example.com' disabled={isPending} /> )} /> ( Password field.handleChange(event.target.value)} placeholder='Minimum 8 characters' disabled={isPending} /> )} />
); }