Shopping list items can now be checked/unchecked
This commit is contained in:
parent
3a3288bc93
commit
a1fd63ad08
14 changed files with 940 additions and 790 deletions
41
backend/src/services/ron/mod.rs
Normal file
41
backend/src/services/ron/mod.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use axum::{
|
||||
debug_handler,
|
||||
extract::{Extension, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{IntoResponse, Result},
|
||||
};
|
||||
use axum_extra::extract::cookie::{Cookie, CookieJar};
|
||||
// use tracing::{event, Level};
|
||||
|
||||
use crate::{consts, data::db, model, ron_extractor::ExtractRon, ron_utils::ron_error};
|
||||
|
||||
pub mod calendar;
|
||||
pub mod recipe;
|
||||
mod rights;
|
||||
pub mod shopping_list;
|
||||
|
||||
const NOT_AUTHORIZED_MESSAGE: &str = "Action not authorized";
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn set_lang(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
headers: HeaderMap,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::SetLang>,
|
||||
) -> Result<(CookieJar, StatusCode)> {
|
||||
let mut jar = CookieJar::from_headers(&headers);
|
||||
if let Some(user) = user {
|
||||
connection.set_user_lang(user.id, &ron.lang).await?;
|
||||
} else {
|
||||
let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)).path("/");
|
||||
jar = jar.add(cookie);
|
||||
}
|
||||
Ok((jar, StatusCode::OK))
|
||||
}
|
||||
|
||||
/*** 404 ***/
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn not_found(Extension(_user): Extension<Option<model::User>>) -> impl IntoResponse {
|
||||
ron_error(StatusCode::NOT_FOUND, "Not found")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue