diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-30 17:36:45 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-30 17:52:53 +0100 |
commit | cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b (patch) | |
tree | 5b1598be6a369c5ddd467e9aa6189c825eae1cf1 /frontend/src/main.rs | |
parent | Frontend: Update yew to follow master (diff) | |
download | OSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.tar.gz OSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.tar.bz2 OSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.zip |
Frontend: Implement support for searching with /search/* routes
We now immediately search if we are in a /search/* route. This implementation is not that good as we have to duplicate the code that runs both when creating the component in /search/* route and when submitting a search query.
Diffstat (limited to '')
-rw-r--r-- | frontend/src/main.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs index fd5ef3c..7f73cf7 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -9,17 +9,19 @@ use app::OSSE; enum Route { #[at("/")] OSSEHome, + #[at("/search/")] + OSSEHomeEmptySearch, #[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::OSSEHome | Route::OSSEHomeEmptySearch => html! { + <OSSE api_endpoint={"http://127.0.0.1:4444"} initial_search_query={None as Option<String>} /> }, Route::OSSESearch { query } => html! { - <OSSE api_endpoint={"http://127.0.0.1:4444"}/> + <OSSE api_endpoint={"http://127.0.0.1:4444"} initial_search_query={Some(query)} /> }, } } |