about summary refs log tree commit diff
path: root/frontend/src/main.rs
blob: 95b52e5a67ea7d1dfc899d9cdea8d47fd7d32ad0 (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
mod app;

use yew::prelude::*;
use yew_router::prelude::*;
use app::OSSE;


#[derive(Clone, Routable, PartialEq)]
enum Route {
    #[at("/")]
    OSSEHome,
    #[at("/search/:query")]
    OSSESearch { query: String },
}

fn switch_routes(routes: &Route) -> Html {
    match routes {
        Route::OSSEHome => html! {
            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
        },
        Route::OSSESearch { query } => html! {
            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
        },
    }
}

#[function_component(App)]
fn yew_app() -> Html {
    html! {
        <>
            <BrowserRouter>
                <Switch<Route> render={Switch::render(switch_routes)} />
            </BrowserRouter>
        </>
    }
}

fn main() {
    yew::start_app::<App>();
}