From 854f247b6b7bf1106f31d7f23a326c0904d4f87e Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 26 Nov 2022 13:34:35 -0500 Subject: Visualize bidding table state from server --- webapp/src/components/table.rs | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index a874a93..a285449 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -1,11 +1,11 @@ +use crate::components::{Hand, BiddingTable, BiddingBox}; +use crate::use_app_context; +use crate::utils::ok_json; +use anyhow::Context; use gloo_net::http::Request; use log::info; use protocol::bridge_engine::GameStatePlayerView; use yew::prelude::*; -use crate::use_app_context; -use crate::components::Hand; -use crate::utils::ok_json; -use anyhow::Context; #[function_component(OnlineTable)] pub fn online_table(props: &OnlineTableProps) -> Html { @@ -22,7 +22,8 @@ pub fn online_table(props: &OnlineTableProps) -> Html { ctx.spawn_async(async move { let response = Request::get(&format!("/api/table/{}", props.table.id)) .send() - .await.context("fetching table data")?; + .await + .context("fetching table data")?; let table = ok_json(response).await?; table_state.set(Some(table)); Ok(()) @@ -65,8 +66,36 @@ pub fn table(props: &TableProps) -> Html { info!("Card clicked: {}", card); }) }; + let on_bid = { + Callback::from(move |bid| { + info!("Bid clicked: {:?}", bid); + }) + }; + let center = match &props.table { + GameStatePlayerView::Bidding { + bidding, + .. + } => html! { + <> + + + + }, + GameStatePlayerView::PassedOut { + .. + } => todo!(), + GameStatePlayerView::Lead { + .. + } => todo!(), + GameStatePlayerView::Play { + .. + } => todo!(), + }; html! { <> +
+ { center } +
-- cgit v1.2.3