Merge branch 'frontend' into 'fe/livekit'
# Conflicts: # frontend/src/hooks/api/useAuth.js # frontend/src/pages/MyInfoChangePage/MyInfoChangePage.jsx # frontend/src/pages/PasswordChangePage/PasswordChangePage.jsx
This commit is contained in:
commit
3ed79652bd
@ -1,13 +1,17 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import styles from './ClassCard.module.css';
|
||||
|
||||
export default function ClassCard({ path, children }) {
|
||||
export default function ClassCard({ img, path, children }) {
|
||||
return (
|
||||
<Link
|
||||
to={path}
|
||||
className={styles.card}
|
||||
>
|
||||
<div className={styles.thumbnail} />
|
||||
<img
|
||||
src={'img'}
|
||||
alt="강의 이미지"
|
||||
className={styles.thumbnail}
|
||||
/>
|
||||
<div>{children}</div>
|
||||
</Link>
|
||||
);
|
||||
|
@ -17,8 +17,8 @@ export default function LectureLayout() {
|
||||
const { data } = useLectureInfo(lectureId);
|
||||
const lecture = data?.data;
|
||||
const userType = useBoundStore((state) => state.userType);
|
||||
const handleDelete = () => {
|
||||
lectureDelete(lectureId);
|
||||
const handleDelete = async () => {
|
||||
await lectureDelete(lectureId);
|
||||
navigate('..');
|
||||
};
|
||||
const lectureData = {
|
||||
@ -29,7 +29,7 @@ export default function LectureLayout() {
|
||||
endDate: lecture.endDate,
|
||||
time: lecture.time,
|
||||
};
|
||||
console.log(lectureData);
|
||||
|
||||
return (
|
||||
<>
|
||||
<LectureHeader
|
||||
|
26
frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx
Normal file
26
frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx
Normal file
@ -0,0 +1,26 @@
|
||||
import { ClassCard } from '../../components/ClassCard';
|
||||
import { ClassGrid } from '../../components/ClassGrid';
|
||||
import { MaxWidthLayout } from '../../components/Layout';
|
||||
import { useLectures } from '../../hooks/api/useLectures';
|
||||
|
||||
export default function StudentHomePage() {
|
||||
const { data: allLectures } = useLectures();
|
||||
const allClasses = allLectures?.data ?? [];
|
||||
console.log(allClasses);
|
||||
|
||||
return (
|
||||
<MaxWidthLayout>
|
||||
<ClassGrid title="전체 강의">
|
||||
{allClasses.map?.((lecture) => (
|
||||
<ClassCard
|
||||
key={lecture.id}
|
||||
path={`/lecture/${lecture.id}/info`}
|
||||
img={lecture.image}
|
||||
>
|
||||
{lecture.title}
|
||||
</ClassCard>
|
||||
))}
|
||||
</ClassGrid>
|
||||
</MaxWidthLayout>
|
||||
);
|
||||
}
|
1
frontend/src/pages/DefaultHomePage/index.js
Normal file
1
frontend/src/pages/DefaultHomePage/index.js
Normal file
@ -0,0 +1 @@
|
||||
export { default } from './DefaultHomePage';
|
@ -1,16 +1,16 @@
|
||||
import useBoundStore from '../../store';
|
||||
import StudentHomePage from '../StudentHomePage/StudentHomePage';
|
||||
import TeacherHomePage from '../TeacherHomePage';
|
||||
import DefaultHomePage from '../DefaultHomePage';
|
||||
|
||||
export default function HomePage() {
|
||||
const userType = useBoundStore((state) => state.userType);
|
||||
// TODO: 비로그인 페이지 추가하기
|
||||
switch (userType) {
|
||||
case 'student':
|
||||
return <StudentHomePage />;
|
||||
case 'teacher':
|
||||
return <TeacherHomePage />;
|
||||
default:
|
||||
return <StudentHomePage />;
|
||||
return <DefaultHomePage />;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { LectureForm } from '../../components/LectureForm';
|
||||
import { useLectureCreate } from '../../hooks/api/useLectureCreate';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default function LectureCreatePage() {
|
||||
const navigate = useNavigate();
|
||||
const { lectureCreate } = useLectureCreate();
|
||||
|
||||
const handleSubmit = async (lectureObject, imageFile) => {
|
||||
@ -12,8 +14,9 @@ export default function LectureCreatePage() {
|
||||
formData.append('image', imageFile);
|
||||
}
|
||||
|
||||
const response = await lectureCreate(formData);
|
||||
console.log(response?.data);
|
||||
await lectureCreate(formData).then(() => {
|
||||
navigate('..');
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -1,5 +1,17 @@
|
||||
import { InfoEditForm } from '../../components/InfoEditForm';
|
||||
import { useAuth } from '../../hooks/api/useAuth';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default function MyInfoChangePage() {
|
||||
return <InfoEditForm />;
|
||||
const navigate = useNavigate();
|
||||
const { updateInfo } = useAuth();
|
||||
|
||||
const handleSubmit = async (e, username, useremail) => {
|
||||
e.preventDefault();
|
||||
await updateInfo(username, useremail)
|
||||
.then(() => navigate('/'))
|
||||
.catch((err) => console.log(err));
|
||||
};
|
||||
|
||||
return <InfoEditForm onSubmit={handleSubmit} />;
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
import { PasswordChangeForm } from '../../components/PasswordChangeForm';
|
||||
import { useAuth } from '../../hooks/api/useAuth';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default function PasswordChangePage() {
|
||||
return <PasswordChangeForm />;
|
||||
const navigate = useNavigate();
|
||||
const { updatePassword } = useAuth();
|
||||
const handleSubmit = async (currentPw, newPw, newPwCheck) => {
|
||||
await updatePassword(currentPw, newPw, newPwCheck).then(() => navigate('/'));
|
||||
};
|
||||
return <PasswordChangeForm onSubmit={handleSubmit} />;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ export default function StudentHomePage() {
|
||||
<ClassCard
|
||||
key={lecture.id}
|
||||
path={`/lecture/${lecture.id}`}
|
||||
img={lecture.image}
|
||||
>
|
||||
{lecture.title}
|
||||
</ClassCard>
|
||||
@ -29,6 +30,7 @@ export default function StudentHomePage() {
|
||||
<ClassCard
|
||||
key={lecture.id}
|
||||
path={`/lecture/${lecture.id}/info`}
|
||||
img={lecture.image}
|
||||
>
|
||||
{lecture.title}
|
||||
</ClassCard>
|
||||
|
@ -6,6 +6,7 @@ import { useMyLectures } from '../../hooks/api/useMyLectures';
|
||||
export default function TeacherHomePage() {
|
||||
const { data: myLectures } = useMyLectures();
|
||||
const onGoingClasses = myLectures?.data ?? [];
|
||||
console.log(onGoingClasses);
|
||||
// TODO: 새 강의 만들기 스타일 추가, 추가 기능 필요시 추가
|
||||
return (
|
||||
<MaxWidthLayout>
|
||||
@ -14,6 +15,7 @@ export default function TeacherHomePage() {
|
||||
<ClassCard
|
||||
key={lecture.id}
|
||||
path={`/lecture/${lecture.id}`}
|
||||
img={lecture.image}
|
||||
>
|
||||
{lecture.title}
|
||||
</ClassCard>
|
||||
|
Loading…
Reference in New Issue
Block a user