51 lines
1.0 KiB
Rust
51 lines
1.0 KiB
Rust
use yew::prelude::*;
|
|
|
|
use crate::routes::home::student_vote;
|
|
|
|
pub enum Msg {
|
|
Registered,
|
|
}
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct StudentHomeProps {
|
|
pub token: String,
|
|
pub voted: bool,
|
|
}
|
|
|
|
pub struct StudentHome {
|
|
voted: bool,
|
|
}
|
|
|
|
impl Component for StudentHome {
|
|
type Message = Msg;
|
|
type Properties = StudentHomeProps;
|
|
|
|
fn create(ctx: &Context<Self>) -> Self {
|
|
Self {
|
|
voted: ctx.props().voted,
|
|
}
|
|
}
|
|
|
|
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
match msg {
|
|
Msg::Registered => {
|
|
self.voted = true;
|
|
true
|
|
}
|
|
}
|
|
}
|
|
|
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
html! {
|
|
if self.voted {
|
|
<p>{ "Alles in Ordnung." }</p>
|
|
} else {
|
|
<student_vote::StudentVote
|
|
token={ctx.props().token.to_owned()}
|
|
onvoted={ctx.link().callback(|_| Msg::Registered)}
|
|
/>
|
|
}
|
|
}
|
|
}
|
|
}
|