diff --git a/web/src/components/post.rs b/web/src/components/post.rs index 6008632a..f4b071e6 100644 --- a/web/src/components/post.rs +++ b/web/src/components/post.rs @@ -131,7 +131,7 @@ pub fn PostBox(advanced: WriteSignal) -> impl IntoView { for mention in mentions.get().as_deref().unwrap_or(&[]) { to_vec.push(mention.to_string()); } - let payload = serde_json::Value::Object(serde_json::Map::default()) + let payload = apb::new() .set_object_type(Some(apb::ObjectType::Note)) .set_summary(summary.as_deref()) .set_content(Some(&content)) diff --git a/web/src/page/register.rs b/web/src/page/register.rs index 076b2e3e..fc9a2c38 100644 --- a/web/src/page/register.rs +++ b/web/src/page/register.rs @@ -2,6 +2,23 @@ use leptos::*; use reqwest::Method; use crate::prelude::*; +macro_rules! get_ref { + ($r:ident) => { + $r.get().map(|x| x.value()).filter(|x| !x.is_empty()) + } +} + +// TODO this should get moved in a common crate so its not duplicated across FE/BE +#[derive(Debug, Clone, serde::Serialize)] +pub struct RegisterForm { + username: String, + password: String, + display_name: Option, + summary: Option, + avatar_url: Option, + banner_url: Option, +} + #[component] pub fn RegisterPage() -> impl IntoView { let auth = use_context::().expect("missing auth context"); @@ -17,17 +34,29 @@ pub fn RegisterPage() -> impl IntoView {
no credentials provided } + )); + } + spawn_local(async move { - match Http::request::<()>( - Method::PUT, &format!("{URL_BASE}/auth"), None, auth - ).await { - Ok(_x) => {}, - Err(e) => set_error.set(Some( + let payload = RegisterForm { + username: email.unwrap_or_default(), + password: password.unwrap_or_default(), + display_name, summary, avatar_url, banner_url + }; + if let Err(e) = Http::request(Method::PUT, &format!("{URL_BASE}/auth"), Some(&payload), auth).await { + set_error.set(Some( view! {
{e.to_string()}
} - )), + )); } }); } >