diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-11-24 10:30:45 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-11-24 10:30:45 -0500 |
commit | 810d2de21f4c47d5f263678c274ae915702d247f (patch) | |
tree | 5dd8fad41503d196045a278df607cbbecbbc7d1e /webapp/src/components | |
parent | e732b64fa6881cf25fd353edff4fd76c839e0c8b (diff) |
Add `TableView` for representing player hands in the app
Diffstat (limited to 'webapp/src/components')
-rw-r--r-- | webapp/src/components/game.rs | 4 | ||||
-rw-r--r-- | webapp/src/components/table.rs | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/webapp/src/components/game.rs b/webapp/src/components/game.rs index 02774e7..9511eb2 100644 --- a/webapp/src/components/game.rs +++ b/webapp/src/components/game.rs @@ -24,6 +24,7 @@ pub fn game() -> Html { let state = state.clone(); Callback::from(move |card| { if let GameState::Play { + dealer, playing_deal, contract, bidding, @@ -33,6 +34,7 @@ pub fn game() -> Html { match playing_deal.play(card) { Err(err) => error!("Could not play card: {:?}", err), Ok(DealInPlayResult::InProgress(playing_deal)) => state.set(GameState::Play { + dealer, playing_deal, contract, bidding, @@ -52,6 +54,7 @@ pub fn game() -> Html { Callback::from(move |(contract, bidding)| { state.set(match contract { Some(contract) => GameState::Play { + dealer, playing_deal: DealInPlay::new(dealer, deal.clone()), contract, bidding, @@ -69,6 +72,7 @@ pub fn game() -> Html { } } GameState::Play { + dealer, playing_deal, contract: _, bidding: _, diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index 3561131..6d861d0 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -1,5 +1,6 @@ use gloo_net::http::Request; use log::info; +use protocol::bridge_engine::TableView; use yew::prelude::*; use crate::use_app_context; @@ -8,7 +9,7 @@ use crate::use_app_context; pub fn table(props: &TableProps) -> Html { let ctx = use_app_context(); - let table_state: UseStateHandle<Option<String>> = use_state(|| None); + let table_state: UseStateHandle<Option<TableView>> = use_state(|| None); { // TODO update this from server state let table_state = table_state.clone(); @@ -20,8 +21,8 @@ pub fn table(props: &TableProps) -> Html { let response = Request::get(&format!("/api/table/{}", props.table.id)) .send() .await?; - let table: protocol::bridge_engine::GameState = response.json().await?; - table_state.set(Some(format!("{:#?}", table))); + let table = response.json().await?; + table_state.set(Some(table)); Ok(()) }); || () @@ -43,7 +44,7 @@ pub fn table(props: &TableProps) -> Html { <button onclick={leave_table}> { "Leave table" } </button> - <pre>{ table_state.as_ref().map_or("".to_string(), |t| format!("{}", t)) }</pre> + <pre>{ format!("Table view: {:?}", *table_state) }</pre> </> } } |