2025-08-26 08:39:09 +00:00
|
|
|
import { useEffect } from 'react'
|
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
|
import { RoleSelector } from './RoleSelector'
|
|
|
|
|
import { useClassroomLogic } from '@/utils/hooks/useClassroomLogic'
|
|
|
|
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
|
|
|
|
import { Room } from './Room'
|
|
|
|
|
|
|
|
|
|
export function Dashboard() {
|
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 11:08:57 +00:00
|
|
|
// Render edilecek içerik
|
|
|
|
|
const renderContent = () => {
|
|
|
|
|
switch (roleState) {
|
|
|
|
|
case 'role-selection':
|
|
|
|
|
return <RoleSelector onRoleSelect={handleRoleSelect} />
|
|
|
|
|
|
|
|
|
|
case 'classroom':
|
|
|
|
|
return currentClass ? (
|
|
|
|
|
<Room classSession={currentClass} onLeaveClass={handleLeaveClass} />
|
|
|
|
|
) : null
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return null
|
|
|
|
|
}
|
2025-08-26 08:39:09 +00:00
|
|
|
}
|
2025-08-26 11:08:57 +00:00
|
|
|
|
|
|
|
|
return renderContent()
|
2025-08-26 08:39:09 +00:00
|
|
|
}
|