38 lines
1.4 KiB
Rust
38 lines
1.4 KiB
Rust
use crate::{Issue, User};
|
|
use sycamore::prelude::*;
|
|
|
|
#[component(HomeScreen<G>)]
|
|
pub fn home_screen() -> View<G> {
|
|
let issues: Signal<Vec<(Issue, User)>> = Signal::new(Vec::new());
|
|
if G::IS_BROWSER {
|
|
wasm_bindgen_futures::spawn_local(cloned!(issues => async move {
|
|
let resp = reqwasm::http::Request::get("/api/issues").send().await.unwrap().text().await.unwrap();
|
|
let parsed: Vec<(Issue, User)> = serde_json::from_str(&resp).unwrap_or_default();
|
|
issues.set(parsed);
|
|
}));
|
|
}
|
|
view! {
|
|
div(class="text-align-center") {
|
|
Keyed(KeyedProps {
|
|
iterable: issues.handle(),
|
|
template: |(i, u)| view! {
|
|
div(class="card") {
|
|
h3(class="text-align-center", style="margin-bottom: 0") { (i.title) }
|
|
div(style="justify-content: space-between; display: flex") {
|
|
div { (u.username) }
|
|
div { (i.repo) }
|
|
}
|
|
br {}
|
|
br {}
|
|
p(class="text-align-center") { (i.desc) }
|
|
div(style="display: flex; justify-content: right") {
|
|
a(href=format!("/issue/{}", i.id)) { button { ">>>" } }
|
|
}
|
|
}
|
|
},
|
|
key: |(i, _)| i.id,
|
|
})
|
|
}
|
|
}
|
|
}
|