summary refs log tree commit diff stats
path: root/src/components/buy.rs
blob: 6d9402ee0f21a12ff1896863af66bca0bdc52510 (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
use leptos::{IntoView, component, view};
use log::info;
use rocie_client::models::UnitId;
use uuid::Uuid;

use crate::components::{form::Form, site_header::SiteHeader};

#[component]
pub fn Buy() -> impl IntoView {
    view! {
        <SiteHeader logo=icondata_io::IoPricetag back_location="/" name="Buy" />

        {Form! {
            on_submit = |product_barcode, amount, unit_id| {
                info!("Got product barcode: {product_barcode} with amount: {amount}, {unit_id}");
            };

            <Input
                name=product_barcode,
                rust_type=u32,
                html_type="number",
                label="Product Barcode"
            />
            <Select
                name=unit_id,
                rust_type=Uuid,
                label="Unit",
                options=[
                    ("Kilogram", Uuid::new_v4()),
                    ("Gram",  Uuid::new_v4())
                ]
            />
            <Input
                name=amount,
                rust_type=u16,
                html_type="number",
                label="Amount"
            />
        }}
    }
}