use renox::nav::NavLink;
use renox::prelude::*;
use super::roles::ROLES;
pub struct Home;
impl Module for Home {
fn name(&self) -> &'static str {
"home"
}
fn register(&self, app: &mut Registry) {
app.nav(
"app",
NavLink::route("home", "nav.home")
.icon("house")
.group("nav.app")
.order(20)
.when(|_| true),
);
}
fn routes(&self) -> Routes {
Routes::new().get("/", index).name("home")
}
}
async fn index(State(db): State<Db>) -> Result<View> {
let people = User::query().count(&db).await?;
Ok(view(
"home/index.html",
context! { people, roles => ROLES.len() },
))
}