Files
blog-service/frontend/src/components/ArticleCard.tsx
T

28 lines
831 B
TypeScript
Raw Normal View History

2026-01-24 18:44:37 -06:00
import { useNavigate } from 'react-router-dom';
import type { Article } from '../types/Article.ts';
2026-01-25 00:44:02 -06:00
import { Card, Typography } from '@mui/material';
2026-01-24 18:44:37 -06:00
interface Props {
article: Article;
}
export default function ArticleCard(props: Props) {
const navigate = useNavigate();
2026-01-25 00:44:02 -06:00
// TODO: Retrieve author id => author name
2026-01-24 18:44:37 -06:00
return (
<Card
2026-01-25 00:44:02 -06:00
className="flex flex-col p-5 gap-2 cursor-pointer"
2026-01-24 18:44:37 -06:00
onClick={() => { navigate(`/article/${props.article.slug}`) }}
>
2026-01-25 00:44:02 -06:00
<div className="flex align-center justify-center">
<Typography variant="h5">
{props.article.name}
</Typography>
</div>
<div className="flex align-center justify-center">By {props.article.author_id}</div>
<div className="flex align-center justify-center">{props.article.summary}</div>
2026-01-24 18:44:37 -06:00
</Card>
);
};