dw about it fixed

This commit is contained in:
LinlyBoi
2022-12-23 11:43:28 +02:00
parent e4305fbb41
commit 649a9a3648
20 changed files with 1421 additions and 2 deletions

61
frontend/src/main.rs Normal file
View File

@@ -0,0 +1,61 @@
use yew::prelude::*;
use common::CommonTicket;
#[function_component]
fn App() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
move |_| {
let value = *counter + 1;
counter.set(value);
}
};
let stdnts = vec! [
Stdnt {
id: 1,
name: "Hamada".to_string(),
email: "Hamada@Gmail.com".to_string(),
gpa: 3.4
},
Stdnt {
id: 2,
name: "Gamal".to_string(),
email: "Gamal@Gmail.com".to_string(),
gpa: 4.0
},
Stdnt {
id: 3,
name: "Joe".to_string(),
email: "joe@proton.mail".to_string(),
gpa: 3.8
}
];
let stdnts_comp = stdnts.iter().map(|stdnt| html! {
<>
<p key={stdnt.id}>{format!("Name: {}", stdnt.name)} </p>
<p key={stdnt.id}>{format!("Email: {}", stdnt.email)} </p>
<p key={stdnt.id}>{format!("GPA: {}",stdnt.gpa)} </p>
<br/>
</>
}).collect::<Html>();
html! {
<div>
<button {onclick}>{ "+1" }</button>
<p>{ *counter }</p>
<h2> { "Students:" } </h2>
<p> { stdnts_comp } </p>
</div>
}
}
struct Stdnt {
id: usize,
name: String,
gpa: f32,
email: String,
}
fn main() {
yew::Renderer::<App>::new().render();
}