import { useState } from 'react' import type { NextPage } from 'next' import Head from 'next/head' import Link from 'next/link' const ReportPage: NextPage = () => { const [formData, setFormData] = useState({ source_url: '', reporter_email: '', reporter_name: '', description: '', categories: [] as string[] }) const [loading, setLoading] = useState(false) const [success, setSuccess] = useState(false) const categories = [ { id: 'hoax', name: 'Hoax' }, { id: 'hate-speech', name: 'Hate Speech' }, { id: 'violence', name: 'Violence' }, { id: 'racism', name: 'Racism' }, { id: 'conspiracy', name: 'Conspiracy' }, { id: 'propaganda', name: 'Propaganda' } ] const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) try { const response = await fetch('/api/reports', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(formData), }) if (response.ok) { setSuccess(true) setFormData({ source_url: '', reporter_email: '', reporter_name: '', description: '', categories: [] }) } } catch (error) { console.error('Failed to submit report:', error) } finally { setLoading(false) } } const handleCategoryChange = (categoryId: string, checked: boolean) => { if (checked) { setFormData(prev => ({ ...prev, categories: [...prev.categories, categoryId] })) } else { setFormData(prev => ({ ...prev, categories: prev.categories.filter(id => id !== categoryId) })) } } if (success) { return (
Hlásenie odoslané - Infohliadka

Ďakujeme!

Vaše hlásenie bolo úspešne odoslané a bude preverené našimi moderátormi.

← Späť na hlavnú stránku
) } return (
Nahlásiť problematický obsah - Infohliadka

Nahlásiť problematický obsah

setFormData(prev => ({ ...prev, source_url: e.target.value }))} style={{ width: '100%', padding: '8px', border: '1px solid #d1d5db', borderRadius: '4px' }} placeholder="https://example.com" />
setFormData(prev => ({ ...prev, reporter_email: e.target.value }))} style={{ width: '100%', padding: '8px', border: '1px solid #d1d5db', borderRadius: '4px' }} placeholder="vas@email.com" />
setFormData(prev => ({ ...prev, reporter_name: e.target.value }))} style={{ width: '100%', padding: '8px', border: '1px solid #d1d5db', borderRadius: '4px' }} placeholder="Vaše meno" />
{categories.map(category => ( ))}