Fixed multi component i18n strings and added serverside impressum
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -1,48 +1,60 @@
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_sdk::{i18n::use_i18, translate};
|
||||
use tracing::info;
|
||||
|
||||
use crate::components::{H1, HR, P};
|
||||
|
||||
#[component]
|
||||
pub fn Impressum() -> Element {
|
||||
let mut show_impressum = use_signal(|| false);
|
||||
let i18 = use_i18();
|
||||
let mut impressum = use_signal(Vec::<String>::new);
|
||||
let mut contact = use_signal(Vec::<String>::new);
|
||||
|
||||
rsx! {
|
||||
if show_impressum() {
|
||||
div {
|
||||
div {
|
||||
div {
|
||||
class: "flex flex-col items-center",
|
||||
button {
|
||||
onclick: move |_| {
|
||||
info!("Hide impressum.");
|
||||
},
|
||||
H1 { { translate!(i18, "impressum.on") } },
|
||||
},
|
||||
P { "Tuan-Dat Tran" },
|
||||
P { "c/o AutorenServices.de" },
|
||||
P { "Birkenallee 24" },
|
||||
P { "36037 Fulda" },
|
||||
},
|
||||
HR {}
|
||||
div {
|
||||
class: "flex flex-col items-center",
|
||||
P { "tuan-dat.tran@tudattr.dev" },
|
||||
P { "+49 176 83468388" },
|
||||
}
|
||||
}
|
||||
} else {
|
||||
div {
|
||||
class: "flex flex-col items-center p-3",
|
||||
class: "flex flex-col items-center",
|
||||
button {
|
||||
onclick: move |_| async move {
|
||||
show_impressum.set(true);
|
||||
if let Ok(data) = get_impressum().await {
|
||||
impressum.set(data.clone());
|
||||
}
|
||||
if let Ok(data) = get_contact().await {
|
||||
contact.set(data.clone());
|
||||
}
|
||||
},
|
||||
|
||||
H1 { { translate!(i18, "impressum.off") } },
|
||||
H1 { { translate!(i18, "impressum.on") } },
|
||||
},
|
||||
},
|
||||
div {
|
||||
class: "flex flex-col items-center",
|
||||
for line in impressum() {
|
||||
P { {line} }
|
||||
}
|
||||
}
|
||||
if !impressum.read().is_empty() { HR{} },
|
||||
div {
|
||||
class: "flex flex-col items-center",
|
||||
for line in contact() {
|
||||
P { {line} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[server(GetServerData)]
|
||||
async fn get_impressum() -> Result<Vec<String>, ServerFnError> {
|
||||
Ok(vec![
|
||||
"Tuan-Dat Tran".to_string(),
|
||||
"c/o AutorenServices.de".to_string(),
|
||||
"Birkenallee 24".to_string(),
|
||||
"36037 Fulda".to_string(),
|
||||
])
|
||||
}
|
||||
|
||||
async fn get_contact() -> Result<Vec<String>, ServerFnError> {
|
||||
Ok(vec![
|
||||
"tuan-dat.tran@tudattr.dev".to_string(),
|
||||
"+49 176 83468388".to_string(),
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user