From bfbdbced7d549106e23dd5dff47b700af3386431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Tue, 26 Aug 2025 11:59:57 +0300 Subject: [PATCH] =?UTF-8?q?Classroom=20d=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/classroom/Dashboard.tsx | 15 ++++++--------- ui/src/components/classroom/RoleSelector.tsx | 8 +++----- ui/src/proxy/classroom/models.ts | 2 ++ ui/src/utils/hooks/useClassroomLogic.ts | 10 ++++------ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/ui/src/components/classroom/Dashboard.tsx b/ui/src/components/classroom/Dashboard.tsx index 1511a174..c946d9eb 100644 --- a/ui/src/components/classroom/Dashboard.tsx +++ b/ui/src/components/classroom/Dashboard.tsx @@ -2,13 +2,12 @@ import { useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { RoleSelector } from './RoleSelector' import { useClassroomLogic } from '@/utils/hooks/useClassroomLogic' -import { useStoreState } from '@/store/store' import { ROUTES_ENUM } from '@/routes/route.constant' import { Room } from './Room' export function Dashboard() { const { - appState, + roleState, currentClass, handleRoleSelect, handleJoinClass, @@ -18,20 +17,18 @@ export function Dashboard() { handleDeleteClass, } = useClassroomLogic() const navigate = useNavigate() - const { user } = useStoreState((state) => state.auth) useEffect(() => { - if (appState === 'dashboard') { + if (roleState === 'dashboard') { navigate(ROUTES_ENUM.protected.admin.classroom.classes, { replace: true }) } - }, [appState, navigate]) + }, [roleState, navigate]) - if (appState === 'role-selection') { + if (roleState === 'role-selection') { return - } else if (appState === 'dashboard') { - // Yönlendirme yapılacağı için burada içerik render etmiyoruz + } else if (roleState === 'dashboard') { return null - } else if (appState === 'classroom' && currentClass) { + } else if (roleState === 'classroom' && currentClass) { return } return null diff --git a/ui/src/components/classroom/RoleSelector.tsx b/ui/src/components/classroom/RoleSelector.tsx index c41da1dd..1905bfef 100644 --- a/ui/src/components/classroom/RoleSelector.tsx +++ b/ui/src/components/classroom/RoleSelector.tsx @@ -1,22 +1,20 @@ import React from 'react' import { motion } from 'framer-motion' import { FaGraduationCap, FaUserCheck, FaEye } from 'react-icons/fa' +import { Role } from '@/proxy/classroom/models' interface RoleSelectorProps { - onRoleSelect: (role: 'teacher' | 'student' | 'observer') => void + onRoleSelect: (role: Role) => void } export const RoleSelector: React.FC = ({ onRoleSelect }) => { return ( -
+
-

- Sanal Sınıf Sistemine Hoş Geldiniz -

Lütfen rolünüzü seçin

diff --git a/ui/src/proxy/classroom/models.ts b/ui/src/proxy/classroom/models.ts index 1ec43a2d..ca252254 100644 --- a/ui/src/proxy/classroom/models.ts +++ b/ui/src/proxy/classroom/models.ts @@ -1,3 +1,5 @@ +export type RoleState = 'role-selection' | 'dashboard' | 'classroom' + export type Role = 'teacher' | 'student' | 'observer' export interface User { diff --git a/ui/src/utils/hooks/useClassroomLogic.ts b/ui/src/utils/hooks/useClassroomLogic.ts index cbe330a0..3f53dd05 100644 --- a/ui/src/utils/hooks/useClassroomLogic.ts +++ b/ui/src/utils/hooks/useClassroomLogic.ts @@ -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 { useState } from 'react' -export type RoleState = 'role-selection' | 'dashboard' | 'classroom' - export function useClassroomLogic() { const { user } = useStoreState((state) => state.auth) const { setUser } = useStoreActions((actions) => actions.auth.user) @@ -12,7 +10,7 @@ export function useClassroomLogic() { const [currentClass, setCurrentClass] = useState(null) const [allClasses, setAllClasses] = useState([]) - const handleRoleSelect = (role: 'teacher' | 'student' | 'observer') => { + const handleRoleSelect = (role: Role) => { setUser({ ...user, role, @@ -52,8 +50,8 @@ export function useClassroomLogic() { } return { - appState: roleState, - setAppState: setRoleState, + roleState, + setRoleState, currentClass, setCurrentClass, allClasses,