Form CSS style + dev panel (WIP)

This commit is contained in:
Greg Burri 2025-04-15 11:34:18 +02:00
parent 9daa852add
commit f2e0aa3b43
18 changed files with 154 additions and 34 deletions

View file

@ -7,7 +7,7 @@ use axum::{
response::{Html, IntoResponse, Response},
};
use crate::{Context, Result, data::db, html_templates::*, ron_utils};
use crate::{Context, Result, consts, data::db, html_templates::*, ron_utils};
pub mod fragments;
pub mod recipe;
@ -66,15 +66,31 @@ pub async fn home_page(
pub async fn dev_panel(
State(connection): State<db::Connection>,
Extension(context): Extension<Context>,
) -> Result<impl IntoResponse> {
Ok(Html(
HomeTemplate {
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
.await?,
context,
}
.render()?,
))
) -> Result<Response> {
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
Ok(Html(
DevPanelTemplate {
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
.await?,
context,
}
.render()?,
)
.into_response())
} else {
Ok((
StatusCode::UNAUTHORIZED,
Html(
MessageTemplate::new_with_user(
consts::NOT_AUTHORIZED_MESSAGE,
context.tr,
context.user,
)
.render()?,
),
)
.into_response())
}
}
///// 404 /////