Skip to content

Commit 40fc24c

Browse files
committed
refactor: simplify AICard component by removing unused imports and updating data handling
1 parent e586ab9 commit 40fc24c

1 file changed

Lines changed: 7 additions & 37 deletions

File tree

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

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { MdBugReport } from 'react-icons/md'
2-
import { TbTestPipe } from 'react-icons/tb'
3-
import { VscClose } from 'react-icons/vsc'
4-
import { Card, Panel } from 'src/components/Elements'
1+
import { Card } from 'src/components/Elements'
52
import { ListComponent } from 'src/components/List'
63
import { useFeatureFlags } from 'src/stores/featureFlags'
74
import { useUserPreferences } from 'src/stores/preferences'
8-
import { Article, CardPropsType } from 'src/types'
5+
import { CardPropsType, FeedItem } from 'src/types'
96
import { useGetAIArticles } from '../../api/getAIArticles'
107
import ArticleItem from './ArticleItem'
118

@@ -15,54 +12,27 @@ export function AICard({ meta, withAds }: CardPropsType) {
1512
const { userSelectedTags } = useUserPreferences()
1613
const { isDone, markDone } = useFeatureFlags()
1714
const {
18-
data: articles = [],
15+
data: articles,
1916
isLoading,
2017
error,
2118
} = useGetAIArticles({
22-
userTopics: userSelectedTags.map((tag) => tag.label.toLocaleLowerCase()),
19+
tags: userSelectedTags.map((tag) => tag.label.toLocaleLowerCase()),
2320
config: {
2421
cacheTime: 0,
2522
staleTime: 0,
2623
useErrorBoundary: false,
2724
},
2825
})
2926

30-
const renderItem = (item: Article, index: number) => (
27+
const renderItem = (item: FeedItem, index: number) => (
3128
<ArticleItem item={item} key={`ai-${index}`} index={index} analyticsTag={meta.analyticsTag} />
3229
)
3330

3431
return (
3532
<Card card={meta} withAds={withAds}>
36-
<ListComponent
37-
items={articles}
33+
<ListComponent<FeedItem>
34+
items={articles?.pages.flatMap((page) => page.data) || []}
3835
error={error}
39-
header={
40-
!isDone(SHOW_PANEL_FEATURE_FLAG) && (
41-
<Panel
42-
variant="information"
43-
title={
44-
<>
45-
<span>
46-
<TbTestPipe size={18} /> Alpha feature
47-
</span>
48-
<button
49-
className="closeBtn"
50-
onClick={() => markDone(SHOW_PANEL_FEATURE_FLAG, true)}
51-
aria-label="Mark feature as read">
52-
<VscClose size="24" />
53-
</button>
54-
</>
55-
}
56-
body={
57-
<>
58-
This AI-powered card compiles articles from various sources. If you spot
59-
irrelevant content, hover an item then use{' '}
60-
<MdBugReport size={18} style={{ verticalAlign: 'middle' }} /> to report it.
61-
</>
62-
}
63-
/>
64-
)
65-
}
6636
isLoading={isLoading}
6737
renderItem={renderItem}
6838
/>

0 commit comments

Comments
 (0)