app: Allow to list recipes

This commit is contained in:
traxys 2023-06-25 14:12:09 +02:00
parent 80e3d7ee86
commit f3788e31a9
3 changed files with 136 additions and 6 deletions

View file

@ -10,13 +10,14 @@ use crate::{
api,
bootstrap::{bs, ConfirmDangerModal, FormModal},
do_add_user_to_household, do_resolve_user, HouseholdInfo, RegaladeGlobalState, Route,
RouteKind,
};
#[derive(PartialEq)]
struct MenuEntry {
icon: &'static str,
label: &'static str,
page: Route,
page: RouteKind,
}
#[derive(Properties, PartialEq)]
@ -298,7 +299,7 @@ fn Sidebar(props: &SidebarProps) -> Html {
)}>
{
for props.entries.iter().map(|e| {
let active = if e.page == props.current {
let active = if Some(e.page) == props.current.kind() {
Some("active")
} else {
None
@ -311,7 +312,7 @@ fn Sidebar(props: &SidebarProps) -> Html {
"text-white",
active,
)}
to={e.page}
to={e.page.redirect_to()}
>
<i class={classes!("fs-4", e.icon)}></i>
<span class={classes!("ms-2", "d-none", "d-sm-inline")}>
@ -433,17 +434,22 @@ pub(crate) fn RegaladeSidebar(props: &RegaladeSidebarProps) -> Html {
MenuEntry {
label: "Home",
icon: "bi-house",
page: Route::Index,
page: RouteKind::Index,
},
MenuEntry {
label: "Recipes",
icon: "bi-book",
page: RouteKind::Recipe,
},
MenuEntry {
label: "Ingredients",
icon: "bi-egg-fill",
page: Route::Ingredients,
page: RouteKind::Ingredients,
},
MenuEntry {
label: "New Recipe",
icon: "bi-clipboard2-plus-fill",
page: Route::NewRecipe,
page: RouteKind::NewRecipe,
},
];