erp-platform/ui/src/views/classroom/Dashboard.tsx

30 lines
989 B
TypeScript
Raw Normal View History

2025-08-26 08:39:09 +00:00
import { useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import { useClassroomLogic } from '@/utils/hooks/useClassroomLogic'
import { ROUTES_ENUM } from '@/routes/route.constant'
2025-08-26 14:57:09 +00:00
import { Container } from '@/components/shared'
import { RoleSelector } from '@/components/classroom/RoleSelector'
import RoomDetail from './RoomDetail'
2025-08-26 08:39:09 +00:00
2025-08-26 14:57:09 +00:00
const Dashboard: React.FC = () => {
2025-08-26 11:08:57 +00:00
const { roleState, currentClass, handleRoleSelect, handleLeaveClass } = useClassroomLogic()
2025-08-26 08:39:09 +00:00
const navigate = useNavigate()
2025-08-26 11:08:57 +00:00
// Eğer dashboard seçildiyse otomatik yönlendirme yap
2025-08-26 08:39:09 +00:00
useEffect(() => {
2025-08-26 08:59:57 +00:00
if (roleState === 'dashboard') {
2025-08-26 08:39:09 +00:00
navigate(ROUTES_ENUM.protected.admin.classroom.classes, { replace: true })
}
2025-08-26 08:59:57 +00:00
}, [roleState, navigate])
2025-08-26 08:39:09 +00:00
2025-08-26 14:57:09 +00:00
return (
<Container>
{roleState === 'role-selection' && <RoleSelector onRoleSelect={handleRoleSelect} />}
2025-08-26 11:08:57 +00:00
2025-08-26 14:57:09 +00:00
{roleState === 'classroom' && currentClass && <RoomDetail />}
</Container>
)
2025-08-26 08:39:09 +00:00
}
2025-08-26 14:57:09 +00:00
export default Dashboard