diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-11-26 13:34:35 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-11-27 17:23:11 -0500 |
commit | 854f247b6b7bf1106f31d7f23a326c0904d4f87e (patch) | |
tree | 91c3ecfc6bb38af2be1d67f185b08f4ea544dd36 /webapp/src/components | |
parent | 8fe6b9755a9c96246e7aa1158ee02becda79aa68 (diff) |
Visualize bidding table state from server
Diffstat (limited to 'webapp/src/components')
-rw-r--r-- | webapp/src/components/table.rs | 39 |
1 files 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! { + <> + <BiddingTable bidding={bidding.clone()} /> + <BiddingBox current_bid={bidding.highest_bid().clone()} { on_bid } /> + </> + }, + GameStatePlayerView::PassedOut { + .. + } => todo!(), + GameStatePlayerView::Lead { + .. + } => todo!(), + GameStatePlayerView::Play { + .. + } => todo!(), + }; html! { <> + <div class="center"> + { center } + </div> <div class="hand south"> <Hand cards={ props.table.hand().clone() } on_card_clicked={ on_card_clicked.clone() } /> </div> |