'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { UserMenu } from '@/components/UserMenu'; import { authFetch } from '@/lib/authFetch'; const COVER_COLORS = [ '#f59e0b', '#ef4444', '#8b5cf6', '#3b82f6', '#10b981', '#ec4899', '#f97316', '#6366f1', ]; export default function NewNotebookPage() { const router = useRouter(); const [title, setTitle] = useState(''); const [description, setDescription] = useState(''); const [coverColor, setCoverColor] = useState('#f59e0b'); const [saving, setSaving] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!title.trim() || saving) return; setSaving(true); try { const res = await authFetch('/api/notebooks', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title, description, coverColor }), }); const notebook = await res.json(); if (res.ok) { router.push(`/notebooks/${notebook.id}`); } } catch (error) { console.error('Failed to create notebook:', error); } finally { setSaving(false); } }; return (

Create Notebook

setTitle(e.target.value)} placeholder="My Research Notes" className="w-full px-4 py-3 bg-slate-800/50 border border-slate-700 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:border-amber-500/50" autoFocus />