about summary refs log tree commit diff
path: root/frontend/src/main.rs
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 15:47:47 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 16:12:40 +0100
commit57e36c148c00c339d7b1b3426b7ca651edfc8a1b (patch)
treef2c52861821c97a419757f8d48e22fb38577f0e7 /frontend/src/main.rs
parentFrontend: Move app-specific code to app.rs (diff)
downloadOSSE-57e36c148c00c339d7b1b3426b7ca651edfc8a1b.tar.gz
OSSE-57e36c148c00c339d7b1b3426b7ca651edfc8a1b.tar.bz2
OSSE-57e36c148c00c339d7b1b3426b7ca651edfc8a1b.zip
Frontend: Setup skeleton route support
We now have the / and /search/ route boilerplate. This will allow us to
switch to the /search/ route when searching.
Diffstat (limited to '')
-rw-r--r--frontend/src/main.rs35
1 files changed, 34 insertions, 1 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index fd19fb4..95b52e5 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -1,6 +1,39 @@
 mod app;
 
-use app::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>();