summary refs log tree commit diff stats
path: root/src/pages/home.rs
blob: e3767fd0aaf7888e80fa95051f27d2a222ad930c (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
use leptos::{
    IntoView, component,
    prelude::{ClassAttribute, ElementChild, GetUntracked},
    view,
};
use leptos_router::{
    NavigateOptions,
    hooks::{use_navigate, use_query_map},
};

use crate::components::{
    catch_errors::CatchErrors, inventory::Inventory, login_wall::LoginWall,
    product_overview::ProductOverview, product_parent_overview::ProductParentOverview,
    recipies::Recipies, site_header::SiteHeader, unit_overview::UnitOverview,
};

#[component]
pub fn Home() -> impl IntoView {
    let query_map = use_query_map().get_untracked();
    let navigate = use_navigate();

    if let Some(path) = query_map.get("path") {
        navigate(&path, NavigateOptions::default());
    }

    view! {
        <CatchErrors>
            <LoginWall back=move || "/".to_owned()>
                <SiteHeader logo=icondata_io::IoRoseSharp back_location="/" name="Rocie" />

                <div class="flex flex-col content-start">
                    <Inventory />
                    <Recipies />
                    <hr class="w-8 h-0.5 rounded-lg mt-4 self-center bg-gray-500" />
                    <ProductOverview />
                    <UnitOverview />
                    <ProductParentOverview />
                </div>
            </LoginWall>
        </CatchErrors>
    }
}