use crate::app::config::Configuration;
use crate::template_helpers::TemplateOverrides;
use rocket::Build;
use rocket::Rocket;

pub fn init(config: &Configuration) -> super::Result<TemplateOverrides> {
    let localized_template_list = TemplateOverrides::load(
        config.template_dir.as_path(),
        crate::app::config::DEFAULT_LOCALIZED_TEMPLATE_DIR_NAME,
    );

    println!("{:?}", localized_template_list);

    localized_template_list.map(Some)
}

pub fn register(
    rocket: Rocket<Build>,
    _config: &Configuration,
    state: TemplateOverrides,
) -> Rocket<Build> {
    rocket.manage(state)
}
