Merge branch 'FE/Fix' into 'frontend'

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

See merge request s11-webmobile1-sub2/S11P12A701!180
This commit is contained in:
조민우 2024-08-13 09:58:58 +09:00
commit 7651ac24f5
2 changed files with 19 additions and 9 deletions

View File

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

View File

@ -38,8 +38,21 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
if (initialValues.time) timeRef.current.value = initialValues.time; if (initialValues.time) timeRef.current.value = initialValues.time;
}, [initialValues]); }, [initialValues]);
console.log(startDateRef.current.value, endDateRef.current.value);
const handleSubmit = async (e) => { const handleSubmit = async (e) => {
e.preventDefault(); 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 = { const lectureObject = {
title: titleRef.current.value, title: titleRef.current.value,
@ -49,7 +62,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
endDate: new Date(endDateRef.current.value).toISOString(), endDate: new Date(endDateRef.current.value).toISOString(),
time: timeRef.current.value, time: timeRef.current.value,
}; };
console.log(lectureObject);
const formData = new FormData(); const formData = new FormData();
formData.append('lectureCreateRequest', new Blob([JSON.stringify(lectureObject)], { type: 'application/json' })); 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} maxLength={50}
type="text" type="text"
placeholder="강의명을 입력하세요" placeholder="강의명을 입력하세요"
required
/> />
</div> </div>
<div className={styles.inputField}> <div className={styles.inputField}>
@ -91,6 +105,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
<textarea <textarea
ref={descriptionRef} ref={descriptionRef}
className={styles.textarea} className={styles.textarea}
maxLength={2000}
placeholder="강의에 대한 설명을 입력하세요" placeholder="강의에 대한 설명을 입력하세요"
></textarea> ></textarea>
</div> </div>
@ -99,6 +114,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
<textarea <textarea
ref={planRef} ref={planRef}
className={styles.textarea} className={styles.textarea}
maxLength={2000}
placeholder="강의 계획을 입력하세요" placeholder="강의 계획을 입력하세요"
></textarea> ></textarea>
</div> </div>
@ -110,6 +126,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
className={styles.input} className={styles.input}
ref={startDateRef} ref={startDateRef}
type="date" type="date"
required
/> />
<span className={styles.label}>부터</span> <span className={styles.label}>부터</span>
</div> </div>
@ -118,6 +135,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
className={styles.input} className={styles.input}
ref={endDateRef} ref={endDateRef}
type="date" type="date"
required
/> />
<span className={styles.label}>까지</span> <span className={styles.label}>까지</span>
</div> </div>