start work on content moderation table

This commit is contained in:
smanylov
2026-05-25 16:10:11 +07:00
parent f5c99f1e09
commit 9db7f6b08d
5 changed files with 707 additions and 21 deletions
+48
View File
@@ -0,0 +1,48 @@
'use server'
import { getSessionData } from '@/app/actions/session';
import { API_BASE_URL } from '@/app/actions/definitions';
export async function fetchModerationContentList(page?: number, size?: number, sortBy?: string, sortDirection?: 'asc' | 'desc' | string, nameQuery?: string) {
const token = await getSessionData('token');
console.log('fetchModerationContentList');
try {
const response = await fetch(`${API_BASE_URL}/api/admin`, {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 20005,
message_body: {
action: 'files_for_moderation',
/* page: page,
size: size,
sort_by: sortBy || '',
sort_direction: sortDirection || 'asc',
full_name: nameQuery */
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
const parsed = await response.json();
console.log(parsed);
if (parsed.message_code === 0) {
return parsed.message_body;
} else {
return null;
}
} else {
throw new Error(`${response.status}`);
}
} catch (error) {
return null;
}
}