{"size": 3301, "ext": "js", "max_stars_repo_path": "client/src/teacher/containers/TeacherApp.js", "max_stars_repo_name": "rutgerssoftwareengineering/Minerva-Web-App", "max_stars_repo_stars_event_min_datetime": "2019-04-21T23:18:57.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-21T23:18:57.000Z", "max_issues_repo_path": "client/src/teacher/containers/TeacherApp.js", "max_issues_repo_name": "rutgerssoftwareengineering/Minerva-Web-App", "max_issues_repo_issues_event_min_datetime": "2021-05-08T10:27:01.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-08T10:34:44.000Z", "max_forks_repo_path": "client/src/teacher/containers/TeacherApp.js", "max_forks_repo_name": "rutgerssoftwareengineering/Minerva-Web-App", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 38.3837209302, "max_line_length": 127, "alphanum_fraction": 0.5873977583}
import React, { Component } from 'react';
import {Router, Route} from 'react-router-dom';
import { Provider } from 'react-redux';
import store from '../store'
import Login from '../../Login'
import Home from './Home';
import QuizRouter from './QuizRouter';
import GradesContainer from '../components/Gradebook';
import axios from 'axios'
import PersistentDrawerLeft from './Drawio'
import CreateQuiz from '../quiz_components/CreateQuiz';
import CreateAnnouncement from '../components/CreateAnnouncement';
import Hub from '../components/Hub';
import VideoPage from './VideoPage';
import ViewAnnouncement from '../components/ViewAnnouncement';
import history from '../../History';
import ForumContainer from './ForumContainer'
import RegisterClass from '../components/RegisterClass'
import ManageFiles from './manageFiles'
import Cookies from 'universal-cookie';
const cookies = new Cookies();


class TeacherApp extends Component {
    constructor(props){
        super(props)
        this.state={
            files: [],
            isOpen: false
    }}
    componentWillMount() {
        this.getFiles();
        this.getFeedbackFromDb()
    }
    toggleRegister = () => {
        this.setState({
          isOpen: !this.state.isOpen
        })
    }
    getFiles() {
        fetch('/api/getFiles')
          .then(res => res.json())
          .then(files => {
            if (files.message) {
              console.log('No Files');
              this.setState({ files: [] })
            } else {
              this.setState({ files: files})
            }
          });
    }
    getFeedbackFromDb = () => {
      axios.get("http://localhost:3001/api/getFeedback"/*, {params: {class:cookies.get('currentClass')}}*/)
      .then(res => {
          const feedback = res.data.data
          console.log(feedback)
          cookies.set('feedback', feedback, {path: '/'})
    })}
    render(){
    return(
        <Provider store = {store}>
            <Router history={history}>
                <React.Fragment>
                <PersistentDrawerLeft unmountIt={this.props.unmountIt} toggle={this.toggleRegister}/>               
                <Route exact path='/' component={Login} />
                <Route exact path='/home' component={Home} />
                <Route path='/forum' render={routerProps => <ForumContainer {...routerProps}/> }/>
                <Route exact path='/quizzes' component={QuizRouter} />
                <Route exact path='/createQuiz' component={CreateQuiz} />
                <Route exact path='/hub' component={Hub} />
                <Route exact path='/grades' component={GradesContainer} />
                <Route exact path='/announcements/new' component={CreateAnnouncement} />
                <Route exact path='/announcements/view' component={ViewAnnouncement} />
                <Route path='/manageFiles' render={(routerProps) => <ManageFiles {...routerProps} files={this.state.files}/>}/>
                <Route path='/officehours' component={VideoPage}/>
                <RegisterClass className='navButton'show={this.state.isOpen} onClose={this.toggleRegister}>
                        Register a new class
                </RegisterClass>
                </React.Fragment>    
            </Router>
        </Provider>
    )}
};

export default TeacherApp;
