Skip to main content

rumtk_web/components/app/
app_footer.rs

1/*
2 * rumtk attempts to implement HL7 and medical protocols for interoperability in medicine.
3 * This toolkit aims to be reliable, simple, performant, and standards compliant.
4 * Copyright (C) 2025  Luis M. Santos, M.D. <lsantos@medicalmasses.com>
5 * Copyright (C) 2025  Ethan Dixon
6 * Copyright (C) 2025  MedicalMasses L.L.C. <contact@medicalmasses.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 */
21use crate::components::buttons::goto_button::{goto_button, GotoButton};
22use crate::components::html::{footer, Footer};
23use crate::components::socials::{socials, Socials};
24use crate::utils::types::{SharedAppState, URLParams, URLPath};
25use crate::{rumtk_web_get_config, rumtk_web_params_map, ComponentResult, RUMWebTemplate, RUMWebTemplateSafe, PARAMS_ID, PARAMS_TARGET, PARAMS_TITLE};
26use rumtk_core::strings::RUMString;
27
28#[derive(RUMWebTemplate, Debug, Clone)]
29#[template(
30    source = "
31        <p class='f16'>
32            {{company}} &copy; {{copyright}}
33        </p>
34        {% if !disable_contact_button %}
35        {{button|safe}}
36        {% endif %}
37        {{socials|safe}}
38    ",
39    ext = "html"
40)]
41pub struct FooterContents {
42    company: RUMString,
43    copyright: RUMString,
44    button: GotoButton,
45    socials: Socials,
46    disable_contact_button: bool
47}
48
49impl RUMWebTemplateSafe for FooterContents {}
50
51#[derive(RUMWebTemplate, Debug, Clone)]
52#[template(
53    source = "
54        {{footer}}
55    ",
56    ext = "html"
57)]
58pub struct AppFooter {
59    footer: Footer<FooterContents>
60}
61
62impl RUMWebTemplateSafe for AppFooter {}
63
64pub fn app_footer<'a>(_path_components: URLPath<'a, 'a>, params: URLParams<'a>, state: SharedAppState) -> ComponentResult<AppFooter> {
65    let company = rumtk_web_get_config!(state).company.clone();
66    let copyright = rumtk_web_get_config!(state).copyright.clone();
67
68    let disable_contact_button = rumtk_web_get_config!(state).footer_conf.disable_contact_button;
69
70    let contact_button_params = rumtk_web_params_map!([
71        (PARAMS_ID, "contact_button"),
72        (PARAMS_TITLE, "Contact"),
73        (PARAMS_TARGET, "./contact")
74    ]);
75    let contact_button = goto_button(
76        _path_components,
77        contact_button_params.get_inner(),
78        state.clone()
79    )?;
80
81    let socials = socials(_path_components, params, state.clone())?;
82
83    let footer_contents = FooterContents {
84        company,
85        copyright,
86        button: contact_button,
87        socials,
88        disable_contact_button
89    };
90
91    let app_footer = footer(
92        footer_contents,
93        params,
94        state
95    )?;
96
97    Ok(AppFooter {
98        footer: app_footer,
99    })
100}