Skip to content

Commit 5ef238b

Browse files
feat: 직무 아티클 목록 조회 api 함수 작성
1 parent 6ba1d2b commit 5ef238b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import apiRequest from '@shared/apis/setting/axiosInstance';
2+
3+
export const getJobPinsArticles = async (page: number, size: number) => {
4+
const { data } = await apiRequest.get('/api/v3/articles/shared/job', {
5+
params: {
6+
page,
7+
size,
8+
},
9+
});
10+
11+
return data.data;
12+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useInfiniteQuery } from '@tanstack/react-query';
2+
import { getJobPinsArticles } from './axios';
3+
4+
export const useGetJobPinsArticles = () => {
5+
return useInfiniteQuery({
6+
queryKey: ['jobPinsArticles'],
7+
queryFn: ({ pageParam = 0 }) => getJobPinsArticles(pageParam, 20),
8+
initialPageParam: 0,
9+
getNextPageParam: (lastPage, allPages) => {
10+
if (lastPage.articles.length === 0) {
11+
return undefined;
12+
}
13+
14+
return allPages.length;
15+
},
16+
});
17+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export interface JobPinArticle {
2+
url: string;
3+
title: string;
4+
thumbnailUrl: string;
5+
categoryName: string;
6+
categoryColor: string;
7+
}
8+
9+
export interface JobPinsResponse {
10+
job: string | null;
11+
articles: JobPinArticle[];
12+
}

0 commit comments

Comments
 (0)