11import React from 'react' ;
2- import { Link } from 'react-router-dom' ;
2+ import { Link , Outlet } from 'react-router-dom' ;
33import { useSelector , useDispatch } from 'react-redux' ;
4- import { setSelected } from '../../store/actions' ;
4+ import { setSelected , setHistory } from '../../store/actions' ;
55import Course from '../../Types/course' ;
6- import StudentsList from './StudentsList' ;
7- import SessionBtn from './SessionBtn' ;
8- import RegisterBtn from './RegisterBtn' ;
96import { ReactComponent as CloseBtn } from '../../Assets/window-close-regular.svg' ;
7+ import ClassDashboard from './ClassDashboard' ;
8+ import Overview from '../Calendar/Overview' ;
109
1110const headerStyle =
1211 'bg-black text-white flex flex-row justify-between items-center content-center p-8 h-20 mb-4 text-3xl' ;
13- const viewStyle =
14- 'flex flex-col justify-start items-left content-center pt-4 w-1/2 pl-4 h-full' ;
1512
1613const ClassView : React . FC = ( ) => {
1714 const dispatch = useDispatch ( ) ;
1815 const course = useSelector (
1916 ( state : { selectedCourse : Course | null } ) => state . selectedCourse
2017 ) ;
18+ const history = useSelector ( ( state : { history : boolean } ) => state . history ) ;
2119 const courseId = course ?. id ;
2220
21+ const link = history
22+ ? `/homepage/classes/${ courseId } `
23+ : `/homepage/classes/${ courseId } /history` ;
24+
2325 if ( course && courseId ) {
2426 return (
2527 < section className = "h-screen flex flex-col justify-start w-3/4" >
@@ -31,10 +33,16 @@ const ClassView: React.FC = () => {
3133 </ button >
3234 </ Link >
3335 </ div >
34- < div className = { viewStyle } >
35- < RegisterBtn courseId = { courseId } />
36- < SessionBtn courseId = { courseId } />
37- < StudentsList courseId = { courseId } />
36+ < div >
37+ < Link to = { link } >
38+ < h3
39+ className = "text-lg"
40+ onClick = { ( ) => dispatch ( setHistory ( history ) ) }
41+ >
42+ { history ? 'back to dashboard' : 'attendance history' }
43+ </ h3 >
44+ </ Link >
45+ { history ? < Outlet /> : < ClassDashboard courseId = { courseId } /> }
3846 </ div >
3947 </ section >
4048 ) ;
0 commit comments