From 8ad9d19569d302754ba2bec36d7d0dee4c131fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=20=28Claude=29?= Date: Wed, 10 Jun 2026 15:10:33 +0300 Subject: [PATCH] fix: goal+language in ChannelEdit, metrics 500 (await params) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ChannelEdit.js: - Добавлены goal (multi-select + кастомные, как в форме создания) - Добавлен language (select: ru/en/uk/kk) - Импортированы Plus, X иконки и GOALS константа app/api/metrics/channel/[channelId]/route.js: app/api/metrics/best-time/[channelId]/route.js: - await params (Next.js 16 требует), иначе 500 --- .../metrics/best-time/[channelId]/route.js | 3 +- app/api/metrics/channel/[channelId]/route.js | 3 +- components/ChannelEdit.js | 58 ++++++++++++++++++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/app/api/metrics/best-time/[channelId]/route.js b/app/api/metrics/best-time/[channelId]/route.js index fcbe71b..a7b2e05 100644 --- a/app/api/metrics/best-time/[channelId]/route.js +++ b/app/api/metrics/best-time/[channelId]/route.js @@ -7,7 +7,8 @@ export async function GET(request, { params }) { if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); const { searchParams } = new URL(request.url); try { - const data = await engine.getBestTime(params.channelId, Object.fromEntries(searchParams)); + const { channelId } = await params; + const data = await engine.getBestTime(channelId, Object.fromEntries(searchParams)); return NextResponse.json(data); } catch (err) { return NextResponse.json({ error: err.message }, { status: err.status || 500 }); diff --git a/app/api/metrics/channel/[channelId]/route.js b/app/api/metrics/channel/[channelId]/route.js index e28322c..7b920cb 100644 --- a/app/api/metrics/channel/[channelId]/route.js +++ b/app/api/metrics/channel/[channelId]/route.js @@ -7,7 +7,8 @@ export async function GET(request, { params }) { if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); const { searchParams } = new URL(request.url); try { - const data = await engine.getChannelMetrics(params.channelId, Object.fromEntries(searchParams)); + const { channelId } = await params; + const data = await engine.getChannelMetrics(channelId, Object.fromEntries(searchParams)); return NextResponse.json(data); } catch (err) { return NextResponse.json({ error: err.message }, { status: err.status || 500 }); diff --git a/components/ChannelEdit.js b/components/ChannelEdit.js index 3a576a1..3bf95fc 100644 --- a/components/ChannelEdit.js +++ b/components/ChannelEdit.js @@ -2,7 +2,15 @@ import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; -import { ArrowLeft, Save, Trash2, Loader2, Image as ImageIcon, Type, Palette } from 'lucide-react'; +import { ArrowLeft, Save, Trash2, Loader2, Image as ImageIcon, Type, Palette, Plus, X } 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: 'Дружелюбный' }, @@ -66,6 +74,11 @@ export default function ChannelEdit({ channel }) { const [name, setName] = useState(channel.name || ''); const [niche, setNiche] = useState(channel.niche || ''); const [audience, setAudience] = useState(channel.audience || ''); + const [goals, setGoals] = useState( + channel.goal ? channel.goal.split(',').map(g => g.trim()).filter(Boolean) : ['educational'] + ); + const [customGoal, setCustomGoal] = useState(''); + const [language, setLanguage] = useState(channel.language || 'ru'); const [tone, setTone] = useState(style.tone || 'friendly'); const [formality, setFormality] = useState(style.formality || 'informal'); const [humor, setHumor] = useState(style.humor || 'moderate'); @@ -92,7 +105,7 @@ export default function ChannelEdit({ channel }) { setError(''); try { const data = { - name, niche, audience, + name, niche, audience, goal: goals.join(','), language, style: { tone, formality, humor, post_length: postLength, @@ -185,6 +198,47 @@ export default function ChannelEdit({ channel }) {