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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#![expect(
unreachable_pub,
reason = "leptos' component macro generates this warning"
)]
#![expect(
clippy::must_use_candidate,
reason = "Can't add it to leptos' components"
)]
#![expect(
unused_extern_crates,
reason = "Deependency needed to inject the `js` feature into uuid"
)]
extern crate uuid;
// All of them are only used in the `main.rs` and not in the `lib.rs` part of this crate.
extern crate console_error_panic_hook;
extern crate console_log;
extern crate log;
mod api;
mod components;
mod pages;
use leptos::prelude::{AddAnyAttr, IntoView, component, provide_context, view};
use leptos_meta::{Html, Meta, Title, provide_meta_context};
use leptos_router::{
components::{Route, Router, Routes},
path,
};
use reactive_stores::Store;
use rocie_client::apis::configuration::Configuration;
use crate::pages::{
associate_barcode::AssociateBarcode, buy::Buy, create_product::CreateProduct,
create_product_parent::CreateProductParent, create_recipe::CreateRecipe, home::Home,
inventory::Inventory, login::Login, not_found::NotFound, product::Product, products::Products,
provision::Provision, recipe::Recipe, recipies::Recipies, units::Units,
};
#[derive(Debug, Clone, Store)]
pub struct ConfigState {
config: Configuration,
}
#[component]
#[expect(clippy::too_many_lines)]
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
let config = {
let mut config = Configuration::new();
config.user_agent = Some("rocie-mobile".to_owned());
"/api/".clone_into(&mut config.base_path);
config
};
provide_context(Store::new(ConfigState { config }));
view! {
<Html attr:lang="en" attr:dir="ltr" attr:data-theme="light" />
<Title text="Rocie-mobile" />
<Meta charset="UTF-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1.0" />
<Router>
<Routes fallback=|| view! { <NotFound /> }>
<Route
path=path!("/")
view=move || {
view! { <Home /> }
}
/>
<Route
path=path!("/login")
view=move || {
view! { <Login /> }
}
/>
<Route
path=path!("/provision")
view=move || {
view! { <Provision /> }
}
/>
// Inventory
<Route
path=path!("/inventory")
view=move || {
view! { <Inventory /> }
}
/>
<Route
path=path!("/buy")
view=move || {
view! { <Buy /> }
}
/>
// Recipes
<Route
path=path!("/recipies")
view=move || {
view! { <Recipies /> }
}
/>
<Route
path=path!("/recipe/:name")
view=move || {
view! { <Recipe /> }
}
/>
<Route
path=path!("/create-recipe")
view=move || {
view! { <CreateRecipe /> }
}
/>
// Products
<Route
path=path!("/products")
view=move || {
view! { <Products /> }
}
/>
<Route
path=path!("/create-product")
view=move || {
view! { <CreateProduct /> }
}
/>
<Route
path=path!("/associate-barcode-product")
view=move || {
view! { <AssociateBarcode /> }
}
/>
<Route
path=path!("/product/:name")
view=move || {
view! { <Product /> }
}
/>
// Product Parents
<Route
path=path!("/create-product-parent")
view=move || {
view! { <CreateProductParent /> }
}
/>
// Units
<Route
path=path!("/units")
view=move || {
view! { <Units /> }
}
/>
</Routes>
</Router>
}
}
|