mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Fix bad routing for recipe selection
This commit is contained in:
parent
9011ff13b2
commit
9e66d6e66f
@ -71,7 +71,13 @@ async fn ui_static_assets(Path(path): Path<String>) -> impl IntoResponse {
|
||||
let mut path = path.trim_start_matches("/");
|
||||
path = match path {
|
||||
"" | "inventory" | "plan" | "cook" | "login" => "index.html",
|
||||
_ => path,
|
||||
_ => {
|
||||
if path.starts_with("recipe") {
|
||||
"index.html"
|
||||
} else {
|
||||
path
|
||||
}
|
||||
}
|
||||
};
|
||||
debug!(path = path, "Serving transformed path");
|
||||
StaticFile(path.to_owned())
|
||||
|
@ -61,7 +61,6 @@ pub fn recipe(idx: ReadSignal<String>) -> View<G> {
|
||||
let steps = create_memo(cloned!((recipe) => move || recipe.get().steps.clone()));
|
||||
view.set(view! {
|
||||
div(class="recipe") {
|
||||
h1(class="recipe_title") { (title.get()) }
|
||||
div(class="recipe_description") {
|
||||
(desc.get())
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ pub fn recipe_selection(props: RecipeCheckBoxProps) -> View<G> {
|
||||
app_service.get_recipe_count_by_index(id.as_ref())
|
||||
));
|
||||
let for_id = id.clone();
|
||||
let href = format!("#recipe/{}", id);
|
||||
let href = format!("/ui/recipe/{}", id);
|
||||
let name = format!("recipe_id:{}", id);
|
||||
let value = id.clone();
|
||||
view! {
|
||||
|
@ -198,11 +198,13 @@ impl DeriveRoute for AppRoutes {
|
||||
"/ui/cook" => AppRoutes::Cook,
|
||||
"/ui/inventory" => AppRoutes::Inventory,
|
||||
h => {
|
||||
// TODO(jwall): Parse the recipe hash
|
||||
let parts: Vec<&str> = h.splitn(2, "/").collect();
|
||||
if let Some(&"#recipe") = parts.get(0) {
|
||||
if let Some(&idx) = parts.get(1) {
|
||||
return AppRoutes::Recipe(idx.to_owned());
|
||||
if h.starts_with("/ui/recipe/") {
|
||||
let parts: Vec<&str> = h.split("/").collect();
|
||||
debug!(?parts, "found recipe path");
|
||||
if let Some(&"recipe") = parts.get(2) {
|
||||
if let Some(&idx) = parts.get(3) {
|
||||
return AppRoutes::Recipe(idx.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
error!(origin=%input.0, path=%input.1, hash=%input.2, "Path not found");
|
||||
|
Loading…
x
Reference in New Issue
Block a user