From 0df00764845206992cc05777442d3841825401e2 Mon Sep 17 00:00:00 2001 From: ybchar Date: Tue, 21 May 2024 10:19:18 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=94=BC=EB=93=9C=20API=20v2?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/feed.ts | 4 +- src/msw/handlers/feed.ts | 93 ++++++++++++++++++---------------- src/pages/feed/FeedSection.tsx | 4 +- 3 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/apis/feed.ts b/src/apis/feed.ts index b0726d3f..765a179c 100644 --- a/src/apis/feed.ts +++ b/src/apis/feed.ts @@ -16,7 +16,7 @@ type GetFeedListResponse = { type GetFeedByMemberIdResponse = Array; -export type FeedVisibilityType = 'ALL' | 'FOLLOWER' | 'NONE'; +export type FeedVisibilityType = 'ALL' | 'FOLLOWING' | 'NONE'; export const FEED_API = { getFeed: async (memberId: number): Promise => { @@ -24,7 +24,7 @@ export const FEED_API = { return data; }, getFeedList: async (request: GetFeedListRequest): Promise => { - const { data } = await apiInstance.get('/feed/me', { + const { data } = await apiInstance.get('/feed/me/v2', { params: request, }); return data; diff --git a/src/msw/handlers/feed.ts b/src/msw/handlers/feed.ts index 47a49c66..f38b37b8 100644 --- a/src/msw/handlers/feed.ts +++ b/src/msw/handlers/feed.ts @@ -5,56 +5,59 @@ const BASE_URL = process.env.NEXT_PUBLIC_SEVER_API; const getFeedResponse = { success: true, status: 200, - data: [ - { - memberId: 5, - missionId: 7, - recordId: 6, - name: '미션4', - remark: '이 화면 작업중이에용', - nickname: '도모', - recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', - profileImage: null, - duration: 14, - sinceDay: 13, - startedAt: '2024-01-23 15:13:07', - finishedAt: '2024-01-22 15:34:36', - }, - { - memberId: 5, - missionId: 8, - recordId: 27, - name: '미션5', - remark: '이 화면 작업중이에용', - recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', + data: { + content: [ + { + memberId: 5, + missionId: 7, + recordId: 6, + name: '미션4', + remark: '이 화면 작업중이에용', + nickname: '도모', + recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', + profileImage: null, + duration: 14, + sinceDay: 13, + startedAt: '2024-01-23 15:13:07', + finishedAt: '2024-01-22 15:34:36', + }, + { + memberId: 5, + missionId: 8, + recordId: 27, + name: '미션5', + remark: '이 화면 작업중이에용', + recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', - nickname: '도모', - profileImage: null, - duration: 14, - sinceDay: 13, - startedAt: '2024-01-23 15:13:07', - finishedAt: '2024-01-22 15:34:36', - }, - { - memberId: 1, - missionId: 2, - recordId: 9, - name: '미션2', - remark: null, - nickname: '도모', - profileImage: null, - recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', + nickname: '도모', + profileImage: null, + duration: 14, + sinceDay: 13, + startedAt: '2024-01-23 15:13:07', + finishedAt: '2024-01-22 15:34:36', + }, + { + memberId: 1, + missionId: 2, + recordId: 9, + name: '미션2', + remark: null, + nickname: '도모', + profileImage: null, + recordImageUrl: 'https://kr.object.ncloudstorage.com/10mm-images/dev/mission_record/20/image.png', - duration: 12, - sinceDay: 34, - startedAt: '2024-01-03 00:00:00', - finishedAt: '2024-01-03 00:12:30', - }, - ], + duration: 12, + sinceDay: 34, + startedAt: '2024-01-03 00:00:00', + finishedAt: '2024-01-03 00:12:30', + }, + ], + last: true, + }, timestamp: '2024-02-05T10:14:08.636259', }; -const getFeeds = http.get(BASE_URL + '/feed/me', () => { +const getFeeds = http.get(BASE_URL + '/feed/me/v2', () => { return HttpResponse.json(getFeedResponse); }); diff --git a/src/pages/feed/FeedSection.tsx b/src/pages/feed/FeedSection.tsx index bbc92c84..db82ea7c 100644 --- a/src/pages/feed/FeedSection.tsx +++ b/src/pages/feed/FeedSection.tsx @@ -11,13 +11,13 @@ const FEED_TABS: { id: FeedVisibilityType; tabName: string }[] = [ tabName: '전체', }, { - id: 'FOLLOWER', + id: 'FOLLOWING', tabName: '팔로워', }, ]; function FeedSection() { - const tabProps = useTab(FEED_TABS, 'FOLLOWER'); + const tabProps = useTab(FEED_TABS, 'FOLLOWING'); // const { data, isLoading } = useGetFeedList(tabProps.activeTab as FeedVisibilityType); // const feeds = data?.filter((feed) => feed.recordImageUrl); // 이미지 없는 경우가 있음. 나중에 리팩토링 + 서버와 이야기, FeedItem에 ErrorBoundary 적용해도 좋을 듯.