summary refs log tree commit diff stats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-09-30 09:15:56 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-09-30 09:15:56 +0200
commitd0263ce46160cd4152c67381fab2ee557f3aa483 (patch)
treeb24a725d71b984e466ff478fbb4449111beeacac /src/lib.rs
parentchore: Second version (diff)
downloadweb-client-d0263ce46160cd4152c67381fab2ee557f3aa483.zip
feat(treewide): Switch to tailwindcss and add more components
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 357ce93..a488d95 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,24 +7,38 @@
     reason = "Can't add it to leptos' components"
 )]
 #![expect(
-    clippy::needless_pass_by_value,
-    reason = "Can't add it to leptos' components"
+    unused_extern_crates,
+    reason = "Deependency needed to inject the `js` feature into uuid"
 )]
+extern crate uuid;
+
+// All of them are only used in the `main.rs` and not in the `lib.rs` part of this crate.
+extern crate console_error_panic_hook;
+extern crate console_log;
+extern crate log;
 
+mod api;
 mod components;
 mod pages;
 
-use std::sync::Arc;
-
-use leptos::prelude::{AddAnyAttr, IntoView, component, view};
+use leptos::prelude::{AddAnyAttr, IntoView, component, provide_context, view};
 use leptos_meta::{Html, Meta, Title, provide_meta_context};
 use leptos_router::{
     components::{Route, Router, Routes},
     path,
 };
+use reactive_stores::Store;
 use rocie_client::apis::configuration::Configuration;
 
-use crate::pages::{home::Home, not_found::NotFound};
+use crate::{
+    components::inventory::Inventory,
+    pages::{home::Home, not_found::NotFound},
+};
+
+#[derive(Debug, Clone, Store)]
+pub struct ConfigState {
+    config: Configuration,
+}
 
 #[component]
 pub fn App() -> impl IntoView {
@@ -37,13 +51,15 @@ pub fn App() -> impl IntoView {
         config.user_agent = Some("rocie-mobile".to_owned());
         "http://127.0.0.1:8080".clone_into(&mut config.base_path);
 
-        Arc::new(config)
+        config
     };
 
+    provide_context(Store::new(ConfigState { config }));
+
     view! {
         <Html attr:lang="en" attr:dir="ltr" attr:data-theme="light" />
 
-        <Title text="Welcome to Leptos CSR" />
+        <Title text="Rocie-mobile" />
 
         <Meta charset="UTF-8" />
         <Meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -53,8 +69,13 @@ pub fn App() -> impl IntoView {
                 <Route
                     path=path!("/")
                     view=move || {
-                        let local_config = Arc::clone(&config);
-                        view! { <Home config=local_config /> }
+                        view! { <Home /> }
+                    }
+                />
+                <Route
+                    path=path!("/inventory")
+                    view=move || {
+                        view! { <Inventory /> }
                     }
                 />
             </Routes>