11import { http , HttpResponse } from 'msw' ;
22import { Todo , DAY_OF_THE_WEEK } from '@/shared/type/Todo' ;
3- import { Goal , GoalCategoryEnum } from '@/shared/type/goal' ;
43
54// CORS preflight 요청 처리
65export const optionsHandler = http . options ( '*' , ( ) => {
@@ -14,79 +13,6 @@ export const optionsHandler = http.options('*', () => {
1413 } ) ;
1514} ) ;
1615
17- // 테스트용 Goal 데이터
18- export const mockGoals : Goal [ ] = [
19- {
20- id : 'goal-1' ,
21- name : '프론트엔드 개발 마스터하기' ,
22- mentor : 'TIM_COOK' ,
23- duration : {
24- startDate : '2024-01-01' ,
25- endDate : '2024-03-31' ,
26- } ,
27- toBe : 'React 전문가가 되어 프로젝트를 주도할 수 있음' ,
28- category : GoalCategoryEnum . STUDY ,
29- plans : [
30- {
31- id : 'plan-1' ,
32- content : 'React 컴포넌트 설계 및 리팩토링' ,
33- weekOfMonth : 1 ,
34- } ,
35- {
36- id : 'plan-2' ,
37- content : 'TypeScript와 React 연동' ,
38- weekOfMonth : 2 ,
39- } ,
40- ] ,
41- } ,
42- {
43- id : 'goal-2' ,
44- name : '디자인 시스템 구축' ,
45- mentor : 'CONFUCIUS' ,
46- duration : {
47- startDate : '2024-01-15' ,
48- endDate : '2024-02-28' ,
49- } ,
50- toBe : '일관성 있는 디자인 시스템' ,
51- category : GoalCategoryEnum . FINANCE ,
52- plans : [
53- {
54- id : 'plan-3' ,
55- content : '디자인 토큰 정의 및 컴포넌트 설계' ,
56- weekOfMonth : 1 ,
57- } ,
58- {
59- id : 'plan-4' ,
60- content : '스토리북을 활용한 컴포넌트 문서화' ,
61- weekOfMonth : 2 ,
62- } ,
63- ] ,
64- } ,
65- {
66- id : 'goal-3' ,
67- name : '프로젝트 관리 역량 강화' ,
68- mentor : 'WARREN_BUFFETT' ,
69- duration : {
70- startDate : '2024-01-01' ,
71- endDate : '2024-04-30' ,
72- } ,
73- toBe : '프로젝트를 기획하고 관리할 수 있는 역량' ,
74- category : GoalCategoryEnum . STUDY ,
75- plans : [
76- {
77- id : 'plan-5' ,
78- content : '프로젝트 기획 및 요구사항 분석' ,
79- weekOfMonth : 1 ,
80- } ,
81- {
82- id : 'plan-6' ,
83- content : '팀 협업 및 커뮤니케이션' ,
84- weekOfMonth : 2 ,
85- } ,
86- ] ,
87- } ,
88- ] ;
89-
9016// 테스트용 Todo 데이터 (요일별로 구성)
9117export const mockTodosByPlan : Record < string , Record < DAY_OF_THE_WEEK , Todo [ ] > > = {
9218 'plan-1' : {
@@ -266,24 +192,6 @@ const getAllTodos = (): Todo[] => {
266192 return Object . values ( mockTodosByPlan ) . flatMap ( planTodos => Object . values ( planTodos ) . flat ( ) ) ;
267193} ;
268194
269- // Goal 목록 조회
270- export const getGoals = http . get ( '/mock/goals' , ( ) => {
271- return HttpResponse . json (
272- {
273- data : mockGoals ,
274- message : 'Goal 목록을 성공적으로 조회했습니다.' ,
275- } ,
276- {
277- status : 200 ,
278- headers : {
279- 'Access-Control-Allow-Origin' : '*' ,
280- 'Access-Control-Allow-Methods' : 'GET, POST, PUT, DELETE, PATCH, OPTIONS' ,
281- 'Access-Control-Allow-Headers' : 'Content-Type, Authorization' ,
282- } ,
283- }
284- ) ;
285- } ) ;
286-
287195// 주간 Todo 리스트 조회 (요일별로 그룹화)
288196export const getWeeklyTodoList = http . get ( '/mock/todos' , ( { request } ) => {
289197 const url = new URL ( request . url ) ;
@@ -690,7 +598,6 @@ function getDayOfWeek(dateString: string): DAY_OF_THE_WEEK {
690598// 모든 Todo 핸들러들을 배열로 export
691599export const todoHandlers = [
692600 optionsHandler ,
693- getGoals ,
694601 getWeeklyTodoList ,
695602 getTodos ,
696603 getTodoById ,
0 commit comments