Update to dioxus 0.4

This commit is contained in:
traxys 2023-08-05 12:54:49 +02:00
parent c36ce14b3b
commit 183f8a75d2
10 changed files with 328 additions and 586 deletions

View file

@ -2,7 +2,7 @@ use std::{marker::PhantomData, rc::Rc};
use api::{CreateRecipeRequest, CreateRecipeResponse, IngredientInfo};
use dioxus::prelude::*;
use dioxus_router::use_router;
use dioxus_router::prelude::*;
use uuid::Uuid;
use crate::{
@ -10,7 +10,7 @@ use crate::{
bootstrap::{bs, FormModal, ModalBody, ModalFooter, ModalToggleButton, TitledModal},
ingredients::do_add_ingredient,
recipe::IngredientSelect,
use_error, use_trimmed_context, ErrorView,
use_error, use_trimmed_context, ErrorView, Route,
};
use super::RecipeIngredient;
@ -211,7 +211,7 @@ pub fn RecipeCreator(cx: Scope) -> Element {
let steps = use_state(cx, String::new);
let router = use_router(cx);
let navigator = use_navigator(cx);
let ingredient_list: Vec<_> =
ingredients.with(|ig| {
@ -254,8 +254,9 @@ pub fn RecipeCreator(cx: Scope) -> Element {
person_count,
steps,
error,
router
navigator
];
cx.spawn(async move {
match do_create_recipe(
token,
@ -281,7 +282,7 @@ pub fn RecipeCreator(cx: Scope) -> Element {
name.set(Default::default());
error.set(Default::default());
router.navigate_to(&format!("/recipe/{id}"));
navigator.push(Route::RecipeView{id});
}
Err(e) => {
error.set(Some(format!("Error creating recipe: {e:?}")));