Skip to content

Commit e5676b5

Browse files
feat: 직무 아티클 목록 api 연결
1 parent 5ef238b commit e5676b5

File tree

1 file changed

+57
-26
lines changed

1 file changed

+57
-26
lines changed

apps/client/src/pages/jobPins/JobPins.tsx

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,73 @@
1-
import { Card } from '@pinback/design-system/ui';
1+
import { useGetJobPinsArticles } from '@pages/jobPins/apis/queries';
22
import Footer from '@pages/myBookmark/components/footer/Footer';
3-
4-
const MOCK_JOB_PINS = Array.from({ length: 30 }, (_, index) => ({
5-
id: index + 1,
6-
title: '텍스트텍스트텍스트텍스트텍스트텍스트텍스트',
7-
content: '서브텍스트입니다서브텍스트입니다서브텍스트입니다서브텍스트입니다',
8-
category: '카테고리명',
9-
categoryColor: 'COLOR7' as const,
10-
variant: 'save' as const,
11-
nickname: index % 3 === 0 ? '구글닉네임명' : '',
12-
}));
3+
import { Card } from '@pinback/design-system/ui';
4+
import { useInfiniteScroll } from '@shared/hooks/useInfiniteScroll';
5+
import { useRef } from 'react';
136

147
const JobPins = () => {
8+
const scrollContainerRef = useRef<HTMLDivElement>(null);
9+
10+
const { data, isPending, fetchNextPage, hasNextPage } =
11+
useGetJobPinsArticles();
12+
13+
const observerRef = useInfiniteScroll({
14+
fetchNextPage,
15+
hasNextPage,
16+
root: scrollContainerRef,
17+
});
18+
19+
const articlesToDisplay =
20+
data?.pages.flatMap((page) => page.articles ?? []) ?? [];
21+
22+
const job = data?.pages?.[0]?.job ?? null;
23+
24+
if (isPending) {
25+
return <div>Loading...</div>;
26+
}
27+
1528
return (
1629
<div className="flex h-screen flex-col pl-[8rem] pr-[5rem] pt-[5.2rem]">
1730
<div className="flex items-center gap-[1.2rem]">
1831
<p className="head3">관심 직무 핀</p>
19-
<p className="head3 text-main500">기획자</p>
32+
{job && <p className="head3 text-main500">{job}</p>}
2033
</div>
2134
<p className="body3-r text-font-gray-3 mt-[0.8rem]">
2235
같은 직무의 사람들이 저장한 아티클을 살펴봐요. 선택한 직무를 기준으로
2336
최신 핀이 업데이트 돼요!
2437
</p>
2538

26-
<div className="scrollbar-hide mt-[2.6rem] flex h-screen flex-wrap content-start gap-[1.6rem] overflow-y-auto scroll-smooth">
27-
{MOCK_JOB_PINS.map((pin) => (
28-
<Card
29-
key={pin.id}
30-
type="bookmark"
31-
variant={pin.variant}
32-
title={pin.title}
33-
content={pin.content}
34-
category={pin.category}
35-
categoryColor={pin.categoryColor}
36-
nickname={pin.nickname}
37-
/>
38-
))}
39-
</div>
39+
{job === null ? (
40+
<p className="body2-m text-font-gray-3 mt-[4rem]">
41+
기존 사용자 직무 선택 API로 직무 정보를 변경해주세요.
42+
</p>
43+
) : articlesToDisplay.length > 0 ? (
44+
<div
45+
ref={scrollContainerRef}
46+
className="scrollbar-hide mt-[2.6rem] flex h-screen flex-wrap content-start gap-[1.6rem] overflow-y-auto scroll-smooth"
47+
>
48+
{articlesToDisplay.map((article) => (
49+
<Card
50+
key={article.id}
51+
type="bookmark"
52+
variant="save"
53+
title={article.title}
54+
imageUrl={article.thumbnailUrl}
55+
content={article.memo}
56+
category={article.categoryName}
57+
categoryColor={article.categoryColor}
58+
nickname={article.ownerName}
59+
onClick={() => window.open(article.url, '_blank')}
60+
/>
61+
))}
62+
63+
<div ref={observerRef} style={{ height: '1px', width: '100%' }} />
64+
</div>
65+
) : (
66+
// TODO: 아티클 없는경우 UI 수정
67+
<p className="body2-m text-font-gray-3 mt-[4rem]">
68+
아직 공유된 아티클이 없어요.
69+
</p>
70+
)}
4071

4172
<Footer />
4273
</div>

0 commit comments

Comments
 (0)