mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Display current plan date at the top
This commit is contained in:
parent
a320351041
commit
0ba5f18b22
@ -18,9 +18,13 @@ use crate::{app_state::StateHandler, components::recipe_list::*};
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn CookPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
pub fn CookPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
||||||
|
let current_plan = sh.get_selector(cx, |state| {
|
||||||
|
state.get().selected_plan_date
|
||||||
|
});
|
||||||
view! {cx,
|
view! {cx,
|
||||||
PlanningPage(
|
PlanningPage(
|
||||||
selected=Some("Cook".to_owned()),
|
selected=Some("Cook".to_owned()),
|
||||||
|
plan_date = current_plan,
|
||||||
) { RecipeList(sh) }
|
) { RecipeList(sh) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,13 @@ use crate::{app_state::StateHandler, components::shopping_list::*};
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn InventoryPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
pub fn InventoryPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
||||||
|
let current_plan = sh.get_selector(cx, |state| {
|
||||||
|
state.get().selected_plan_date
|
||||||
|
});
|
||||||
view! {cx,
|
view! {cx,
|
||||||
PlanningPage(
|
PlanningPage(
|
||||||
selected=Some("Inventory".to_owned()),
|
selected=Some("Inventory".to_owned()),
|
||||||
|
plan_date = current_plan,
|
||||||
) { ShoppingList(sh) }
|
) { ShoppingList(sh) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
use crate::components::tabs::*;
|
use crate::components::tabs::*;
|
||||||
|
use chrono::NaiveDate;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
pub mod cook;
|
pub mod cook;
|
||||||
@ -25,14 +26,19 @@ pub use plan::*;
|
|||||||
pub use select::*;
|
pub use select::*;
|
||||||
|
|
||||||
#[derive(Props)]
|
#[derive(Props)]
|
||||||
pub struct PageState<'a, G: Html> {
|
pub struct PageState<'ctx, G: Html> {
|
||||||
pub children: Children<'a, G>,
|
pub children: Children<'ctx, G>,
|
||||||
pub selected: Option<String>,
|
pub selected: Option<String>,
|
||||||
|
pub plan_date: &'ctx ReadSignal<Option<NaiveDate>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn PlanningPage<'a, G: Html>(cx: Scope<'a>, state: PageState<'a, G>) -> View<G> {
|
pub fn PlanningPage<'ctx, G: Html>(cx: Scope<'ctx>, state: PageState<'ctx, G>) -> View<G> {
|
||||||
let PageState { children, selected } = state;
|
let PageState {
|
||||||
|
children,
|
||||||
|
selected,
|
||||||
|
plan_date,
|
||||||
|
} = state;
|
||||||
let children = children.call(cx);
|
let children = children.call(cx);
|
||||||
let planning_tabs: Vec<(String, &'static str)> = vec![
|
let planning_tabs: Vec<(String, &'static str)> = vec![
|
||||||
("/ui/planning/select".to_owned(), "Select"),
|
("/ui/planning/select".to_owned(), "Select"),
|
||||||
@ -45,6 +51,10 @@ pub fn PlanningPage<'a, G: Html>(cx: Scope<'a>, state: PageState<'a, G>) -> View
|
|||||||
TabbedView(
|
TabbedView(
|
||||||
selected=selected,
|
selected=selected,
|
||||||
tablist=planning_tabs,
|
tablist=planning_tabs,
|
||||||
) { (children) }
|
) { div {
|
||||||
|
"Plan Date: " (plan_date.get().map_or(String::from("Unknown"), |d| format!("{}", d)))
|
||||||
|
}
|
||||||
|
(children)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,13 @@ use sycamore::prelude::*;
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn PlanPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
pub fn PlanPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View<G> {
|
||||||
|
let current_plan = sh.get_selector(cx, |state| {
|
||||||
|
state.get().selected_plan_date
|
||||||
|
});
|
||||||
view! {cx,
|
view! {cx,
|
||||||
PlanningPage(
|
PlanningPage(
|
||||||
selected=Some("Plan".to_owned()),
|
selected=Some("Plan".to_owned()),
|
||||||
|
plan_date = current_plan,
|
||||||
) { RecipePlan(sh) }
|
) { RecipePlan(sh) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,13 @@ pub fn SelectPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> Vie
|
|||||||
plans.sort_unstable_by(|d1, d2| d2.cmp(d1));
|
plans.sort_unstable_by(|d1, d2| d2.cmp(d1));
|
||||||
plans
|
plans
|
||||||
});
|
});
|
||||||
|
let current_plan = sh.get_selector(cx, |state| {
|
||||||
|
state.get().selected_plan_date
|
||||||
|
});
|
||||||
view! {cx,
|
view! {cx,
|
||||||
PlanningPage(
|
PlanningPage(
|
||||||
selected=Some("Select".to_owned()),
|
selected=Some("Select".to_owned()),
|
||||||
|
plan_date = current_plan.clone(),
|
||||||
) {
|
) {
|
||||||
PlanList(sh=sh, list=plan_dates)
|
PlanList(sh=sh, list=plan_dates)
|
||||||
button(on:click=move |_| {
|
button(on:click=move |_| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user