app: Correctly handle person count when adding ingredients

This commit is contained in:
traxys 2023-06-30 19:43:26 +02:00
parent 66f9b729b5
commit 840afc7ef4

View file

@ -405,6 +405,7 @@ struct AddIngredientProps {
token: String,
household: Uuid,
recipe: i64,
person_count: u32,
update: Callback<()>,
}
@ -422,10 +423,12 @@ fn AddIngredientInner(props: &AddIngredientProps) -> HtmlResult {
let household = props.household;
let recipe = props.recipe;
let update = props.update.clone();
let pc = props.person_count as f64;
let on_submit = Callback::from(move |_| match &*s_ig {
&Some((id, _)) => match &*am {
&Some(amount) => {
let fut = do_add_ingredient_recipe(token.clone(), household, recipe, id, amount);
let fut =
do_add_ingredient_recipe(token.clone(), household, recipe, id, amount / pc);
let am = am.clone();
let s_ig = s_ig.clone();
@ -516,6 +519,7 @@ fn AddIngredient(props: &AddIngredientProps) -> Html {
household={props.household}
recipe={props.recipe}
update={props.update.clone()}
person_count={props.person_count}
/>
</Suspense>
</>}
@ -1025,6 +1029,7 @@ fn RecipeInfoView(props: &RecipeInfoProps) -> Html {
household={props.household}
recipe={props.recipe_id}
update={props.update.clone()}
person_count={*person_count}
/>
</div>
<hr />