feat: 수강신청 중(onPending) 시 수강 신청을 막는 기능 추가

This commit is contained in:
정기영 2024-08-06 10:42:30 +09:00
parent 65567379b2
commit 48863c4d11
3 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import styles from './ClassInfo.module.css'; import styles from './ClassInfo.module.css';
export default function ClassInfo({ classTerm, classTime, onSubmit }) { export default function ClassInfo({ classTerm, classTime, onPending = false, onSubmit }) {
return ( return (
<div className={styles.classInfo}> <div className={styles.classInfo}>
<div className={styles.title}>수업정보</div> <div className={styles.title}>수업정보</div>
@ -17,8 +17,9 @@ export default function ClassInfo({ classTerm, classTime, onSubmit }) {
<button <button
onClick={onSubmit} onClick={onSubmit}
className={styles.button} className={styles.button}
disabled={onPending}
> >
수강신청 {onPending ? '수강신청 중' : '수강신청'}
</button> </button>
</div> </div>
); );

View File

@ -55,3 +55,11 @@
color: var(--on-primary); color: var(--on-primary);
cursor: pointer; cursor: pointer;
} }
.button:disabled {
border-color: var(--border-color);
background-color: var(--background-tertiary);
color: var(--text-color-tertiary);
cursor: not-allowed;
stroke: var(--text-color-tertiary);
}

View File

@ -16,6 +16,7 @@ export default function LectureInfoPage() {
const endDate = new Date(lectureData.endDate).toLocaleDateString(); const endDate = new Date(lectureData.endDate).toLocaleDateString();
const userType = useBoundStore((state) => state.userType); const userType = useBoundStore((state) => state.userType);
console.log(lectureData); console.log(lectureData);
const onPending = lectureData.status === 'PENDING' ? true : false;
const { lectureRegister } = useLectureRegister(); const { lectureRegister } = useLectureRegister();
const handleSubmit = () => { const handleSubmit = () => {
if (userType === null) { if (userType === null) {
@ -58,6 +59,7 @@ export default function LectureInfoPage() {
classTerm={`${startDate} ~ ${endDate}`} classTerm={`${startDate} ~ ${endDate}`}
classTime={lectureData.time} classTime={lectureData.time}
onSubmit={handleSubmit} onSubmit={handleSubmit}
onPending={onPending}
/> />
</aside> </aside>
</MaxWidthLayout> </MaxWidthLayout>