From 188dd7ee818d0a456f348d9010ff616a701497d6 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 3 May 2024 06:14:36 +0200 Subject: [PATCH] feat(web): bad search bar and page --- web/src/app.rs | 1 + web/src/control.rs | 21 ++++++++++++++---- web/src/page.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/web/src/app.rs b/web/src/app.rs index 9e7845ef..8ae651ce 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -112,6 +112,7 @@ pub fn App() -> impl IntoView { } /> + } /> diff --git a/web/src/control.rs b/web/src/control.rs index 84ac46cf..73c3c92a 100644 --- a/web/src/control.rs +++ b/web/src/control.rs @@ -6,11 +6,24 @@ use crate::prelude::*; #[component] pub fn Navigator() -> impl IntoView { let auth = use_context::().expect("missing auth context"); + let (query, set_query) = create_signal("".to_string()); view! { - - - - + + + + + + + + + +
+ + + +
} } diff --git a/web/src/page.rs b/web/src/page.rs index 03ba6af5..e8e6fd65 100644 --- a/web/src/page.rs +++ b/web/src/page.rs @@ -331,3 +331,57 @@ pub fn DebugPage() -> impl IntoView { } } + +#[component] +pub fn SearchPage() -> impl IntoView { + let auth = use_context::().expect("missing auth context"); + + let user = create_local_resource( + move || use_query_map().get().get("q").cloned().unwrap_or_default(), + move |q| { + let user_fetch = Uri::api(FetchKind::User, &q, true); + async move { Some(Arc::new(Http::fetch::(&user_fetch, auth).await.ok()?)) } + } + ); + + let object = create_local_resource( + move || use_query_map().get().get("q").cloned().unwrap_or_default(), + move |q| { + let object_fetch = Uri::api(FetchKind::Object, &q, true); + async move { Some(Arc::new(Http::fetch::(&object_fetch, auth).await.ok()?)) } + } + ); + + view! { + search +
+
+ + users + + {move || match user.get() { + None => None, + Some(None) => None, + Some(Some(u)) => Some(view! { + + }), + }} +
+
+ +
+
+ + objects + + {move || match object.get() { + None => None, + Some(None) => None, + Some(Some(o)) => Some(view! { + + }), + }} + + + } +}