summaryrefslogtreecommitdiffstats
path: root/src/components/inventory.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/inventory.rs')
-rw-r--r--src/components/inventory.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/components/inventory.rs b/src/components/inventory.rs
new file mode 100644
index 0000000..275dd0b
--- /dev/null
+++ b/src/components/inventory.rs
@@ -0,0 +1,43 @@
+use leptos::{IntoView, component, view};
+
+use crate::{
+ api::products_in_storage_wrapped,
+ components::{async_fetch::AsyncFetch, container::Container, icon_p::IconP},
+};
+
+#[component]
+pub fn Inventory() -> impl IntoView {
+ view! {
+ <Container
+ header="Inventory"
+ buttons=vec![
+ (view! { <IconP icon=icondata_io::IoClipboard text="Inventory" /> }, "inventory"),
+ (view! { <IconP icon=icondata_io::IoPricetags text="Consume" /> }, "consume"),
+ (view! { <IconP icon=icondata_io::IoStorefront text="Buy" /> }, "buy"),
+ ]
+ >
+ {
+ AsyncFetch! {
+ @map_error_in_producer
+ fetcher = products_in_storage_wrapped(),
+ producer = |products| {
+ let products_num = products.len();
+ let plural_s = if products_num == 1 { "" } else { "s" };
+ let products_value = 2;
+ let products_currency = "EUR";
+
+ view! {
+ <p>
+ {format!(
+ "You have {products_num} product{plural_s} \
+ in stock with a value \
+ of {products_value} {products_currency}.",
+ )}
+ </p>
+ }
+ }
+ }
+ }
+ </Container>
+ }
+}