diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-12-23 16:41:50 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-12-23 16:41:50 -0500 |
commit | b62be3482bc8a69d59744964ec4f6d3574d8b918 (patch) | |
tree | c8bc8d42cbfcbb5fe8f075ec99d48d8ffd4b5ce4 /webapp/src/components | |
parent | 45ce66a29b3d1c49ef8e86b125701e89d58e8a4a (diff) |
Add ability to request the next deal when results are displayed
Diffstat (limited to 'webapp/src/components')
-rw-r--r-- | webapp/src/components/table.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index 9702793..3bc52a3 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -35,6 +35,7 @@ struct OnlineTableInner { pub enum Msg { TableStateUpdated(Result<TableStatePlayerView, anyhow::Error>), + RequestNewDeal, Bid(Bid), Play(Card), } @@ -136,6 +137,15 @@ impl Component for OnlineTableInner { ctx.props().app_ctx.set_error(error); false } + Msg::RequestNewDeal => { + let table = ctx.props().table.clone(); + ctx.link().send_future( + async move { + services::new_deal(table.clone()).await?; + services::get_table_player_view(table).await + }.map(Msg::TableStateUpdated)); + false + }, } } @@ -146,8 +156,13 @@ impl Component for OnlineTableInner { <p>{"An error occurred."}</p> }, Some(TableStatePlayerView::Game(game)) => self.view_game(ctx, game), - Some(TableStatePlayerView::Result(result)) => html! { - <p>{"A beautiful result."}</p> + Some(TableStatePlayerView::Result(_)) => html! { + <> + <p>{"A beautiful result."}</p> + <button onclick={ctx.link().callback(|_| Msg::RequestNewDeal)}> + {"New deal"} + </button> + </> }, } } |