use rinja_axum::Template; use crate::{ data::model, translation::{Sentence, Tr}, }; pub struct Recipes { pub published: Vec<(i64, String)>, pub unpublished: Vec<(i64, String)>, pub current_id: Option, } impl Recipes { pub fn is_current(&self, id: &&i64) -> bool { self.current_id == Some(**id) } } #[derive(Template)] #[template(path = "home.html")] pub struct HomeTemplate { pub user: Option, pub tr: Tr, pub recipes: Recipes, } #[derive(Template)] #[template(path = "message.html")] pub struct MessageTemplate { pub user: Option, pub tr: Tr, pub message: String, pub as_code: bool, // Display the message in
 markup.
}

impl MessageTemplate {
    pub fn new(message: String, tr: Tr) -> MessageTemplate {
        MessageTemplate {
            user: None,
            tr,
            message,
            as_code: false,
        }
    }

    pub fn new_with_user(message: String, tr: Tr, user: Option) -> MessageTemplate {
        MessageTemplate {
            user,
            tr,
            message,
            as_code: false,
        }
    }
}

#[derive(Template)]
#[template(path = "sign_up_form.html")]
pub struct SignUpFormTemplate {
    pub user: Option,
    pub tr: Tr,

    pub email: String,
    pub message: String,
    pub message_email: String,
    pub message_password: String,
}

#[derive(Template)]
#[template(path = "sign_in_form.html")]
pub struct SignInFormTemplate {
    pub user: Option,
    pub tr: Tr,

    pub email: String,
    pub message: String,
}

#[derive(Template)]
#[template(path = "ask_reset_password.html")]
pub struct AskResetPasswordTemplate {
    pub user: Option,
    pub tr: Tr,

    pub email: String,
    pub message: String,
    pub message_email: String,
}

#[derive(Template)]
#[template(path = "reset_password.html")]
pub struct ResetPasswordTemplate {
    pub user: Option,
    pub tr: Tr,

    pub reset_token: String,
    pub message: String,
    pub message_password: String,
}

#[derive(Template)]
#[template(path = "profile.html")]
pub struct ProfileTemplate {
    pub user: Option,
    pub tr: Tr,

    pub username: String,
    pub email: String,
    pub message: String,
    pub message_email: String,
    pub message_password: String,
}

#[derive(Template)]
#[template(path = "recipe_view.html")]
pub struct RecipeViewTemplate {
    pub user: Option,
    pub tr: Tr,

    pub recipes: Recipes,

    pub recipe: model::Recipe,
}

#[derive(Template)]
#[template(path = "recipe_edit.html")]
pub struct RecipeEditTemplate {
    pub user: Option,
    pub tr: Tr,

    pub recipes: Recipes,

    pub recipe: model::Recipe,
}

#[derive(Template)]
#[template(path = "recipes_list_fragment.html")]
pub struct RecipesListFragmentTemplate {
    pub tr: Tr,

    pub recipes: Recipes,
}