Posts management widget
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::routes::get_users;
|
||||
use crate::routes::{POSTS_PER_PAGE, SUBS_PER_PAGE, get_posts_count, get_posts_page, get_users};
|
||||
use crate::{
|
||||
authentication::AuthenticatedUser,
|
||||
routes::{AppError, get_max_page, get_subs, get_total_subs},
|
||||
@@ -45,10 +45,18 @@ pub async fn admin_dashboard(
|
||||
let count = get_total_subs(&connection_pool)
|
||||
.await
|
||||
.context("Could not fetch total subscribers count from the database.")?;
|
||||
let max_page = get_max_page(count);
|
||||
let max_page = get_max_page(count, SUBS_PER_PAGE);
|
||||
let users = get_users(&connection_pool)
|
||||
.await
|
||||
.context("Could not fetch users")?;
|
||||
let posts = get_posts_page(&connection_pool, 1)
|
||||
.await
|
||||
.context("Could not fetch posts.")?;
|
||||
let posts_current_page = 1;
|
||||
let count = get_posts_count(&connection_pool)
|
||||
.await
|
||||
.context("Could not fetch posts count.")?;
|
||||
let posts_max_page = get_max_page(count, POSTS_PER_PAGE);
|
||||
let template = DashboardTemplate {
|
||||
user,
|
||||
idempotency_key_1,
|
||||
@@ -58,6 +66,9 @@ pub async fn admin_dashboard(
|
||||
current_page,
|
||||
max_page,
|
||||
users,
|
||||
posts,
|
||||
posts_current_page,
|
||||
posts_max_page,
|
||||
};
|
||||
Ok(Html(template.render().unwrap()).into_response())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user