import * as React from 'react' ; import { useState } from 'react' ; import { useDispatch , useSelector } from 'react-redux' ; import { useLocation } from 'react-router-dom' ; import { State } from 'reducers' ; import { Option } from '../Select/Select.view' ; import { hideChapterDrawer , hideMenuDrawer } from './Drawer.actions' ; import { ChapterDrawerView , LoginDrawerView } from './Drawer.view' ; export const ChapterDrawer = ( ) => { const dispatch = useDispatch ( ) ; const showingChapter = useSelector ( ( state ) => state . chapterDrawer && state . chapterDrawer . showingChapter ) ; const { pathname } = useLocation ( ) ; let defaultCourse = { name : "Ocean 101" , path : "ocean101" } ; const [ activeCourse , setActiveCourse ] = useState < Option > ( defaultCourse ) ; function changeCourseCallback ( e ) { if ( e . path === 'ocean101' ) { const ocean101 = { name : "Ocean 101" , path : "ocean101" } ; setActiveCourse ( ocean101 ) ; } if ( e . path === 'introToDataDefi' ) { const introToDataDefi = { name : "Intro to Data Defi" , path : "introToDataDefi" } ; setActiveCourse ( introToDataDefi ) ; } if ( e . path === 'ComputeToData' ) { const ComputeToData = { name : "ComputeToData" , path : "ComputeToData" } ; setActiveCourse ( ComputeToData ) ; } } const hideCallback = ( ) => { dispatch ( hideChapterDrawer ( ) ) ; } ; return ( < ChapterDrawerView showingChapters = { showingChapter } hideCallback = { hideCallback } pathname = { pathname } activeCourse = { activeCourse } changeCourseCallback = { changeCourseCallback } / > ) ; } ; export const LoginDrawer = ( ) => { const dispatch = useDispatch ( ) ; const showingMenu = useSelector ( ( state ) => state . loginDrawer && state . loginDrawer . showingMenu ) ; const user = useSelector ( ( state ) => state && state . auth && state . auth . user ) ; const hideCallback = ( ) => { dispatch ( hideMenuDrawer ( ) ) ; } ; function removeAuthUserCallback ( ) { } return ( < LoginDrawerView showingMenu = { showingMenu } user = { user } hideCallback = { hideCallback } removeAuthUserCallback = { removeAuthUserCallback } / > ) ; } ;