use leptos::{
IntoView, component,
prelude::{ClassAttribute, ElementChild},
view,
};
use crate::{
api::{get_full_product_by_id, get_products},
components::{async_fetch::AsyncFetch, site_header::SiteHeader},
};
#[component]
pub fn Inventory() -> impl IntoView {
view! {
{
AsyncFetch! {
fetcher = {get_products()}
producer = |products| {
products
.into_iter()
.map(|product| {
view! {
{AsyncFetch! {
fetcher = {get_full_product_by_id(product.id)}
producer = |(product, amount, unit)| {
view! {
- {product.name}
-
{
format!(
"{} {}",
amount.amount.value,
unit.short_name
)
}
}
}
}}
}
})
.collect::>()
}
}
}
}
}