mentorenwahl/frontend/src/components/graphql_errors.rs

33 lines
713 B
Rust

use yew::prelude::*;
use crate::graphql;
#[derive(Properties, PartialEq)]
pub struct GraphQLErrorsProps {
pub errors: graphql::Errors,
}
pub struct GraphQLErrors;
impl Component for GraphQLErrors {
type Message = ();
type Properties = GraphQLErrorsProps;
fn create(_ctx: &Context<Self>) -> Self {
Self
}
fn view(&self, ctx: &Context<Self>) -> Html {
html! {
if let Some(errors) = &ctx.props().errors {
<div>
<p style="color: red;">{ "Errors:" }</p>
<div>
{ for errors.iter().map(|e| html! { <p style="color: red;">{ e }</p> }) }
</div>
</div>
}
}
}
}