Compare commits

...

1 commit

Author SHA1 Message Date
cd02c48a14 remove view for livecoding 2022-05-12 02:29:30 +02:00

View file

@ -5,6 +5,7 @@ use openmensa_rs::{request::MealRequest, Meal};
use seed::{prelude::*, *};
const DATE_ISO_FMT: &str = "%Y-%m-%d";
const DATE_DE_FMT: &str = "%d.%m.%Y";
// ------ ------
// Init
@ -66,37 +67,7 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
// `view` describes what to display.
fn view(model: &Model) -> Node<Msg> {
div![
// button![model.counter, ev(Ev::Click, |_| Msg::Increment),],
h1![format!("Speiseplan vom {}", model.date.format("%d.%m.%Y"))],
input![
attrs! {
At::Type => "date",
At::Value => model.date.format(DATE_ISO_FMT)
},
input_ev(Ev::Input, Msg::SetDate),
],
if &model.meals.len() > &0 {
view_meals(&model.meals)
} else {
p!["Kein Speiseplan verfügbar"]
},
]
}
fn view_meals(meals: &[Meal]) -> Node<Msg> {
ul![meals.iter().map(|meal| {
let price = meal.prices().students();
let price_str = match price {
Some(p) => format!("{:.2}", p),
None => String::from("unbekannt"),
};
li![
el_key(&meal.id()),
format!("{} ({})", meal.name(), price_str),
]
})]
div!["Hello World"]
}
// ------ ------