2026-09-03 10:03:15 +00:00
|
|
|
use crate::api;
|
|
|
|
|
use crate::api::ArticleView;
|
2026-09-03 14:28:22 +00:00
|
|
|
use crate::components::badge::{Badge, BadgeVariant};
|
2026-09-03 10:03:15 +00:00
|
|
|
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 {
|
2026-09-03 14:28:22 +00:00
|
|
|
Badge { variant: BadgeVariant::Secondary, "{pct}%" }
|
2026-09-03 10:03:15 +00:00
|
|
|
}
|
|
|
|
|
p { class: "summary", "{article.summary}" }
|
|
|
|
|
div { class: "topics",
|
|
|
|
|
for topic in article.topics.iter() {
|
2026-09-03 14:28:22 +00:00
|
|
|
Badge { variant: BadgeVariant::Outline, "{topic}" }
|
2026-09-03 10:03:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
button {
|
|
|
|
|
onclick: move |_| {
|
|
|
|
|
let id = article.id.clone();
|
|
|
|
|
async move {
|
|
|
|
|
let _ = api::articles::mark_dismissed(id).await;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"Not relevant"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|