forked from admin/zeropost-tool
fix: restructure inbox API routes — channel/ and message/ namespaces
Next.js не позволяет [channelId] и [id] на одном уровне. Решение: /api/inbox/channel/[channelId]/* и /api/inbox/message/[id]/* InboxTab: все fetch пути обновлены
This commit is contained in:
@@ -49,7 +49,7 @@ export default function InboxTab({ channel }) {
|
||||
const load = useCallback(async (t = tab) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch(`/api/inbox/${channel.id}?status=${t}&limit=40`).then(r => r.json());
|
||||
const res = await fetch(`/api/inbox/channel/${channel.id}?status=${t}&limit=40`).then(r => r.json());
|
||||
setMessages(res.messages || []);
|
||||
setTotal(res.total || 0);
|
||||
} catch {}
|
||||
@@ -61,7 +61,7 @@ export default function InboxTab({ channel }) {
|
||||
async function setupWebhook() {
|
||||
setSetuppping(true);
|
||||
try {
|
||||
const res = await fetch(`/api/inbox/${channel.id}/setup-webhook`, { method: 'POST' }).then(r => r.json());
|
||||
const res = await fetch(`/api/inbox/channel/${channel.id}/setup-webhook`, { method: 'POST' }).then(r => r.json());
|
||||
if (res.ok) { setWebhookOk(true); load(tab); }
|
||||
else alert(res.error || 'Ошибка');
|
||||
} catch { alert('Ошибка соединения'); }
|
||||
@@ -72,7 +72,7 @@ export default function InboxTab({ channel }) {
|
||||
if (!replyText.trim()) return;
|
||||
setSending(true);
|
||||
try {
|
||||
const res = await fetch(`/api/inbox/${msg.id}/reply`, {
|
||||
const res = await fetch(`/api/inbox/message/${msg.id}/reply`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ text: replyText }),
|
||||
@@ -87,7 +87,7 @@ export default function InboxTab({ channel }) {
|
||||
}
|
||||
|
||||
async function setStatus(msgId, status) {
|
||||
await fetch(`/api/inbox/${msgId}/status`, {
|
||||
await fetch(`/api/inbox/message/${msgId}/status`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ status }),
|
||||
|
||||
Reference in New Issue
Block a user