'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { ArrowLeft, X, Plus, Sparkles } from 'lucide-react'; const GOALS = [ { v: 'educational', label: 'Обучение', desc: 'Объясняем, разбираем' }, { v: 'news', label: 'Новости', desc: 'Что произошло' }, { v: 'entertainment', label: 'Развлечение', desc: 'Лёгкий контент, мемы' }, { v: 'expert', label: 'Экспертный', desc: 'Глубокий анализ, инсайты' }, { v: 'sales', label: 'Продажи', desc: 'Подвести к покупке' }, ]; const TONES = [ { v: 'friendly', label: 'Дружелюбный' }, { v: 'serious', label: 'Серьёзный' }, { v: 'ironic', label: 'Ироничный' }, { v: 'provocative', label: 'Провокационный' }, { v: 'academic', label: 'Академичный' }, ]; const LENGTHS = [ { v: 'short', label: 'Короткий', desc: 'до 300 знаков' }, { v: 'medium', label: 'Средний', desc: '300-800' }, { v: 'long', label: 'Длинный', desc: '800-2000' }, ]; const EMOJI = [ { v: 'none', label: 'Без эмодзи' }, { v: 'moderate', label: 'Умеренно' }, { v: 'active', label: 'Активно' }, ]; const HUMOR = [ { v: 'none', label: 'Без юмора' }, { v: 'dry', label: 'Сухой/ирония' }, { v: 'moderate', label: 'Умеренный' }, { v: 'playful', label: 'Игривый' }, ]; export default function NewChannelPage() { const router = useRouter(); const [step, setStep] = useState(1); const [busy, setBusy] = useState(false); const [error, setError] = useState(''); // Шаг 1 — база const [name, setName] = useState(''); const [niche, setNiche] = useState(''); const [audience, setAudience] = useState(''); const [goals, setGoals] = useState(['educational']); // multi-select, отправляем как CSV const [customGoal, setCustomGoal] = useState(''); // поле для своей цели const [language, setLanguage] = useState('ru'); // Шаг 2 — стиль const [tone, setTone] = useState('friendly'); const [formality, setFormality] = useState('informal'); const [humor, setHumor] = useState('moderate'); const [postLength, setPostLength] = useState('medium'); const [emojiLevel, setEmojiLevel] = useState('moderate'); const [hashtagsMode, setHashtagsMode] = useState('end'); // Шаг 3 — примеры и табу const [examplePosts, setExamplePosts] = useState(['']); const [bannedWords, setBannedWords] = useState(''); const [bannedTopics, setBannedTopics] = useState(''); async function submit() { if (!name) { setError('Название канала обязательно'); setStep(1); return; } setBusy(true); setError(''); const data = { name, niche, audience, goal: goals.join(','), language, region: 'ru', style: { tone, formality, humor, post_length: postLength, emoji_level: emojiLevel, hashtags_mode: hashtagsMode, example_posts: examplePosts.map(s => s.trim()).filter(Boolean), banned_words: bannedWords.split(',').map(s => s.trim()).filter(Boolean), banned_topics: bannedTopics.split(',').map(s => s.trim()).filter(Boolean), }, }; const res = await fetch('/api/channels', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); const json = await res.json(); setBusy(false); if (!res.ok) { if (json.code === 'CHANNEL_LIMIT_REACHED') { setError(`${json.error} → `); // Перенаправим на страницу тарифов через 2 сек setTimeout(() => router.push('/plans'), 2000); } else { setError(json.error || 'Ошибка'); } return; } router.push(`/channels/${json.id}`); } return (
Назад

Новый канал

Чем точнее опишешь канал, тем лучше ИИ будет писать в его стиле

{/* Stepper */}
{[1, 2, 3].map(s => (
{s}. {s === 1 ? 'О канале' : s === 2 ? 'Стиль' : 'Примеры и табу'}
))}
{error && (
{error}
)} {step === 1 && (
setName(e.target.value)} placeholder="Например: PostCast AI" />