summary refs log tree commit diff stats
path: root/src/components/product_overview.rs
blob: 6cded3f83e725fc38451b07d0120b52063275a0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// rocie - An enterprise grocery management system - Web app
//
// Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This file is part of Rocie.
//
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.

use leptos::{IntoView, component, view};

use crate::{
    api::products_registered_wrapped,
    components::{async_fetch::AsyncFetch, container::Container, icon_p::IconP},
};

#[component]
pub fn ProductOverview() -> impl IntoView {
    view! {
        <Container
            header="Products"
            buttons=vec![
                (view! { <IconP icon=icondata_io::IoClipboard text="Show" /> }, "products"),
                (
                    view! { <IconP icon=icondata_io::IoPricetags text="Create product" /> },
                    "create-product",
                ),
                (
                    view! {
                        <IconP
                            icon=icondata_io::IoPricetags
                            text="Associate barcode with product"
                        />
                    },
                    "associate-barcode-product",
                ),
            ]
        >
            {
                AsyncFetch! {
                    @map_error_in_producer
                    fetcher = products_registered_wrapped(),
                    producer = |products| {
                        view! {
                            <p>{format!("You have {} products.", products.len())}</p>
                        }
                    }
                }
            }
        </Container>
    }
}