Newer
Older
import React, { Component } from "react";
import Form from 'react-bootstrap/Form';
import Button from "react-bootstrap/esm/Button";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as degreeCourseManagementActions from "../../actions/DegreeCourseManagementActions"
const mapStateToProps = state => {
return {
accessToken: state.AuthenticationReducer.accessToken
};
}
constructor(props) {
super(props);
this.state = {
name: '',
shortName: '',
universityName: '',
universityShortName: '',
departmentName: '',
departmentShortName: ''
}
this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
}
handleChange(e) {
const { name, value } = e.target;
this.setState({ [name]: value })
console.log(JSON.stringify(this.state))
}
async handleSubmit(e) {
e.preventDefault();
const { createNewDegreeCourseAction } = this.props;
console.log("degreeCourse sollte angelegt werden")
this.props.goBack()
await createNewDegreeCourseAction(this.state, this.props.accessToken)
}
render() {
return (
<div id="DegreeCourseManagementPageCreateComponent" style={{ display: 'flex', justifyContent: 'center', textAlign: 'left', padding: '2em', background: "#fff", borderRadius: '30px' }}>
<Form style={{ width: '60rem' }}>
<Form.Group className="mb-3">
<Form.Label>Studiengang-Name</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditName" name='name' type="text" placeholder="Bitte Namen des Studiengangs eingeben" onChange={this.handleChange} required />
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Studiengang-Kurzbezeichnung</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditShortName" name="shortName" type="text" placeholder="Bitte Kurzbezeichnung des Studiengangs eingeben" onChange={this.handleChange} />
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Universität-Name</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditUniversityName" name="universityName" type="text" placeholder="Bitte Namen der Universität eingeben" onChange={this.handleChange} />
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Universität-Kurzbezeichnung</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditUniversityShortName" name="universityShortName" type="text" placeholder="Bitte Kurzbezeichnung der Universität eingeben" onChange={this.handleChange} required />
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Fachbereich-Name</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditDepartmentName" name="departmentName" type="text" placeholder="Bitte Namen des Fachbereichs eingeben" onChange={this.handleChange} />
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Fachbereich-Kurzbezeichnung</Form.Label>
<Form.Control id="CreateDegreeCourseComponentEditDepartmentShortName" name="departmentShortName" type="text" placeholder="Bitte Kurzbezeichnung des Fachbereichs eingeben" onChange={this.handleChange} />
</Form.Group>
<Button id="CreateDegreeCourseComponentCreateDegreeCourseButton" variant="primary" type="submit" onClick={this.handleSubmit}>
Anlegen
</Button>
<Button id="OpenDegreeCourseManagementPageListComponentButton" variant="primary" type="submit" onClick={this.props.goBack}>
Studiengang-Liste
</Button>
</Form>
</div >
)
}
}
const mapDispatchToProps = dispatch => bindActionCreators({
createNewDegreeCourseAction: degreeCourseManagementActions.passNewDegreeCourse,
showAllDegreeCourses: degreeCourseManagementActions.displayDegreeCourses
}, dispatch)
const ConnectedDegreeCourseForm = connect(mapStateToProps, mapDispatchToProps)(CreateNewDegreeCourseForm)
export default ConnectedDegreeCourseForm