fix: 헤더 live버튼 제거, 강의생성 날짜 확인 적용

This commit is contained in:
정기영 2024-08-13 09:53:29 +09:00
parent 0c000cd1b8
commit 6b4b28ffd2
2 changed files with 19 additions and 9 deletions

View File

@ -26,14 +26,6 @@ export default function Header() {
/>
</Link>
</li>
<li>
<Link
to={'/live/1'}
target="_blank"
>
live
</Link>
</li>
</ul>
<ul className={styles.group}>
{userType && (

View File

@ -38,8 +38,21 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
if (initialValues.time) timeRef.current.value = initialValues.time;
}, [initialValues]);
console.log(startDateRef.current.value, endDateRef.current.value);
const handleSubmit = async (e) => {
e.preventDefault();
const startDate = new Date(startDateRef.current.value);
const endDate = new Date(endDateRef.current.value);
if (startDate > endDate) {
window.alert('시작 날짜가 끝나는 날짜보다 더 늦습니다.');
return;
}
if (startDate <= new Date(Date.now() - 86400000)) {
window.alert('시작 날짜는 오늘 이후여야 합니다.');
return;
}
const lectureObject = {
title: titleRef.current.value,
@ -49,7 +62,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
endDate: new Date(endDateRef.current.value).toISOString(),
time: timeRef.current.value,
};
console.log(lectureObject);
const formData = new FormData();
formData.append('lectureCreateRequest', new Blob([JSON.stringify(lectureObject)], { type: 'application/json' }));
@ -84,6 +97,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
maxLength={50}
type="text"
placeholder="강의명을 입력하세요"
required
/>
</div>
<div className={styles.inputField}>
@ -91,6 +105,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
<textarea
ref={descriptionRef}
className={styles.textarea}
maxLength={2000}
placeholder="강의에 대한 설명을 입력하세요"
></textarea>
</div>
@ -99,6 +114,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
<textarea
ref={planRef}
className={styles.textarea}
maxLength={2000}
placeholder="강의 계획을 입력하세요"
></textarea>
</div>
@ -110,6 +126,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
className={styles.input}
ref={startDateRef}
type="date"
required
/>
<span className={styles.label}>부터</span>
</div>
@ -118,6 +135,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
className={styles.input}
ref={endDateRef}
type="date"
required
/>
<span className={styles.label}>까지</span>
</div>