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();

    rsx! {
        if show_impressum() {
            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",
                button {
                    onclick: move |_| async move {
                        show_impressum.set(true);
                    },

                H1 { { translate!(i18, "impressum.off") } },
                },
            }
        }
    }
}
