Before I nuke my life

This commit is contained in:
LinlyBoi
2022-12-24 20:16:36 +02:00
parent 367d778ec1
commit 77002200a3
6 changed files with 116 additions and 46 deletions

42
frontend/src/fetching.rs Normal file
View File

@@ -0,0 +1,42 @@
use common::{CommonAdmin, CommonDriver};
use yew::{html, Html};
//Trait to handle Future yew HTMLS
pub trait UseAble {
//Return HTML if didn't fail return error if not
fn use_it(self) -> Result<Html, String>;
}
impl UseAble for CommonDriver {
fn use_it(self) -> Result<Html, String> {
let name = self.name;
let email = self.address;
let id = self.id;
let html = html! {
<div>
<h2> { "Driver:" } </h2>
<p> { format!("Name: {}", name) } </p>
<p> { format!("Email: {}", email) } </p>
<p> { format!("ID: {}", id) } </p>
</div>
};
Ok(html)
}
}
impl UseAble for CommonAdmin {
fn use_it(self) -> Result<Html, String> {
let name = self.name;
let email = self.address;
let id = self.id;
let html = html! {
<div>
<h2> { "Admin:" } </h2>
<p> { format!("Name: {}", name) } </p>
<p> { format!("Email: {}", email) } </p>
<p> { format!("ID: {}", id) } </p>
</div>
};
Ok(html)
}
}