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