Files
peazyweb/frontend/src/main.rs
2025-03-31 15:04:11 +03:00

73 lines
1.7 KiB
Rust

use yew::prelude::*;
use yew_router::prelude::*;
mod api;
mod components;
mod routes;
use crate::components::{
navbar::Navbar,
pages::{
config::Config, configs::Configs, create_config::CreateConfig, directories::Directories,
homepage::Homepage, not_found::NotFound,
},
};
use crate::routes::Route;
fn switch(routes: Route) -> Html {
match routes.clone() {
Route::Home => html! {
<>
<Navbar currrent_route={routes} />
<Homepage />
</> },
Route::Directories => html! {
<>
<Navbar currrent_route={routes} />
<Directories />
</>
},
Route::Configs { dir_name } => html! {
<>
<Navbar currrent_route={routes} currrent_dir={dir_name.clone()} />
<Configs dir={dir_name} />
</>
},
Route::CreateConfig { dir_name } => html! {
<>
<Navbar currrent_route={routes} currrent_dir={dir_name.clone()} />
<CreateConfig dir={dir_name} />
</>
},
Route::Config {
dir_name,
file_name,
} => html! {
<>
<Navbar currrent_route={routes} currrent_dir={dir_name.clone()} />
<Config dir={dir_name} file_name={file_name} />
</>
},
_ => html! {
<>
<Navbar />
<NotFound />
</>
},
}
}
#[function_component]
fn App() -> Html {
html! {
<BrowserRouter>
<Switch<Route> render={switch} />
</BrowserRouter>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}