Skip to content

Commit

Permalink
Merge pull request #664 from depromeet/fix/server-deploy
Browse files Browse the repository at this point in the history
refactor: 피드 API v2로 변경
  • Loading branch information
char-yb authored May 21, 2024
2 parents f49fa16 + 0df0076 commit 30b78c7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/apis/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ type GetFeedListResponse = {

type GetFeedByMemberIdResponse = Array<FeedBaseType>;

export type FeedVisibilityType = 'ALL' | 'FOLLOWER' | 'NONE';
export type FeedVisibilityType = 'ALL' | 'FOLLOWING' | 'NONE';

export const FEED_API = {
getFeed: async (memberId: number): Promise<GetFeedByMemberIdResponse> => {
const { data } = await apiInstance.get(`/feed/${memberId}`);
return data;
},
getFeedList: async (request: GetFeedListRequest): Promise<GetFeedListResponse> => {
const { data } = await apiInstance.get('/feed/me', {
const { data } = await apiInstance.get('/feed/me/v2', {
params: request,
});
return data;
Expand Down
93 changes: 48 additions & 45 deletions src/msw/handlers/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
4 changes: 2 additions & 2 deletions src/pages/feed/FeedSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 적용해도 좋을 듯.
Expand Down

0 comments on commit 30b78c7

Please sign in to comment.