diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-03-19 07:45:14 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-03-19 07:45:14 +0100 |
| commit | f6a3fb9c4d8dd86f78c9f75a23c1ac35bf35d4eb (patch) | |
| tree | 5f28fbca03d83921b568f7cb1708374456d9ec42 /src/components/unit_overview.rs | |
| parent | feat(treewide): Add further buttons (diff) | |
| download | web-client-f6a3fb9c4d8dd86f78c9f75a23c1ac35bf35d4eb.zip | |
feat(treewide): Commit MVP
Diffstat (limited to 'src/components/unit_overview.rs')
| -rw-r--r-- | src/components/unit_overview.rs | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/components/unit_overview.rs b/src/components/unit_overview.rs index 25e5675..0ea3825 100644 --- a/src/components/unit_overview.rs +++ b/src/components/unit_overview.rs @@ -1,6 +1,10 @@ use leptos::{IntoView, component, view}; +use rocie_client::models::{Unit, UnitProperty}; -use crate::components::{container::Container, icon_p::IconP}; +use crate::{ + api::{unit_properties_wrapped, units_wrapped}, + components::{async_fetch::AsyncFetch, container::Container, icon_p::IconP}, +}; #[component] pub fn UnitOverview() -> impl IntoView { @@ -8,14 +12,37 @@ pub fn UnitOverview() -> impl IntoView { <Container header="Units" buttons=vec![ - (view! { <IconP icon=icondata_io::IoClipboard text="Show unit" /> }, "units"), - (view! { <IconP icon=icondata_io::IoClipboard text="Create unit" /> }, "create-unit"), - (view! { <IconP icon=icondata_io::IoPricetags text="Create unit property" /> }, "create-unit-property"), + (view! { <IconP icon=icondata_io::IoClipboard text="Show" /> }, "units"), + ( + view! { <IconP icon=icondata_io::IoClipboard text="Create unit" /> }, + "create-unit", + ), + ( + view! { <IconP icon=icondata_io::IoPricetags text="Create unit property" /> }, + "create-unit-property", + ), ] > { - "You have units" + AsyncFetch! { + @map_error_in_producer + fetcher = get_units_and_unit_properties(), + producer = |(units, unit_properties)| { + view! { + <p>{move || format!( + "You have {} units and {} unit properties.", + units.len(), + unit_properties.len() + )}</p> + } + }, + } } </Container> } } + +async fn get_units_and_unit_properties() +-> Result<(Vec<Unit>, Vec<UnitProperty>), leptos::error::Error> { + Ok((units_wrapped().await?, unit_properties_wrapped().await?)) +} |
