use leptos::prelude::*;

use super::unified::UnifiedSignoutPage;

#[component]
pub fn SignoutClient(
    #[prop(default = rustelo_core_lib::config::get_default_language().to_string())]
    language: String,
) -> impl IntoView {
    let page_content = crate::common::use_page_i18n_dynamic(vec!["signout-"], || vec![]);
    let lang_content = page_content.get_untracked();

    view! {
        <UnifiedSignoutPage _language=language lang_content=lang_content />
    }
}

#[component]
pub fn SignoutSSR(
    #[prop(default = rustelo_core_lib::config::get_default_language().to_string())]
    language: String,
) -> impl IntoView {
    let translator = rustelo_core_lib::i18n::page_translator::SsrTranslator::new(language.clone());
    let patterns: Vec<&str> = vec!["signout-"];
    let lang_content =
        rustelo_core_lib::i18n::helpers::build_page_content_patterns(&translator, &patterns);

    view! {
        <UnifiedSignoutPage _language=language.clone() lang_content=lang_content />
    }
}

#[component]
pub fn SignoutPage(
    #[prop(default = rustelo_core_lib::config::get_default_language().to_string())]
    language: String,
) -> impl IntoView {
    #[cfg(not(target_arch = "wasm32"))]
    {
        view! { <SignoutSSR language=language.clone() /> }
    }

    #[cfg(target_arch = "wasm32")]
    {
        view! { <SignoutClient language=language.clone() /> }
    }
}
