summary refs log tree commit diff stats
path: root/src/pages/home.rs
blob: dfc2c54e6bf482af291df4b8709de48d3d6da149 (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
// 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,
    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>
    }
}