Skip to content

Commit

Permalink
�refactor: 이벤트리스트 mock 작성 (#284)
Browse files Browse the repository at this point in the history
* feat: get event, get mentor mock

* refactor: mock 폴더 구조 변경

* refactor: mock index 추가

* refactor: 이벤트 더미데이터 분리

* fix: 페이지 로더 적용 해제

* fix: 페이지 데이터 개수 수정
  • Loading branch information
leeminhee119 authored Apr 24, 2024
1 parent 655cbb6 commit 9248b23
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 32 deletions.
13 changes: 0 additions & 13 deletions src/mocks/handlers.ts

This file was deleted.

119 changes: 119 additions & 0 deletions src/mocks/handlers/event/event.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { ReadEvent } from '~/types/event/event';
import { EventList } from '~/types/event/eventList';
import { PageData } from '~/types/pageData';

const pageDataMock: PageData = {
first: true,
last: false,
number: 0,
size: 9,
sort: {
empty: true,
sorted: false,
unsorted: true,
},
totalPages: 5,
totalElements: 4,
};

export const readEventMock0: ReadEvent = {
id: 0,
mentorId: 0,
title: '웹 개발자 이력서 5일 간 첨삭',
content: '프론트, 백 관계 없이 웹 개발을 희망하시는 분들 이력서 피드백 드릴게요',
maximumCount: 3,
currentApplicantCount: 1,
status: 'OPEN',
positions: ['FRONT', 'BACK'],
timeInfo: {
openDateTime: '2024-04-24T08:00:00.000Z',
closeDateTime: '2024-04-30T23:59:59.999Z',
endDate: '2024-05-01T23:59:59.999Z',
},
};

export const readEventMock1: ReadEvent = {
id: 1,
mentorId: 0,
title: 'AI 이력서 첨삭',
content: 'AI 개발을 희망하시는 분들 이력서 피드백 드릴게요',
maximumCount: 2,
currentApplicantCount: 0,
status: 'OPEN',
positions: ['ML_AI'],
timeInfo: {
openDateTime: '2024-04-24T08:00:00.000Z',
closeDateTime: '2024-04-30T23:59:59.999Z',
endDate: '2024-05-01T23:59:59.999Z',
},
};

export const readEventMock2: ReadEvent = {
id: 2,
mentorId: 0,
title: '데브옵스 이력서 첨삭',
content: '데브옵스 개발을 희망하시는 분들 이력서 피드백 드릴게요',
maximumCount: 1,
currentApplicantCount: 0,
status: 'OPEN',
positions: ['DEVOPS'],
timeInfo: {
openDateTime: '2024-04-24T08:00:00.000Z',
closeDateTime: '2024-04-30T23:59:59.999Z',
endDate: '2024-05-01T23:59:59.999Z',
},
};

export const readEventMock3: ReadEvent = {
id: 3,
mentorId: 0,
title: '모바일 개발자 이력서 첨삭',
content: '모바일 개발을 희망하시는 분들 이력서 피드백 드릴게요',
maximumCount: 1,
currentApplicantCount: 0,
status: 'OPEN',
positions: ['MOBILE'],
timeInfo: {
openDateTime: '2024-04-24T08:00:00.000Z',
closeDateTime: '2024-04-30T23:59:59.999Z',
endDate: '2024-05-01T23:59:59.999Z',
},
};

export const eventListMock: EventList = {
events: [
{
info: readEventMock0,
mentorInfo: {
mentorId: 0,
nickname: '윤지석',
imageUrl: '',
},
},
{
info: readEventMock1,
mentorInfo: {
mentorId: 0,
nickname: '윤지석',
imageUrl: '',
},
},
{
info: readEventMock2,
mentorInfo: {
mentorId: 0,
nickname: '윤지석',
imageUrl: '',
},
},
{
info: readEventMock3,
mentorInfo: {
mentorId: 0,
nickname: '윤지석',
imageUrl: '',
},
},
],
pageData: pageDataMock,
};
26 changes: 26 additions & 0 deletions src/mocks/handlers/event/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { HttpResponse, http } from 'msw';
import {
eventListMock,
readEventMock1,
readEventMock2,
readEventMock0,
readEventMock3,
} from './event.mock';
import { environments } from '~/config/environments';

const allEvents = new Map();
allEvents.set('0', readEventMock0);
allEvents.set('1', readEventMock1);
allEvents.set('2', readEventMock2);
allEvents.set('3', readEventMock3);

export const handlers = [
http.get(`${environments.baseUrlEnv()}/v1/events`, () => {
return HttpResponse.json(eventListMock);
}),
http.get(`${environments.baseUrlEnv()}/v1/events/:id`, ({ params }) => {
const { id } = params;
const event = allEvents.get(id);
return HttpResponse.json(event);
}),
];
3 changes: 3 additions & 0 deletions src/mocks/handlers/event/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handlers } from './event';

