diff --git a/front-end/.gitignore b/front-end/.gitignore index 714f38e..f5f2ac9 100644 --- a/front-end/.gitignore +++ b/front-end/.gitignore @@ -25,4 +25,6 @@ dist-ssr .env* -*.pem \ No newline at end of file +*.pem + +vercel* \ No newline at end of file diff --git a/front-end/package.json b/front-end/package.json index 8428f3b..5c0f978 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "prebuild": "node copyCmaps.js && node vercelRewrite.js", + "prebuild": "node copyCmaps.js", "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview" diff --git a/front-end/src/pages/professor/home/modal/CourseModal.tsx b/front-end/src/pages/professor/home/modal/CourseModal.tsx index 5e13a0b..02a3f4e 100644 --- a/front-end/src/pages/professor/home/modal/CourseModal.tsx +++ b/front-end/src/pages/professor/home/modal/CourseModal.tsx @@ -54,6 +54,40 @@ const makeFullUniversity = (university: string) => { return university; }; +const checkScheduleError = (schedules: CourseForm['schedule']): boolean => { + let isScheduleError = false; + + schedules.forEach((schedule, index) => { + if (isScheduleError) return; + + if (schedule.day === '') { + isScheduleError = true; + } + if (!timeRegex.test(schedule.start) || !timeRegex.test(schedule.end)) { + isScheduleError = true; + } + if (schedule.start >= schedule.end) { + isScheduleError = true; + } + + schedules.forEach((otherSchedule, otherIndex) => { + if (isScheduleError) return; + + if (index >= otherIndex) return; + + if ( + schedule.day === otherSchedule.day && + schedule.start < otherSchedule.end && + schedule.end > otherSchedule.start + ) { + isScheduleError = true; + } + }); + }); + + return isScheduleError; +}; + const checkFormError = ( courseError: CourseError, courseForm: CourseForm @@ -77,22 +111,7 @@ const checkFormError = ( return true; } - let isScheduleError = false; - courseForm.schedule.forEach((schedule) => { - if (isScheduleError) return; - - if (schedule.day === '') { - isScheduleError = true; - } - if (!timeRegex.test(schedule.start) || !timeRegex.test(schedule.end)) { - isScheduleError = true; - } - if (schedule.start >= schedule.end) { - isScheduleError = true; - } - }); - - return isScheduleError; + return checkScheduleError(courseForm.schedule); }; const CourseModal = ({ course, onSubmit, onClose }: CourseModalProps) => { diff --git a/front-end/src/pages/professor/home/modal/components/TimeInput.tsx b/front-end/src/pages/professor/home/modal/components/TimeInput.tsx index 81dc028..7156398 100644 --- a/front-end/src/pages/professor/home/modal/components/TimeInput.tsx +++ b/front-end/src/pages/professor/home/modal/components/TimeInput.tsx @@ -37,11 +37,12 @@ const TimeInput = ({ time, setTime }: TimeInputProps) => { setLocalHour('00'); setTime(`00:${localMinute}`); } else if (parseInt(inputHour) > 23) { + setLocalHour('23'); setTime(`23:${localMinute}`); } else { - setTime( - `${parseInt(inputHour).toString().padStart(2, '0')}:${localMinute}` - ); + const parsedHour = parseInt(inputHour).toString().padStart(2, '0'); + setLocalHour(parsedHour); + setTime(`${parsedHour}:${localMinute}`); } }} /> @@ -64,11 +65,14 @@ const TimeInput = ({ time, setTime }: TimeInputProps) => { setLocalMinute('00'); setTime(`${localHour}:00`); } else if (parseInt(inputMinute) > 59) { + setLocalMinute('59'); setTime(`${localHour}:59`); } else { - setTime( - `${localHour}:${parseInt(inputMinute).toString().padStart(2, '0')}` - ); + const parsedMinute = parseInt(inputMinute) + .toString() + .padStart(2, '0'); + setLocalMinute(parsedMinute); + setTime(`${localHour}:${parsedMinute}`); } }} /> diff --git a/front-end/vercel.json b/front-end/vercel.json deleted file mode 100644 index c1a7308..0000000 --- a/front-end/vercel.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "rewrites": [ - { - "source": "/api/:path*", - "destination": "VITE_API_URL/:path*" - }, - { - "source": "/:path((?!api).*)", - "destination": "/index.html" - } - ] -} diff --git a/front-end/vercelRewrite.js b/front-end/vercelRewrite.js deleted file mode 100644 index 88bd9f2..0000000 --- a/front-end/vercelRewrite.js +++ /dev/null @@ -1,29 +0,0 @@ -// vercel-prebuild.js -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -const apiUrl = process.env.VITE_API_URL; -if (!apiUrl) { - console.error('Error: VITE_API_URL 환경변수가 설정되어 있지 않습니다.'); - process.exit(1); -} - -const vercelJsonPath = path.join(__dirname, 'vercel.json'); - -try { - // vercel.json 파일 읽기 - const fileContent = fs.readFileSync(vercelJsonPath, 'utf8'); - - // 파일 내의 모든 "VITE_API_URL" 문자열을 실제 환경변수 값으로 치환 - const updatedContent = fileContent.replace(/VITE_API_URL/g, apiUrl); - - // 치환된 내용을 다시 vercel.json 파일에 기록 - fs.writeFileSync(vercelJsonPath, updatedContent, 'utf8'); - console.log('vercel.json 파일이 성공적으로 업데이트되었습니다.'); -} catch (error) { - console.error('vercel.json 파일 처리 중 에러 발생:', error); - process.exit(1); -}