forked from admin/zeropost-tool
feat: P6 Inbox UI — InboxTab + API routes
ChannelView: вкладка 'Inbox' рядом с 'Аналитика' InboxTab.js: - Webhook setup кнопка (если не настроен) - Табы: Новые / Все / Отвечено / Игнорировано - Карточки сообщений с иконкой типа (question/praise/complaint/spam) - AI-предложенный ответ с кнопкой 'Использовать →' - Форма ответа прямо в карточке - Кнопки: Ответить / Игнорировать / Спам API routes: /api/inbox/[channelId], /reply, /status, /setup-webhook
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { requireUser } from '@/lib/session';
|
||||
|
||||
const ENGINE_URL = process.env.ENGINE_URL || 'http://localhost:3030';
|
||||
const ENGINE_SECRET = process.env.ENGINE_SECRET || '';
|
||||
|
||||
async function enginePost(path, userId, body) {
|
||||
const res = await fetch(`${ENGINE_URL}${path}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-internal-secret': ENGINE_SECRET,
|
||||
'x-user-id': String(userId),
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function POST(req, { params }) {
|
||||
const user = await requireUser();
|
||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const data = await enginePost(`/api/inbox/${params.id}/reply`, user.id, body);
|
||||
return NextResponse.json(data);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { requireUser } from '@/lib/session';
|
||||
|
||||
const ENGINE_URL = process.env.ENGINE_URL || 'http://localhost:3030';
|
||||
const ENGINE_SECRET = process.env.ENGINE_SECRET || '';
|
||||
|
||||
export async function POST(req, { params }) {
|
||||
const user = await requireUser();
|
||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const res = await fetch(`${ENGINE_URL}/api/inbox/${params.id}/status`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-internal-secret': ENGINE_SECRET,
|
||||
'x-user-id': String(user.id),
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
Reference in New Issue
Block a user