use crate::components::buttons::goto_button::{goto_button, GotoButton};
use crate::components::html::{footer, Footer};
use crate::components::socials::{socials, Socials};
use crate::utils::types::{SharedAppState, URLParams, URLPath};
use crate::{rumtk_web_get_config, rumtk_web_params_map, ComponentResult, RUMWebTemplate, RUMWebTemplateSafe, PARAMS_ID, PARAMS_TARGET, PARAMS_TITLE};
use rumtk_core::strings::RUMString;
#[derive(RUMWebTemplate, Debug, Clone)]
#[template(
source = "
<p class='f16'>
{{company}} © {{copyright}}
</p>
{% if !disable_contact_button %}
{{button|safe}}
{% endif %}
{{socials|safe}}
",
ext = "html"
)]
pub struct FooterContents {
company: RUMString,
copyright: RUMString,
button: GotoButton,
socials: Socials,
disable_contact_button: bool
}
impl RUMWebTemplateSafe for FooterContents {}
#[derive(RUMWebTemplate, Debug, Clone)]
#[template(
source = "
{{footer}}
",
ext = "html"
)]
pub struct AppFooter {
footer: Footer<FooterContents>
}
impl RUMWebTemplateSafe for AppFooter {}
pub fn app_footer<'a>(_path_components: URLPath<'a, 'a>, params: URLParams<'a>, state: SharedAppState) -> ComponentResult<AppFooter> {
let company = rumtk_web_get_config!(state).company.clone();
let copyright = rumtk_web_get_config!(state).copyright.clone();
let disable_contact_button = rumtk_web_get_config!(state).footer_conf.disable_contact_button;
let contact_button_params = rumtk_web_params_map!([
(PARAMS_ID, "contact_button"),
(PARAMS_TITLE, "Contact"),
(PARAMS_TARGET, "./contact")
]);
let contact_button = goto_button(
_path_components,
contact_button_params.get_inner(),
state.clone()
)?;
let socials = socials(_path_components, params, state.clone())?;
let footer_contents = FooterContents {
company,
copyright,
button: contact_button,
socials,
disable_contact_button
};
let app_footer = footer(
footer_contents,
params,
state
)?;
Ok(AppFooter {
footer: app_footer,
})
}