Newer
Older
import React, { Component } from "react";
import Nav from 'react-bootstrap/Nav';
import Navbar from 'react-bootstrap/Navbar';
import UserSessionWidget from "../user/components/userSessionWidget";
import { LinkContainer } from 'react-router-bootstrap';
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as authenticationActions from '../authentication/state/AuthenticationActions'
import * as userManagementActions from '../user/state/UserManagementActions';
import * as degreeCourseManagementActions from '../degreeCourse/state/DegreeCourseManagementActions';
import * as applicationManagementActions from '../degreeCourseApplication/state/ApplicationManagementActions';
return {
accessToken: state.AuthenticationReducer.accessToken,
isAdmin: state.AuthenticationReducer.isAdmin,
user: state.AuthenticationReducer.user
constructor(props) {
super(props)
this.handleUserManagementButtonAction = this.handleUserManagementButtonAction.bind(this);
this.handleDegreeCourseManagementButtonAction = this.handleDegreeCourseManagementButtonAction.bind(this);
this.handleApplicationManagementButtonAction = this.handleApplicationManagementButtonAction.bind(this);
async handleApplicationManagementButtonAction() {
if (this.props.isAdmin) {
const { showAllApplications } = this.props
await showAllApplications(this.props.accessToken);
} else {
const { showMyApplications } = this.props
await showMyApplications(this.props.accessToken);
}
}
async handleUserManagementButtonAction() {
const { showAllUsers } = this.props;
await showAllUsers(this.props.accessToken)
}
async handleDegreeCourseManagementButtonAction() {
const { showAllDegreeCourses } = this.props;
await showAllDegreeCourses(this.props.accessToken)
}
<>
<LinkContainer to="/userManagement" id="OpenUserManagementPageButton" onClick={this.handleUserManagementButtonAction}>
<Nav.Link>User-Management</Nav.Link>
</LinkContainer>
<LinkContainer to="/degreeCourseManagement" id="OpenDegreeCourseManagementPageButton" onClick={this.handleDegreeCourseManagementButtonAction}>
<Nav.Link>DegreeCourse-Management</Nav.Link>
</LinkContainer>
<LinkContainer to="/degreeCourseApplicationManagement" id="OpenDegreeCourseApplicationManagementPageButton" onClick={this.handleApplicationManagementButtonAction}>
<Nav.Link>Studienbewerbung-Management</Nav.Link>
</LinkContainer>
</>
} else if (this.props.user) {
OpenManagementPageButtons =
<>
<LinkContainer to="/degreeCourseApplicationManagement" id="OpenDegreeCourseApplicationManagementPageButton" onClick={this.handleApplicationManagementButtonAction}>
<Nav.Link>Studienbewerbung-Management</Nav.Link>
</LinkContainer>
<LinkContainer to="/degreeCourseManagement" id="OpenDegreeCourseManagementPageButton" onClick={this.handleDegreeCourseManagementButtonAction}>
<Nav.Link>DegreeCourse-List</Nav.Link>
</LinkContainer>
<Container style={{ margin: 0 }}>
<LinkContainer to="/" id="OpenStartPageButton">
<Navbar.Brand>BHT</Navbar.Brand>
</LinkContainer>
<Navbar.Collapse id="basic-navbar-nav" style={{ display: 'flex', flexWrap: 'row', justifyContent: 'space-between', width: '100%' }}>
<LinkContainer to="/" id="OpenStartPageButton">
<Nav.Link>Home</Nav.Link>
</LinkContainer>
</Nav>
<UserSessionWidget />
</Navbar.Collapse>
</Container>
const mapDispatchToProps = dispatch => bindActionCreators({
authenticateUserAction: authenticationActions.authenticateUser,
showAllUsers: userManagementActions.displayUsers,
showAllDegreeCourses: degreeCourseManagementActions.displayDegreeCourses,
showAllApplications: applicationManagementActions.displayAllApplications,
showMyApplications: applicationManagementActions.displayMyApplications