diff --git a/README.md b/README.md
index c0da9e1..f1db350 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,11 @@
# register
A web app for simplifying the entire registration process. Done as a final project for Olin.js Spring 2017.
+
+## To Run:
+1) Clone this repository and navigate into it.
+1) Run `npm install` to install packages.
+1) Run `npm run build` to build the frontend bundled code from webpack.
+1) Run `npm start` in a separate terminal window to run the backend server locally.
+1) In your browser, go to localhost:3000/ to see the web app.
+
+The backend is run using nodemon, which should restart the server automatically when code changes as long as npm start is running. Similarly, the frontend is bundled using webpack, which should restart the server automatically as long as npm run build is running. Manually restart any of these commands if problems don't update correctly.
\ No newline at end of file
diff --git a/public/stylesheets/semester.css b/public/stylesheets/semester.css
new file mode 100644
index 0000000..c215832
--- /dev/null
+++ b/public/stylesheets/semester.css
@@ -0,0 +1,4 @@
+.semesterheading {
+ font-weight: bold;
+ font-size: 12pt;
+}
\ No newline at end of file
diff --git a/routes/index.js b/routes/index.js
index 05a7802..f50b369 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -42,11 +42,18 @@ router.get('/logout',
// register new user with local strategy
router.post('/register', (req, res) => {
Student.register(new Student({ username: req.body.username }),
- req.body.password, (regErr, account) => {
+ req.body.password, (regErr, newAccount) => {
if (regErr) {
console.error(regErr);
res.status(401).send(regErr.message);
} else {
+ // hotfix. Redux demands these fields be filled,
+ // but they have no default values
+ const account = Object.assign(newAccount, {
+ name: 'Test User',
+ entryYear: '2001',
+ major: 'Mechanical Engineering',
+ });
account.save((saveErr) => {
if (saveErr) {
console.error(saveErr);
@@ -82,6 +89,19 @@ router.post('/register', (req, res) => {
});
});
+// update student's plan of study
+router.post('/updateplan', (req, res) => {
+ Student.update(
+ { _id: req.user._id },
+ { plannedCourses: req.body.plannedCourses },
+ (err) => {
+ if (err) {
+ console.error(err);
+ }
+ res.json({ success: true });
+ });
+});
+
// get student completed courses
router.get('/completedcourses', (req, res) => {
res.json({
diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx
index 2e751dc..52f1e22 100644
--- a/src/actions/actions.jsx
+++ b/src/actions/actions.jsx
@@ -88,6 +88,13 @@ export const updateSuggestions = suggestions => ({
suggestions,
});
+// Update plan button
+export const updatePlanSuccess = data => ({
+ type: 'UPDATE_PLAN_SUCCESS',
+ isSuccess: data.success,
+});
+
+// Login backend interaction
// login or register action successful
export const receiveUser = json => ({
type: 'RECEIVE_USER',
@@ -160,6 +167,18 @@ export const register = (username, password) => (
}
);
+// Save plan of study backend
+export const updatePlan = plannedCourses => (
+ (dispatch) => {
+ const data = {
+ plannedCourses,
+ };
+ $.post('/updateplan', data)
+ .done(response => (dispatch(updatePlanSuccess(response))))
+ .fail((err, status) => console.error(err, status));
+ }
+);
+
// update login form username
export const updateUsername = username => ({
type: 'UPDATE_USERNAME',
diff --git a/src/components/CoursePlanner.jsx b/src/components/CoursePlanner.jsx
index ec795e1..7d87cac 100644
--- a/src/components/CoursePlanner.jsx
+++ b/src/components/CoursePlanner.jsx
@@ -4,6 +4,7 @@ import { Row, Col } from 'react-bootstrap';
import AddCourseDropdown from './AddCourseDropdown';
import SelectedCourse from './SelectedCourse';
import SearchFieldContainer from '../containers/SearchFieldContainer';
+import UpdatePlanContainer from '../containers/UpdatePlanContainer';
import NavPanel from './NavPanel';
import styles from '../../public/stylesheets/pages.css';
@@ -40,6 +41,7 @@ const CoursePlanner = ({ categories, otherCourses, onCourseSelect, onCourseRemov
Search All Courses
+
diff --git a/src/components/NavPanel.jsx b/src/components/NavPanel.jsx
index 8cab4ef..656d71c 100644
--- a/src/components/NavPanel.jsx
+++ b/src/components/NavPanel.jsx
@@ -13,8 +13,8 @@ const NavPanel = ({ active }) => (
Create/Edit Plan of Study
-
- Other Stuff
+
+ Plan by Semester
diff --git a/src/components/Semester.jsx b/src/components/Semester.jsx
index 663077e..6465f26 100644
--- a/src/components/Semester.jsx
+++ b/src/components/Semester.jsx
@@ -1,12 +1,13 @@
// A single semester rendered as an
. SemesterList contains these.
import React, { PropTypes } from 'react';
import CourseBlockContainer from '../containers/CourseBlockContainer';
+import styles from './../../public/stylesheets/semester.css';
const Semester = ({ semester, courseList, connectDropTarget }) => (
// Indicate node should react to drop target events
connectDropTarget(