import { faCheck, faCircle } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import type { components } from "../api/generated"; import { api } from "../services/api-client"; type Article = components["schemas"]["Article"]; interface Props { article: Article; onReadChange?: (articleId: string, isRead: boolean) => void; } export function ArticleItem({ article, onReadChange }: Props) { const handleToggleRead = async ( articleId: string, isCurrentlyRead: boolean, ) => { const newReadState = !isCurrentlyRead; onReadChange?.(articleId, newReadState); if (isCurrentlyRead) { await api.POST("/api/articles/{articleId}/unread", { params: { path: { articleId } }, }); } else { await api.POST("/api/articles/{articleId}/read", { params: { path: { articleId } }, }); } }; const handleArticleClick = async (article: Article) => { window.open(article.url, "_blank", "noreferrer"); if (!article.isRead) { onReadChange?.(article.id, true); await api.POST("/api/articles/{articleId}/read", { params: { path: { articleId: article.id } }, }); } }; return (