summary refs log tree commit diff stats
path: root/src/pages/inventory.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-25 02:15:31 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-25 02:15:31 +0200
commit3a0e91bda1e93afa33dd182c2e820c94b3e94593 (patch)
tree436fb1b1e1b0bbe450436ccb5e105b8bea8db17f /src/pages/inventory.rs
parentfeat(treewide): Make usage more intuitive (diff)
downloadweb-client-3a0e91bda1e93afa33dd182c2e820c94b3e94593.zip
feat(treewide): Add further buttons
The register product > associate barcode > buy barcode workflow is now
usable.

The only missing features for an MVP are unit and unit property
creation.
Diffstat (limited to 'src/pages/inventory.rs')
-rw-r--r--src/pages/inventory.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/pages/inventory.rs b/src/pages/inventory.rs
index e5ff6ae..b2ce4a1 100644
--- a/src/pages/inventory.rs
+++ b/src/pages/inventory.rs
@@ -3,10 +3,13 @@ use leptos::{
     prelude::{ClassAttribute, ElementChild},
     view,
 };
-use rocie_client::models::{Product, ProductAmount, Unit};
+use rocie_client::models::{Product, ProductAmount, ProductId, Unit};
 
 use crate::{
-    api::{get_full_product_by_id, get_products},
+    api::{
+        amount_by_id_wrapped, product_by_id_wrapped, products_in_storage_wrapped,
+        unit_by_id_wrapped,
+    },
     components::{async_fetch::AsyncFetch, site_header::SiteHeader},
 };
 
@@ -19,7 +22,7 @@ pub fn Inventory() -> impl IntoView {
             {
                 AsyncFetch! {
                     @map_error_in_producer
-                    fetcher = get_products(),
+                    fetcher = products_in_storage_wrapped(),
                     producer = render_products,
                 }
             }
@@ -40,6 +43,16 @@ fn render_products(products: Vec<Product>) -> impl IntoView {
         .collect::<Vec<_>>()
 }
 
+async fn get_full_product_by_id(
+    id: ProductId,
+) -> Result<(Product, ProductAmount, Unit), leptos::error::Error> {
+    let product = product_by_id_wrapped(id).await?;
+    let amount = amount_by_id_wrapped(id).await?;
+    let unit = unit_by_id_wrapped(amount.amount.unit).await?;
+
+    Ok((product, amount, unit))
+}
+
 fn format_full_product((product, amount, unit): (Product, ProductAmount, Unit)) -> impl IntoView {
     view! {
         <ul class="my-3">