-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlive-popular-feed.tsx
More file actions
79 lines (70 loc) · 2.28 KB
/
live-popular-feed.tsx
File metadata and controls
79 lines (70 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { useState } from 'react';
import { useSuspenseQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
import { Carousel, Indicator, Title } from '@bds/ui';
import { Icon } from '@bds/ui/icons';
import FeedCard from '@widgets/community/components/feed-card/feed-card';
import { COMMUNITY_QUERY_OPTIONS } from '@shared/api/domain/community/queries';
import { routePath } from '@shared/router/path';
import * as styles from './live-popular-feed.css';
const TOTAL_POPULAR_FEED = 3;
const LivePopularFeed = () => {
const navigate = useNavigate();
const [currentPage, setCurrentPage] = useState(0);
const { data: popularFeedData } = useSuspenseQuery({
...COMMUNITY_QUERY_OPTIONS.POPULAR_FEED(TOTAL_POPULAR_FEED),
});
return (
<div className={styles.container}>
<div className={styles.titleContainer}>
<Icon
name="ai_fill"
width="2.4rem"
height="2.4rem"
color="bofitOrange"
/>
<Title fontStyle="bd_sm">실시간 인기 게시글</Title>
</div>
<Carousel
slidesPerView={'auto'}
infinite={false}
onSlideChange={(index: number) => setCurrentPage(index)}
onSlideEnd={() => setCurrentPage(2)}
className={styles.carousel}
>
{popularFeedData?.data?.posts?.map(
({
title,
content,
commentCount,
likeCount,
postId,
likedByCurrentUser,
}) => (
<Carousel.Item
key={postId}
className={styles.carouselItem}
onClick={() =>
navigate(
routePath.COMMUNITY_DETAIL.replace(':postId', String(postId)),
)
}
>
<FeedCard
title={title ?? ''}
content={content ?? ''}
commentCount={commentCount ?? 0}
likeCount={likeCount ?? 0}
likedByCurrentUser={likedByCurrentUser ?? false}
/>
</Carousel.Item>
),
)}
</Carousel>
<div className={styles.indicatorWrapper}>
<Indicator current={currentPage} total={TOTAL_POPULAR_FEED} />
</div>
</div>
);
};
export default LivePopularFeed;