This commit is contained in:
2025-08-07 10:35:30 +02:00
parent ebc66e3222
commit 2b05053b47
7 changed files with 38 additions and 16 deletions

View File

@@ -1,14 +1,14 @@
use crate::{language::language, page::Page, Backend, NameUpdateError};
use crate::{Backend, NameUpdateError, language::language, page::Page};
use axum::{
Form, Router,
extract::{Path, State},
http::HeaderMap,
response::{IntoResponse, Redirect, Response},
routing::{get, post},
Form, Router,
};
use axum_extra::extract::CookieJar;
use axum_messages::Messages;
use maud::{html, Markup, PreEscaped};
use maud::{Markup, PreEscaped, html};
use serde::Deserialize;
use std::sync::Arc;
use uuid::Uuid;
@@ -110,7 +110,12 @@ async fn game(
if let Ok(number) = backend.client_found_camera(&client, &camera).await {
messages.info(format!("found-cam|{}|{number}", camera.name));
} else {
messages.info(&format!("err|{}|{}|{}", t!("error_already_found_title"), t!("error_already_found_body"), t!("error_already_found_footer")));
messages.info(&format!(
"err|{}|{}|{}",
t!("error_already_found_title"),
t!("error_already_found_body"),
t!("error_already_found_footer")
));
}
Ok(Redirect::to("/game"))
@@ -138,9 +143,26 @@ async fn set_name(
match backend.set_client_name(&client, &form.name).await {
Ok(()) => messages.info("set-name-succ"),
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_short_title"), t!("error_name_too_short_body", expected = expected), t!("received_characters"), actual)),
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_long_title"), t!("error_name_too_long_body", expected = expected), t!("received_characters"), actual)),
Err(NameUpdateError::ContainsBadWord) => messages.info(format!("err|{}|{}|{}", t!("error_bad_word_title"), t!("error_bad_word_body"), t!("error_bad_word_footer"))),
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!(
"err|{}|{}|{}: {}",
t!("error_name_too_short_title"),
t!("error_name_too_short_body", expected = expected),
t!("received_characters"),
actual
)),
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!(
"err|{}|{}|{}: {}",
t!("error_name_too_long_title"),
t!("error_name_too_long_body", expected = expected),
t!("received_characters"),
actual
)),
Err(NameUpdateError::ContainsBadWord) => messages.info(format!(
"err|{}|{}|{}",
t!("error_bad_word_title"),
t!("error_bad_word_body"),
t!("error_bad_word_footer")
)),
};
// Redirect back to the game page