'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import Link from 'next/link' import { ArrowLeft } from 'lucide-react' export default function NewClientPage() { const router = useRouter() const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [form, setForm] = useState({ name: '', semaphoreKey: '', senderName: 'NFC-HUB', }) async function handleSubmit(e: React.FormEvent) { e.preventDefault() setLoading(true) setError('') const res = await fetch('/api/clients', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(form), }) if (res.ok) { router.push('/dashboard/clients') } else { const data = await res.json() setError(data.error || 'Failed to create client') setLoading(false) } } return (
Register a new school or organization