Dominic Grimm
860ae7ed5e
All checks were successful
continuous-integration/drone/push Build is passing
57 lines
1.4 KiB
Rust
57 lines
1.4 KiB
Rust
use graphql_client::reqwest::post_graphql;
|
|
use wasm_bindgen_futures;
|
|
use yew::prelude::*;
|
|
use yew_router::prelude::*;
|
|
|
|
use crate::cookie_names;
|
|
use crate::graphql;
|
|
use crate::routes;
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct MainProps {
|
|
#[prop_or_default]
|
|
pub children: Children,
|
|
}
|
|
|
|
#[function_component(Main)]
|
|
pub fn main(props: &MainProps) -> Html {
|
|
let client = reqwest::Client::new();
|
|
wasm_bindgen_futures::spawn_local(async move {
|
|
let response = post_graphql::<graphql::queries::Ok, _>(
|
|
&client,
|
|
graphql::URL.as_str(),
|
|
graphql::queries::ok::Variables {},
|
|
)
|
|
.await
|
|
.unwrap();
|
|
log::debug!("{:?}", response);
|
|
log::debug!("{:?}", wasm_cookies::get(cookie_names::TOKEN));
|
|
});
|
|
|
|
let history = use_history().unwrap();
|
|
let loginout_onclick = Callback::once(move |_| history.push(routes::Route::Login));
|
|
|
|
html! {
|
|
<>
|
|
<nav>
|
|
<ul>
|
|
<li>
|
|
<Link<routes::Route> to={routes::Route::Home}>
|
|
<button>{ "Home" }</button>
|
|
</Link<routes::Route>>
|
|
</li>
|
|
<li>
|
|
<button onclick={loginout_onclick}>{ "Login/Logout" }</button>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
|
|
<hr />
|
|
|
|
<main>
|
|
{ for props.children.iter() }
|
|
</main>
|
|
</>
|
|
}
|
|
}
|