use askama::Template;
use interim_pgtypes::pg_role::{PgRole, RoleTree};

#[derive(Clone, Debug, Template)]
#[template(path = "role_tree.html")]
pub struct RenderableRoleTree {
    role: PgRole,
    branches: Vec<RenderableRoleTree>,
    inherit: bool,
}

impl From<RoleTree> for RenderableRoleTree {
    fn from(value: RoleTree) -> Self {
        Self {
            role: value.role,
            branches: value.branches.into_iter().map(Self::from).collect(),
            inherit: value.inherit,
        }
    }
}
