diff --git a/src/components/courses/ManageCoursePage.js b/src/components/courses/ManageCoursePage.js new file mode 100644 index 0000000..a0c591a --- /dev/null +++ b/src/components/courses/ManageCoursePage.js @@ -0,0 +1,59 @@ +import React from "react"; +import { connect } from "react-redux"; +import { loadCourses } from "../../redux/actions/courseActions"; +import { loadAuthors } from "../../redux/actions/authorActions"; +import PropTypes from "prop-types"; +import { bindActionCreators } from "redux"; + +class ManageCoursePage extends React.Component { + componentDidMount() { + const { courses, authors, actions } = this.props; + + if (courses.length === 0) { + actions.loadCourses().catch((error) => { + alert("Loading courses failed. " + error); + }); + } + + if (authors.length === 0) { + actions.loadAuthors().catch((error) => { + alert("Loading authors failed. " + error); + }); + } + } + + render() { + return ( + <> +