blob: bccbfe47b4e578b9a19bb6eac64de35a9db6a2af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use log::info;
use yew::prelude::*;
use crate::use_app_context;
#[function_component(Table)]
pub fn table(props: &TableProps) -> Html {
let ctx = use_app_context();
// let table_state: UseStateHandle<Option<protocol::TableView>> = use_state(|| None);
{
// TODO update this from server state
// let table_state = table_state.clone();
let ctx = ctx.clone();
ctx.spawn_async(async move {
info!("Getting table state");
Err(anyhow::anyhow!("Not implemented yet"))
});
}
let leave_table = {
let ctx = ctx.clone();
Callback::from(move |_| {
ctx.leave_table();
})
};
html! {
<>
<p>{ format!("This is table {}", props.table.id) }</p>
<button onclick={leave_table}>
{ "Leave table" }
</button>
</>
}
}
#[derive(PartialEq, Properties, Clone)]
pub struct TableProps {
pub table: protocol::Table,
}
|