32 lines
994 B
Rust
32 lines
994 B
Rust
|
|
use crate::api;
|
||
|
|
use crate::api::ArticleView;
|
||
|
|
use dioxus::prelude::*;
|
||
|
|
|
||
|
|
#[component]
|
||
|
|
pub fn ArticleRow(article: ArticleView) -> Element {
|
||
|
|
let score_pct = article.final_score.map(|s| (s * 100.0).round() as i32);
|
||
|
|
rsx! {
|
||
|
|
li { class: "article-row",
|
||
|
|
a { href: "{article.url}", target: "_blank", "{article.title}" }
|
||
|
|
if let Some(pct) = score_pct {
|
||
|
|
span { class: "score", "{pct}%" }
|
||
|
|
}
|
||
|
|
p { class: "summary", "{article.summary}" }
|
||
|
|
div { class: "topics",
|
||
|
|
for topic in article.topics.iter() {
|
||
|
|
span { class: "topic-tag", "{topic}" }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
button {
|
||
|
|
onclick: move |_| {
|
||
|
|
let id = article.id.clone();
|
||
|
|
async move {
|
||
|
|
let _ = api::articles::mark_dismissed(id).await;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"Not relevant"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|