export { handlers as eventHandlers };
5 changes: 5 additions & 0 deletions src/mocks/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { eventHandlers } from './event';
import { resumeHandlers } from './resume';
import { userHandlers } from './user';

export const handlers = [...eventHandlers, ...resumeHandlers, ...userHandlers];
3 changes: 3 additions & 0 deletions src/mocks/handlers/resume/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handlers } from './resume';

export { handlers as resumeHandlers };
8 changes: 8 additions & 0 deletions src/mocks/handlers/resume/resume.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { HttpResponse, http } from 'msw';
import { environments } from '~/config/environments';

export const handlers = [
http.post(`${environments.baseUrlEnv()}/v1/resumes`, () => {
return HttpResponse.json();
}),
];
3 changes: 3 additions & 0 deletions src/mocks/handlers/user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handlers } from './user';

export { handlers as userHandlers };
19 changes: 19 additions & 0 deletions src/mocks/handlers/user/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { HttpResponse, http } from 'msw';
import { environments } from '~/config/environments';
import { ReadMentor } from '~/types/mentor';

const mentorMock: ReadMentor = {
nickname: '윤지석',
experiencedPositions: ['BACK', 'FRONT'],
careerContent: '',
careerYear: 4,
introduce: '',
imageUrl: '',
role: 'mentor',
};

export const handlers = [
http.get(`${environments.baseUrlEnv()}/v1/mentors/:id`, () => {
return HttpResponse.json(mentorMock);
}),
];
20 changes: 12 additions & 8 deletions src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { createBrowserRouter } from 'react-router-dom';
import ErrorBoundary from './ErrorBoundary';
import { EventCreateLoader } from './EventCreateLoader';
import FeedbackLayout from './FeedbackLayout';
import { FeedbackResumeLoader } from './FeedbackResumeLoader';
// import { FeedbackResumeLoader } from './FeedbackResumeLoader';
import FocusLayout from './FocusLayout';
import GuestLoader from './GuestLoader';
import Layout from './Layout';
import MainLayout from './MainLayout';
import { MenteeLoader, MentorLoader, UserLoader } from './UserLoader';
// import { MenteeLoader, MentorLoader, UserLoader } from './UserLoader';
import { CreateEventPage } from '~/pages/EventPages/CreateEventPage';
import { EditEventPage } from '~/pages/EventPages/EditEventPage';
import { EventDetailPage } from '~/pages/EventPages/EventDetailPage';
Expand Down Expand Up @@ -39,7 +39,8 @@ const router = createBrowserRouter([
element: <Layout />,
children: [
{
element: <UserLoader />,
// element: <UserLoader />,
element: <></>,
children: [
{ path: 'mypage', element: <MyPage /> },
{ path: 'user/edit-info', element: <EditProfilePage /> },
Expand All @@ -50,7 +51,8 @@ const router = createBrowserRouter([
],
},
{
element: <MenteeLoader />,
// element: <MenteeLoader />,
element: <></>,
children: [
{
path: 'resume/management',
Expand All @@ -61,7 +63,8 @@ const router = createBrowserRouter([
],
},
{
element: <MentorLoader />,
// element: <MentorLoader />,
element: <></>,
children: [
{ path: 'write-review', element: <WriteReviewPage /> },

Expand Down Expand Up @@ -97,12 +100,13 @@ const router = createBrowserRouter([
element: <FeedbackLayout />,
children: [
{
// element: <MentorLoader />,
element: <FeedbackResumeLoader />,
// element: <FeedbackResumeLoader />,
element: <></>,
children: [{ index: true, element: <FeedbackResumePage /> }],
},
{
element: <MenteeLoader />,
// element: <MentorLoader />,
element: <></>,
children: [{ path: 'feedback/reflect', element: <FeedbackReflectPage /> }],
},
],
Expand Down
12 changes: 1 addition & 11 deletions src/types/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ export type ReadEvent = {
};

export type ReadManagementEvent = {
info: {
id: number;
mentorId: number;
status: EventStatus;
title: string;
content: string;
maximumCount: number;
currentApplicantCount: number;
positions: Position[];
timeInfo: Omit<EventTime, 'now'>;
};
info: ReadEvent;
resumes: EventResume[];
};

0 comments on commit 9248b23

Please sign in to comment.