From fd832ce7a3660bd81b5476477ecdc2bc822df5c2 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 26 Sep 2025 20:15:48 +0200 Subject: chore: Second version --- src/pages/home.rs | 78 ++++++++++++++----------------------------------------- 1 file changed, 19 insertions(+), 59 deletions(-) (limited to 'src/pages/home.rs') diff --git a/src/pages/home.rs b/src/pages/home.rs index 9c86833..8749860 100644 --- a/src/pages/home.rs +++ b/src/pages/home.rs @@ -3,45 +3,26 @@ use std::sync::Arc; use leptos::{ IntoView, component, error::ErrorBoundary, - prelude::{ - ClassAttribute, CollectView, ElementChild, Get, Read, ReadSignal, Set, With, signal, - }, - reactive::spawn_local, - server::{LocalResource, Resource}, + prelude::{CollectView, ElementChild, Get, GetUntracked}, view, }; -use rocie_client::apis::{ - api_get_product_api::{ProductsError, products}, - configuration::Configuration, +use leptos_router::{ + NavigateOptions, + hooks::{use_navigate, use_query_map}, }; +use rocie_client::apis::configuration::Configuration; +use thaw::{Layout, LayoutPosition}; + +use crate::components::{product_overview::ProductOverview, side_header::SiteHeader}; #[component] pub fn Home(config: Arc) -> impl IntoView { - let (read_status, write_status) = signal("Loading..".to_owned()); - - { - let local_config = Arc::clone(&config); + let query_map = use_query_map().get_untracked(); + let navigate = use_navigate(); - spawn_local(async move { - let products = products(&local_config).await; - - write_status.set( - products - .as_ref() - .map(move |products| { - let products_num = products.len(); - let plural_s = if products_num == 1 { "" } else { "s" }; - let products_value = 2; - let products_currency = "EUR"; - format!( - "You have {products_num} product{plural_s} \ - in stock with a value \ - of {products_value} {products_currency}.", - ) - }) - .unwrap(), - ); - }); + // mobile page + if let Some(path) = query_map.get("path") { + navigate(&path, NavigateOptions::default()); } view! { @@ -63,33 +44,12 @@ pub fn Home(config: Arc) -> impl IntoView { } }> - - -
-
-

"Inventory"

- -

{read_status}

-
- -
-

"Recipies"

-
- -
-

"Shopping list"

-
-
+ + + + + + } } -- cgit 1.4.1