From 32847efa04029d81f9d8cf7a37999cb3cbb1e145 Mon Sep 17 00:00:00 2001
From: Benedikt Peetz
Date: Fri, 26 Sep 2025 17:43:43 +0200
Subject: chore: Initial Commit
---
src/components/mod.rs | 1 +
src/lib.rs | 59 +++++++++++++++++++++++++++++++
src/main.rs | 13 +++++++
src/pages/home.rs | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/pages/mod.rs | 2 ++
src/pages/not_found.rs | 6 ++++
6 files changed, 176 insertions(+)
create mode 100644 src/components/mod.rs
create mode 100644 src/lib.rs
create mode 100644 src/main.rs
create mode 100644 src/pages/home.rs
create mode 100644 src/pages/mod.rs
create mode 100644 src/pages/not_found.rs
(limited to 'src')
diff --git a/src/components/mod.rs b/src/components/mod.rs
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/components/mod.rs
@@ -0,0 +1 @@
+
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..7d58735
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,59 @@
+#![expect(
+ unreachable_pub,
+ reason = "leptos' component macro generates this warning"
+)]
+#![expect(
+ clippy::must_use_candidate,
+ reason = "Can't add it to leptos' components"
+)]
+
+mod components;
+mod pages;
+
+use std::sync::Arc;
+
+use leptos::prelude::{AddAnyAttr, IntoView, component, view};
+use leptos_meta::{Html, Meta, Title, provide_meta_context};
+use leptos_router::{
+ components::{Route, Router, Routes},
+ path,
+};
+use rocie_client::apis::configuration::Configuration;
+
+use crate::pages::home::Home;
+
+#[component]
+pub fn App() -> impl IntoView {
+ // Provides context that manages stylesheets, titles, meta tags, etc.
+ provide_meta_context();
+
+ let config = {
+ let mut config = Configuration::new();
+
+ config.user_agent = Some("rocie-mobile".to_owned());
+ config.base_path = "http://127.0.0.1:8080".to_owned();
+
+ Arc::new(config)
+ };
+
+ view! {
+
+
+
+
+
+
+
+
+
+ }
+ }
+ />
+
+
+ }
+}
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..c377484
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,13 @@
+use leptos::prelude::{mount_to_body, view};
+
+use rocie_mobile::App;
+
+fn main() {
+ // set up logging
+ _ = console_log::init_with_level(log::Level::Debug);
+ console_error_panic_hook::set_once();
+
+ mount_to_body(|| {
+ view! { }
+ });
+}
diff --git a/src/pages/home.rs b/src/pages/home.rs
new file mode 100644
index 0000000..9c86833
--- /dev/null
+++ b/src/pages/home.rs
@@ -0,0 +1,95 @@
+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},
+ view,
+};
+use rocie_client::apis::{
+ api_get_product_api::{ProductsError, products},
+ configuration::Configuration,
+};
+
+#[component]
+pub fn Home(config: Arc) -> impl IntoView {
+ let (read_status, write_status) = signal("Loading..".to_owned());
+
+ {
+ let local_config = Arc::clone(&config);
+
+ 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(),
+ );
+ });
+ }
+
+ view! {
+ "Uh oh! Something went wrong!"
+
+ "Errors: "
+ // Render a list of errors as strings - good for development purposes
+
+ {move || {
+ errors
+ .get()
+ .into_iter()
+ .map(|(_, e)| view! { - {e.to_string()}
})
+ .collect_view()
+ }}
+
+ }
+ }>
+
+
+
+
+
+
"Inventory"
+
+
{read_status}
+
+
+
+
"Recipies"
+
+
+
+
"Shopping list"
+
+
+
+ }
+}
diff --git a/src/pages/mod.rs b/src/pages/mod.rs
new file mode 100644
index 0000000..8829694
--- /dev/null
+++ b/src/pages/mod.rs
@@ -0,0 +1,2 @@
+pub mod home;
+pub mod not_found;
diff --git a/src/pages/not_found.rs b/src/pages/not_found.rs
new file mode 100644
index 0000000..7b5c127
--- /dev/null
+++ b/src/pages/not_found.rs
@@ -0,0 +1,6 @@
+use leptos::{IntoView, component, prelude::ElementChild, view};
+
+#[component]
+pub fn NotFound() -> impl IntoView {
+ view! { "Uh oh!"
"We couldn't find that page!"
}
+}
--
cgit 1.4.1