Classroom düzenlemesi
This commit is contained in:
parent
e4544ad1e7
commit
bfbdbced7d
4 changed files with 15 additions and 20 deletions
|
|
@ -2,13 +2,12 @@ import { useEffect } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { RoleSelector } from './RoleSelector'
|
import { RoleSelector } from './RoleSelector'
|
||||||
import { useClassroomLogic } from '@/utils/hooks/useClassroomLogic'
|
import { useClassroomLogic } from '@/utils/hooks/useClassroomLogic'
|
||||||
import { useStoreState } from '@/store/store'
|
|
||||||
import { ROUTES_ENUM } from '@/routes/route.constant'
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
||||||
import { Room } from './Room'
|
import { Room } from './Room'
|
||||||
|
|
||||||
export function Dashboard() {
|
export function Dashboard() {
|
||||||
const {
|
const {
|
||||||
appState,
|
roleState,
|
||||||
currentClass,
|
currentClass,
|
||||||
handleRoleSelect,
|
handleRoleSelect,
|
||||||
handleJoinClass,
|
handleJoinClass,
|
||||||
|
|
@ -18,20 +17,18 @@ export function Dashboard() {
|
||||||
handleDeleteClass,
|
handleDeleteClass,
|
||||||
} = useClassroomLogic()
|
} = useClassroomLogic()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { user } = useStoreState((state) => state.auth)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (appState === 'dashboard') {
|
if (roleState === 'dashboard') {
|
||||||
navigate(ROUTES_ENUM.protected.admin.classroom.classes, { replace: true })
|
navigate(ROUTES_ENUM.protected.admin.classroom.classes, { replace: true })
|
||||||
}
|
}
|
||||||
}, [appState, navigate])
|
}, [roleState, navigate])
|
||||||
|
|
||||||
if (appState === 'role-selection') {
|
if (roleState === 'role-selection') {
|
||||||
return <RoleSelector onRoleSelect={handleRoleSelect} />
|
return <RoleSelector onRoleSelect={handleRoleSelect} />
|
||||||
} else if (appState === 'dashboard') {
|
} else if (roleState === 'dashboard') {
|
||||||
// Yönlendirme yapılacağı için burada içerik render etmiyoruz
|
|
||||||
return null
|
return null
|
||||||
} else if (appState === 'classroom' && currentClass) {
|
} else if (roleState === 'classroom' && currentClass) {
|
||||||
return <Room classSession={currentClass} onLeaveClass={handleLeaveClass} />
|
return <Room classSession={currentClass} onLeaveClass={handleLeaveClass} />
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { motion } from 'framer-motion'
|
import { motion } from 'framer-motion'
|
||||||
import { FaGraduationCap, FaUserCheck, FaEye } from 'react-icons/fa'
|
import { FaGraduationCap, FaUserCheck, FaEye } from 'react-icons/fa'
|
||||||
|
import { Role } from '@/proxy/classroom/models'
|
||||||
|
|
||||||
interface RoleSelectorProps {
|
interface RoleSelectorProps {
|
||||||
onRoleSelect: (role: 'teacher' | 'student' | 'observer') => void
|
onRoleSelect: (role: Role) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RoleSelector: React.FC<RoleSelectorProps> = ({ onRoleSelect }) => {
|
export const RoleSelector: React.FC<RoleSelectorProps> = ({ onRoleSelect }) => {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4">
|
<div className="min-h-screen flex items-center justify-center p-4">
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 20 }}
|
initial={{ opacity: 0, y: 20 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
className="text-center w-full max-w-4xl"
|
className="text-center w-full max-w-4xl"
|
||||||
>
|
>
|
||||||
<h1 className="text-2xl sm:text-3xl lg:text-4xl font-bold text-gray-800 mb-4">
|
|
||||||
Sanal Sınıf Sistemine Hoş Geldiniz
|
|
||||||
</h1>
|
|
||||||
<p className="text-lg sm:text-xl text-gray-600 mb-8 sm:mb-12">Lütfen rolünüzü seçin</p>
|
<p className="text-lg sm:text-xl text-gray-600 mb-8 sm:mb-12">Lütfen rolünüzü seçin</p>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 sm:gap-8">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 sm:gap-8">
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
export type RoleState = 'role-selection' | 'dashboard' | 'classroom'
|
||||||
|
|
||||||
export type Role = 'teacher' | 'student' | 'observer'
|
export type Role = 'teacher' | 'student' | 'observer'
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import { ClassroomDto } from '@/proxy/classroom/models'
|
import { ClassroomDto, Role, RoleState } from '@/proxy/classroom/models'
|
||||||
import { useStoreActions, useStoreState } from '@/store/store'
|
import { useStoreActions, useStoreState } from '@/store/store'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
export type RoleState = 'role-selection' | 'dashboard' | 'classroom'
|
|
||||||
|
|
||||||
export function useClassroomLogic() {
|
export function useClassroomLogic() {
|
||||||
const { user } = useStoreState((state) => state.auth)
|
const { user } = useStoreState((state) => state.auth)
|
||||||
const { setUser } = useStoreActions((actions) => actions.auth.user)
|
const { setUser } = useStoreActions((actions) => actions.auth.user)
|
||||||
|
|
@ -12,7 +10,7 @@ export function useClassroomLogic() {
|
||||||
const [currentClass, setCurrentClass] = useState<ClassroomDto | null>(null)
|
const [currentClass, setCurrentClass] = useState<ClassroomDto | null>(null)
|
||||||
const [allClasses, setAllClasses] = useState<ClassroomDto[]>([])
|
const [allClasses, setAllClasses] = useState<ClassroomDto[]>([])
|
||||||
|
|
||||||
const handleRoleSelect = (role: 'teacher' | 'student' | 'observer') => {
|
const handleRoleSelect = (role: Role) => {
|
||||||
setUser({
|
setUser({
|
||||||
...user,
|
...user,
|
||||||
role,
|
role,
|
||||||
|
|
@ -52,8 +50,8 @@ export function useClassroomLogic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appState: roleState,
|
roleState,
|
||||||
setAppState: setRoleState,
|
setRoleState,
|
||||||
currentClass,
|
currentClass,
|
||||||
setCurrentClass,
|
setCurrentClass,
|
||||||
allClasses,
|
allClasses,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue