Skip to content

Commit a88a921

Browse files
committed
refactor: update ArticleItem component to use FeedItem type and improve structure
1 parent e49cb59 commit a88a921

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

src/features/cards/components/aiCard/ArticleItem.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { BiCommentDetail } from 'react-icons/bi'
21
import { GoDotFill } from 'react-icons/go'
32
import { MdAccessTime } from 'react-icons/md'
43
import { CardItemWithActions, CardLink } from 'src/components/Elements'
54
import { Attributes } from 'src/lib/analytics'
65
import { useUserPreferences } from 'src/stores/preferences'
7-
import { Article, BaseItemPropsType } from 'src/types'
6+
import { BaseItemPropsType, FeedItem } from 'src/types'
87
import { format } from 'timeago.js'
98

10-
const ArticleItem = (props: BaseItemPropsType<Article>) => {
9+
export const ArticleItem = (props: BaseItemPropsType<FeedItem>) => {
1110
const { item, index, analyticsTag } = props
1211
const { listingMode } = useUserPreferences()
1312

@@ -19,23 +18,22 @@ const ArticleItem = (props: BaseItemPropsType<Article>) => {
1918
key={index}
2019
cardItem={
2120
<>
22-
<p className="rowTitle">
21+
<div className="rowTitle">
2322
<CardLink
2423
link={item.url}
2524
className="titleWithCover"
2625
analyticsAttributes={{
27-
[Attributes.POINTS]: item.reactions,
2826
[Attributes.TRIGERED_FROM]: 'card',
2927
[Attributes.TITLE]: item.title,
3028
[Attributes.LINK]: item.url,
3129
[Attributes.SOURCE]: analyticsTag,
3230
}}>
33-
{item.image_url && listingMode === 'normal' && (
34-
<img src={item.image_url} className="rowCover" alt="" />
31+
{item.image && listingMode === 'normal' && (
32+
<img src={item.image} className="rowCover" alt="" />
3533
)}
3634
<span className="subTitle">{item.title}</span>
3735
</CardLink>
38-
</p>
36+
</div>
3937
{listingMode === 'compact' && (
4038
<div className="rowDetails">
4139
<span className="rowItem capitalize">
@@ -48,12 +46,8 @@ const ArticleItem = (props: BaseItemPropsType<Article>) => {
4846
<span className="rowItem capitalize">
4947
<GoDotFill className="rowItemIcon" /> {item.source}
5048
</span>
51-
<span className="rowItem" title={new Date(item.published_at).toUTCString()}>
52-
<MdAccessTime className="rowItemIcon" /> {format(new Date(item.published_at))}
53-
</span>
54-
<span className="rowItem">
55-
<BiCommentDetail className={'rowTitleIcon'} />
56-
{item.comments} comments
49+
<span className="rowItem" title={new Date(item.date).toUTCString()}>
50+
<MdAccessTime className="rowItemIcon" /> {format(new Date(item.date))}
5751
</span>
5852
</div>
5953
)}

0 commit comments

Comments
 (0)