Before I nuke my life
This commit is contained in:
42
frontend/src/fetching.rs
Normal file
42
frontend/src/fetching.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user