Skip to content

Commit

Permalink
Merge pull request #244 from boostcampwm-2021/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
mminjg authored Dec 2, 2021
2 parents b664898 + d48261a commit 0e99cb3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ https://www.boostteams.kro.kr

## 기술 스택 👨‍💻 👩‍💻
![image](https://user-images.githubusercontent.com/47925079/144397243-4754a039-1255-468c-bc41-5392dd1ca4a0.png)

## 시스템 구성도 ⚙️
<img src="https://user-images.githubusercontent.com/42960217/143481445-f5f9a568-2526-46c7-8ed4-e3fd0d7c5ae3.png" width="700px">
![image](https://user-images.githubusercontent.com/47925079/144424027-d6230ee5-35ff-400f-a848-b76dd17b3b06.png)

## 설계 🎨
- [Design: Figma](https://www.figma.com/file/ARSNGmB4baVv48Os7TrELl/Teams?node-id=0%3A1)
Expand Down
14 changes: 3 additions & 11 deletions backend/src/controllers/schedule-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@ import { Request, Response } from 'express';
import moment from 'moment';
import ScheduleService from '@services/schedule-service';

const changeFieldToNumber = (teamID, newScheduleData) => {
newScheduleData.team_id = Number(teamID);
newScheduleData.color = Number(newScheduleData.color);
return newScheduleData;
};

const ScheduleController = {
async createSchedule(req: Request, res: Response) {
try {
const scheduleInfo = changeFieldToNumber(req.params.teamId, req.body);
const newSchedule = await ScheduleService.getInstance().createSchedule(scheduleInfo);
const newSchedule = await ScheduleService.getInstance().createSchedule(req.body);
res.json(newSchedule);
} catch (err) {
res.sendStatus(409);
}
},
async getSchedule(req: Request, res: Response) {
try {
const { start_date, end_date }: { start_date?: string; end_date?: string } = req.query;
const team_id = Number(req.params.teamId);
const { team_id, start_date, end_date }: { team_id?: string; start_date?: string; end_date?: string } = req.query;
const startDate = moment(start_date, 'YYYYMMDD').format('YYYY-MM-DD');
const endDate = moment(end_date, 'YYYYMMDD').format('YYYY-MM-DD');
const schedules = await ScheduleService.getInstance().getSchedule(team_id, startDate, endDate);
const schedules = await ScheduleService.getInstance().getSchedule(Number(team_id), startDate, endDate);
res.json(schedules);
} catch (err) {
res.sendStatus(404);
Expand Down
9 changes: 4 additions & 5 deletions backend/src/routes/schedule-router.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import express from 'express';
import ScheduleController from '@controllers/schedule-controller';
import { checkTeamUser } from '@src/middlewares/user';
import { authenticateToken } from '@src/middlewares/token';

const router = express.Router();

router.post('/:teamId', authenticateToken, checkTeamUser, ScheduleController.createSchedule);
router.get('/:teamId', authenticateToken, checkTeamUser, ScheduleController.getSchedule);
router.put('/:scheduleId', ScheduleController.updateRepeatSchedule);
router.delete('/:scheduleId', ScheduleController.deleteSchedule);
router.post('/', authenticateToken, ScheduleController.createSchedule);
router.get('/', authenticateToken, ScheduleController.getSchedule);
router.put('/:scheduleId', authenticateToken, ScheduleController.updateRepeatSchedule);
router.delete('/:scheduleId', authenticateToken, ScheduleController.deleteSchedule);

export default router;
6 changes: 3 additions & 3 deletions frontend/src/apis/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fetchApi from '@utils/fetch';

export const getSchedules = async (teamId: number, firstDate: string, lastDate: string): Promise<ScheduleType[]> => {
try {
const res = await fetchApi.get(`/api/schedules/${teamId}?start_date=${firstDate}&end_date=${lastDate}`);
const res = await fetchApi.get(`/api/schedules?team_id=${teamId}&start_date=${firstDate}&end_date=${lastDate}`);
if (res.status === 404) throw new Error('😣 일정을 가져올 수 없습니다!');
else if (res.status === 403) throw new Error('😣 권한이 없습니다!');
const data = await res.json();
Expand All @@ -16,9 +16,9 @@ export const getSchedules = async (teamId: number, firstDate: string, lastDate:
}
};

export const createNewSchedule = async (teamId: number, newSchedule: ScheduleReqType): Promise<ScheduleType[]> => {
export const createNewSchedule = async (newSchedule: ScheduleReqType): Promise<ScheduleType[]> => {
try {
const res = await fetchApi.post(`/api/schedules/${teamId}`, { ...newSchedule });
const res = await fetchApi.post('/api/schedules', { ...newSchedule });
if (res.status === 409) throw new Error('😣 일정 추가에 실패하였습니다!');
else if (res.status === 403) throw new Error('😣 권한이 없습니다!');
const data = await res.json();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Calendar/CalendarHeader/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Container = styled.header`
width: 100%;
height: 2.5rem;
background-color: ${ColorCode.BACKGROUND1};
padding: 0 1rem 0 0;
padding: 0 1rem;
box-sizing: border-box;
border-bottom: solid 1px ${ColorCode.LINE2};
svg {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Calendar/CalendarModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const CalendarModal: React.FC<Props> = ({
repeat_option: selectedRepeat,
repeat_count: isNum(selectedRepeatCount) ? selectedRepeatCount : 1,
content: contentRef.current?.value,
team_id: teamId,
};
};

Expand All @@ -90,7 +91,7 @@ const CalendarModal: React.FC<Props> = ({
const newScheduleData = getScheduleData();
if (validateSchedule(newScheduleData)) {
if (checkModalMode('create')) {
const newSchedules = await createNewSchedule(teamId, newScheduleData);
const newSchedules = await createNewSchedule(newScheduleData);
addSchedule(newSchedules);
} else {
newScheduleData.schedule_id = scheduleId;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface ScheduleReqType {
repeat_count: number;
content?: string;
color: number;
team_id: number;
}

export interface TimeType {
Expand Down

0 comments on commit 0e99cb3

Please sign in to comment.