import React, { useState, useCallback } from 'react' import Breadcrumbs from '../../components/forum/Breadcrumbs' import Button from '../../components/ui/Button' import TextInput from '../../components/ui/TextInput' import RichTextEditor from '../../components/forum/RichTextEditor' import TurnstileField from '../../components/security/TurnstileField' import { populateBotFingerprint } from '../../lib/security/botFingerprint' export default function ForumNewThread({ category, csrfToken, errors = {}, oldValues = {}, captcha = {} }) { const [title, setTitle] = useState(oldValues.title ?? '') const [content, setContent] = useState(oldValues.content ?? '') const [captchaToken, setCaptchaToken] = useState('') const [submitting, setSubmitting] = useState(false) const slug = category?.slug const categoryName = category?.name ?? 'Category' const breadcrumbs = [ { label: 'Home', href: '/' }, { label: 'Forum', href: '/forum' }, { label: categoryName, href: slug ? `/forum/${slug}` : '/forum' }, { label: 'New topic' }, ] const handleSubmit = useCallback(async (e) => { e.preventDefault() if (submitting) return setSubmitting(true) // Standard form submission to keep server-side validation + redirect await populateBotFingerprint(e.currentTarget) e.target.submit() }, [submitting]) return (
{/* Header */}

New topic

Create topic in {categoryName}

{/* Form */}
{errors.bot ? (
{Array.isArray(errors.bot) ? errors.bot[0] : errors.bot}
) : null} {errors.captcha ? (
{Array.isArray(errors.captcha) ? errors.captcha[0] : errors.captcha}
) : null} setTitle(e.target.value)} required maxLength={255} placeholder="Thread title…" error={errors.title} /> {/* Rich text editor */}
{captcha.siteKey ? ( ) : null} {/* Submit */}
← Cancel
) }