feat: DefaultStudentPage 추가

This commit is contained in:
정기영 2024-08-05 10:52:33 +09:00
parent e3667f1b73
commit 3ef118ca0f
4 changed files with 28 additions and 4 deletions

View File

@ -47,8 +47,7 @@ export function useAuth() {
const logout = () => {
return instance
.post(`${API_URL}/user/logout`)
.then((response) => {
console.log(response);
.then(() => {
setUserType(null);
setToken(null);
})

View File

@ -0,0 +1,24 @@
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 ?? [];
return (
<MaxWidthLayout>
<ClassGrid title="전체 강의">
{allClasses.map?.((lecture) => (
<ClassCard
key={lecture.id}
path={`/lecture/${lecture.id}/info`}
>
{lecture.title}
</ClassCard>
))}
</ClassGrid>
</MaxWidthLayout>
);
}

View File

@ -0,0 +1 @@
export { default } from './DefaultHomePage';

View File

@ -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 />;
}
}