From 2d9d37bd5e4770a05cae780f2113266f3fdd0915 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 15 Oct 2022 09:34:44 -0400 Subject: Add table creation --- webapp/Cargo.toml | 1 + webapp/src/main.rs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'webapp') diff --git a/webapp/Cargo.toml b/webapp/Cargo.toml index b7c0d28..fd048ab 100644 --- a/webapp/Cargo.toml +++ b/webapp/Cargo.toml @@ -21,6 +21,7 @@ wasm-bindgen-futures = "0.4.33" protocol = { path = "../protocol" } yew-router = "0.16.0" web-sys = { version = "0.3.60", features = ["Location", "Document"] } +uuid = { version = "1.2.1", features = ["serde"] } [dev-dependencies] env_logger = "0.8.4" diff --git a/webapp/src/main.rs b/webapp/src/main.rs index 1b60a9f..4ba8e5f 100644 --- a/webapp/src/main.rs +++ b/webapp/src/main.rs @@ -2,6 +2,7 @@ use std::rc::Rc; #[allow(unused_imports)] use log::{debug, error, info, warn}; +use uuid::Uuid; use yew::prelude::*; use yew_router::prelude::*; pub mod bridge_engine; @@ -53,15 +54,24 @@ fn home() -> Html { None => html! {

{ "Log in" }

}, }; + let create_table = Callback::from(|_| { + wasm_bindgen_futures::spawn_local(async move { + let response = Request::post("/api/table").send().await.unwrap(); + let table_id: Uuid = response.json().await.unwrap(); + info!("Created table {table_id}"); + }); + }); + html! { <> if let Some(error) = &ctx.error { } - { user } -

- to={Route::Playground}>{ "Playground" }> -

+ } } -- cgit v1.2.3