Skip to content

Commit

Permalink
Merge pull request #211 from Selody-project/179-front-task-공유-일정-페이지-구현
Browse files Browse the repository at this point in the history
179 front task 공유 일정 페이지 구현
  • Loading branch information
kimyoungyin authored Jun 17, 2024
2 parents 1ada571 + 832696e commit b27599f
Show file tree
Hide file tree
Showing 67 changed files with 4,008 additions and 1,468 deletions.
175 changes: 175 additions & 0 deletions __test__/__mocks__/handlers/group/calendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
export const getGroupScheduleSummary = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

const startDateTime = req.url.searchParams.get("startDateTime");
const endDateTime = new Date(
new Date(startDateTime).setHours(23, 59, 59, 999),
).toISOString();
// groupId가 1인 그룹은 공유된 일정이 있지만, 나버지는 공유된 일정이 없어 빈 일정이라 가정.
return res(
ctx.status(200),
ctx.json({
accessLevel: "owner",
schedules:
groupId === 1
? [
{
id: 1,
userId: 1,
startDateTime,
endDateTime,
recurrence: 0,
freq: null,
interval: null,
byweekday: null,
until: null,
isGroup: 0,
},
{
id: 2,
userId: 1,
startDateTime,
endDateTime,
recurrence: 0,
freq: null,
interval: null,
byweekday: null,
until: null,
isGroup: 0,
},
]
: [],
}),
);
};

export const getScheduleProposalsList = (req, res, ctx) => {
// 일단은 빈 것
return res(ctx.status(200), ctx.json([]));
};

export const getGroupSchedule = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

const startDateTime = req.url.searchParams.get("startDateTime");
const endDateTime = new Date(
new Date(startDateTime).setHours(23, 59, 59, 999),
).toISOString();
return res(
ctx.status(200),
ctx.json({
schedules: [
{
id: 1,
userId: 1,
title: "오늘오늘",
content: "오늘 끝",
startDateTime,
endDateTime,
recurrence: 0,
freq: null,
interval: null,
byweekday: null,
until: null,
isGroup: 0,
},
],
}),
);
};

export const getSingleGroupSchedule = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

return res(
ctx.status(200),
ctx.json({
id: Number(req.params.id),
userId: 1,
title: "오늘오늘",
content: "오늘 끝",
startDateTime: "2023-12-14T01:55:00.000Z",
endDateTime: "2023-12-14T05:55:00.000Z",
recurrence: 0,
freq: null,
interval: null,
byweekday: null,
until: null,
}),
);
};

export const deleteGroupSchedule = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

try {
const scheduleId = Number(req.params.id);
if (!scheduleId)
return res(
ctx.status(400),
ctx.json({ error: "지원하지 않는 형식의 데이터입니다." }),
);
// 삭제할 일정이 무조건 id가 1이라는 가정 하에
if (scheduleId !== 1)
return res(
ctx.status(404),
ctx.json({ error: "일정을 찾을 수 없습니다." }),
);
return res(ctx.status(204));
} catch (error) {
console.log(error);
return res(ctx.status(500), ctx.json({ error: "Internal Server Error" }));
}
};
50 changes: 50 additions & 0 deletions __test__/__mocks__/handlers/group/inviteLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const inviteCode = "123456789012";

export const getInviteLink = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

try {
// 임의의 12자리 code 생성
return res(ctx.status(200), ctx.json({ inviteCode }));
} catch (error) {
console.log(error);
return res(ctx.status(500), ctx.json({ error: "Internal Server Error" }));
}
};
export const postInviteLink = (req, res, ctx) => {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

try {
// 임의의 12자리 code 생성
return res(ctx.status(200), ctx.json({ inviteCode }));
} catch (error) {
console.log(error);
return res(ctx.status(500), ctx.json({ error: "Internal Server Error" }));
}
};
101 changes: 101 additions & 0 deletions __test__/__mocks__/handlers/group/members.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
export const getGroupMembers = (req, res, ctx) => {
try {
const groupId = Number(req.params.group_id);
if (!groupId) {
return res(
ctx.status(400),
ctx.json({ error: "형식에 맞지 않는 데이터입니다." }),
);
}

if (groupId < 1) {
return res(
ctx.status(404),
ctx.json({ error: "그룹을 찾을 수 없습니다." }),
);
}

// userId === 1 입니다.
return res(
ctx.status(200),
ctx.json([
{
accessLevel: "viewer",
member: {
nickname: "user2",
userId: 2,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:06:14.000Z",
},
},
{
accessLevel: "viewer",
member: {
nickname: "user3",
userId: 3,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:07:14.000Z",
},
},
{
accessLevel: "viewer",
member: {
nickname: "user4",
userId: 4,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:06:14.000Z",
},
},
{
accessLevel: "viewer",
member: {
nickname: "user5",
userId: 5,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:07:14.000Z",
},
},
{
accessLevel: "viewer",
member: {
nickname: "user6",
userId: 6,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:07:14.000Z",
},
},
{
accessLevel: "owner",
member: {
nickname: "kyy",
userId: 1,
image:
"https://selody-images.s3.ap-northeast-2.amazonaws.com/profile/calender-dynamic-gradient%2B1.png",
commentCount: 0,
likeCount: 0,
joinedDate: "2024-01-15T08:05:52.000Z",
},
},
]),
);
} catch (error) {
console.log("그룹 멤버 조회 중 발생한 에러");
console.log(error);
return res(ctx.status(500), ctx.json({ error: "Internal Server error." }));
}
};
Loading

0 comments on commit b27599f

Please sign in to comment.