shouts-admin-fix5

This commit is contained in:
Untone 2025-06-28 14:57:07 +03:00
parent 8f93d77eef
commit 3ccd8ce1d0

View File

@ -14,7 +14,8 @@ import 'prismjs/themes/prism-tomorrow.css'
// Определяем GraphQL запрос
const ADMIN_GET_SHOUTS_QUERY = `
query AdminGetShouts($limit: Int, $offset: Int, $status: String) {
admin_get_shouts(limit: $limit, offset: $offset, status: $status) {
adminGetShouts(limit: $limit, offset: $offset, status: $status) {
shouts {
id
title
slug
@ -61,7 +62,11 @@ const ADMIN_GET_SHOUTS_QUERY = `
version_of
draft
}
admin_get_shouts_count
total
page
perPage
totalPages
}
}
`
@ -204,8 +209,13 @@ interface Shout {
* Интерфейс для ответа API с публикациями
*/
interface AdminGetShoutsData {
admin_get_shouts: any[]
admin_get_shouts_count: number
adminGetShouts: {
shouts: any[]
total: number
page: number
perPage: number
totalPages: number
}
}
/**
@ -414,13 +424,13 @@ const AdminPage: Component<AdminPageProps> = (props) => {
}
)
if (result?.admin_get_shouts) {
setShouts(result.admin_get_shouts)
if (result?.adminGetShouts) {
setShouts(result.adminGetShouts.shouts)
// Обновляем пагинацию с учетом общего количества
setShoutsPagination({
...pagination,
total: result.admin_get_shouts_count || 0,
totalPages: Math.ceil((result.admin_get_shouts_count || 0) / pagination.limit)
total: result.adminGetShouts.total,
totalPages: result.adminGetShouts.totalPages
})
}
} catch (error) {