summaryrefslogtreecommitdiff
path: root/webapp/src/components/table.rs
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/src/components/table.rs')
-rw-r--r--webapp/src/components/table.rs19
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>
+ </>
},
}
}