From 3a0e91bda1e93afa33dd182c2e820c94b3e94593 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 25 Oct 2025 02:15:31 +0200 Subject: 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. --- src/pages/inventory.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/pages/inventory.rs') 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) -> impl IntoView { .collect::>() } +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! {
    -- cgit 1.4.1