summaryrefslogtreecommitdiff
path: root/webapp/src/components/table.rs
blob: 829441e1581a7cb51a2c5b51d131e6dd55287731 (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
use yew::prelude::*;
use yew_router::prelude::*;

use crate::use_app_context;

#[function_component(Table)]
pub fn table(props: &TableProps) -> Html {
    let ctx = use_app_context();
    let history = use_history().unwrap();

    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,
}