-
Notifications
You must be signed in to change notification settings - Fork 0
/
review.ts
98 lines (89 loc) · 2.45 KB
/
review.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { rest } from 'msw';
import { ReviewCommentType, ReviewDetailType } from 'src/types/api/review';
import sampleImage from '../../../../public/assets/image/sample.jpeg';
const REVIEW_LIST_MOCK = {
count: 10,
next: '???',
previous: '1',
results: [
{
id: 1,
createAt: '2021-09-22T16:15:45+09:00',
previewImage: sampleImage,
artist: 'seeya-tester',
author: 'seeya-tester',
},
],
};
const REVIEW_DETAIL_MOCK: ReviewDetailType = {
id: 1,
user: {
id: 12,
email: 'seeya@gmail.com',
kakaoId: 'seeya',
nickname: 'seeya-tester',
},
concertHallName: '올림픽홀',
imageUrlArray: [sampleImage.src, sampleImage.src],
images: [sampleImage.src, sampleImage.src],
createAt: '2021-09-22T16:15:45+09:00',
updateAt: '2021-09-22T16:15:45+09:00',
seatArea: 'B1',
artist: 'seeya-singer',
review: '너무 좋아요',
comments: ['리뷰 테스트1', '리뷰 테스트2', '리뷰 테스트3'],
likeUsers: [],
nextId: 13,
previousId: 2,
};
const REVIEW_COMMENT_LIST_MOCK: ReviewCommentType[] = [
{
id: 1,
review: 13,
user: 12,
comment: '리뷰는 뭐고 코멘트는 뭘까? 여기는 comment',
createAt: '2021-09-22T16:15:45+09:00',
updateAt: '2021-09-22T16:15:45+09:00',
},
{
id: 2,
review: 14,
user: 10,
comment: 'here is comment so good!',
createAt: '2021-09-22T16:15:45+09:00',
updateAt: '2021-09-22T16:15:45+09:00',
},
];
export const getReviewListAPIHandler = rest.get(
`${process.env.NEXT_PUBLIC_HOST}/seat_areas/:seatId/reviews`,
(req, res, ctx) => {
return res(ctx.json(REVIEW_LIST_MOCK));
},
);
export const getReviewDetailAPIHandler = rest.get(
`${process.env.NEXT_PUBLIC_HOST}/seat_areas/:seatAreaId/reviews/:reviewId`,
(req, res, ctx) => {
return res(ctx.json(REVIEW_DETAIL_MOCK));
},
);
export const getReviewCommentListAPIHandler = rest.get(
`${process.env.NEXT_PUBLIC_HOST}/reviews/:reviewId/comments`,
(req, res, ctx) => {
return res(ctx.json(REVIEW_COMMENT_LIST_MOCK));
},
);
export const writeReviewCommentAPIHandler = rest.post(
`${process.env.NEXT_PUBLIC_HOST}/reviews/:reviewId/comments`,
(req, res, ctx) => {
const comment = (req.body as any).comment;
REVIEW_COMMENT_LIST_MOCK.push({
id: Math.floor(Math.random() * 100),
review: 14,
user: 10,
comment,
createAt: '2021-09-22T16:15:45+09:00',
updateAt: '2021-09-22T16:15:45+09:00',
});
return res();
},
);