From 78acec527af3b13279232a9b8ec27a4eb597175b Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Sun, 30 Apr 2017 22:39:37 -0400 Subject: [PATCH 01/40] Added Button to Save Course Plan --- src/components/SemesterList.jsx | 8 +++++++- src/containers/SemesterListContainer.jsx | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index a472268..df03ffc 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -2,7 +2,7 @@ import React, { PropTypes } from 'react'; import SemesterContainer from '../containers/SemesterContainer'; import SemesterReserveContainer from '../containers/SemesterReserveContainer'; -const SemesterList = ({ semesters }) => ( +const SemesterList = ({ semesters, onSavePlan }) => (

Plan by Semester

+
+ +
); SemesterList.propTypes = { semesters: PropTypes.arrayOf(PropTypes.string).isRequired, + onSavePlan: PropTypes.func.isRequired, }; export default SemesterList; diff --git a/src/containers/SemesterListContainer.jsx b/src/containers/SemesterListContainer.jsx index 22b3b88..ea1c2e9 100644 --- a/src/containers/SemesterListContainer.jsx +++ b/src/containers/SemesterListContainer.jsx @@ -17,6 +17,10 @@ const makeSemesterList = (entryYear) => { const mapStateToProps = state => ({ semesters: makeSemesterList(state.LoginReducer.entryYear), + onSavePlan: (e) => { + e.preventDefault(); + // dispatch() + }, }); const SemesterListContainer = connect( From 0384850fa9f64d7c185da06064d9f9bfc73684a3 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:04:26 -0400 Subject: [PATCH 02/40] Add button to bottom of page --- src/components/CoursePlanner.jsx | 2 ++ src/components/SemesterPlanPage.jsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/CoursePlanner.jsx b/src/components/CoursePlanner.jsx index 805d4df..b57c906 100644 --- a/src/components/CoursePlanner.jsx +++ b/src/components/CoursePlanner.jsx @@ -1,6 +1,7 @@ import React, { PropTypes } from 'react'; import { Row, Col } from 'react-bootstrap'; import AddCourseDropdown from './AddCourseDropdown'; +import UpdatePlanContainer from '../containers/UpdatePlanContainer'; import NavPanel from './NavPanel'; import styles from '../../public/stylesheets/pages.css'; @@ -22,6 +23,7 @@ const CoursePlanner = ({ categories, onCourseSelect }) => ( />, )} + diff --git a/src/components/SemesterPlanPage.jsx b/src/components/SemesterPlanPage.jsx index e67a10b..a41b490 100644 --- a/src/components/SemesterPlanPage.jsx +++ b/src/components/SemesterPlanPage.jsx @@ -1,9 +1,11 @@ import React from 'react'; import SemesterListContainer from '../containers/SemesterListContainer'; +import UpdatePlanContainer from '../containers/UpdatePlanContainer'; const SemesterPlanPage = () => (
+
); From 320ec9cdf6258dbf75f58189d035e83174a03bcb Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:05:05 -0400 Subject: [PATCH 03/40] Remove button from component --- src/components/SemesterList.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index df03ffc..445026c 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -15,11 +15,6 @@ const SemesterList = ({ semesters, onSavePlan }) => ( )} -
- -
); From 821eeb2eafcc2e8e0c4869a7739070aa6b244a7e Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:06:08 -0400 Subject: [PATCH 04/40] Create a button to save plan --- src/components/UpdatePlan.jsx | 16 +++++++++++++++ src/containers/UpdatePlanContainer.jsx | 27 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/components/UpdatePlan.jsx create mode 100644 src/containers/UpdatePlanContainer.jsx diff --git a/src/components/UpdatePlan.jsx b/src/components/UpdatePlan.jsx new file mode 100644 index 0000000..f6108d6 --- /dev/null +++ b/src/components/UpdatePlan.jsx @@ -0,0 +1,16 @@ +import React, { PropTypes } from 'react'; + +const UpdatePlan = ({ onClick }) => ( + +); + +UpdatePlan.propTypes = { + onClick: PropTypes.func.isRequired, +}; + +export default UpdatePlan; diff --git a/src/containers/UpdatePlanContainer.jsx b/src/containers/UpdatePlanContainer.jsx new file mode 100644 index 0000000..552a4bb --- /dev/null +++ b/src/containers/UpdatePlanContainer.jsx @@ -0,0 +1,27 @@ +import { connect } from 'react-redux'; +import { updatePlan } from '../actions/actions'; +import UpdatePlan from '../components/UpdatePlan'; + +const mapStateToProps = state => ({ + plannedCourses: state.Student.plannedCourses, +}); + +const mergeProps = (stateProps, dispatchProps) => { + const { plannedCourses } = stateProps; + const { dispatch } = dispatchProps; + + return { + onClick: (e) => { + e.preventDefault(); + dispatch(updatePlan(plannedCourses)); + }, + }; +}; + +const UpdatePlanContainer = connect( + mapStateToProps, + null, + mergeProps, +)(UpdatePlan); + +export default UpdatePlanContainer; From b2a1b32186788fdf0d07eedaddd22d89f0f405b9 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:06:26 -0400 Subject: [PATCH 05/40] Add actions to post to /updateplan route --- src/actions/actions.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 02bb2ef..0b8d191 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -152,7 +152,7 @@ export const register = (username, password) => ( ); // Save plan of study backend -export const updateplan = plannedCourses => ( +export const updatePlan = plannedCourses => ( (dispatch) => { const data = { plannedCourses, From 4c8c01d3dc0865305b598da85344292acad70344 Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Tue, 2 May 2017 02:36:59 -0400 Subject: [PATCH 06/40] Added NavBar to SemesterPlanPage --- src/components/SemesterPlanPage.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/SemesterPlanPage.jsx b/src/components/SemesterPlanPage.jsx index 8a29b6d..aa1c08f 100644 --- a/src/components/SemesterPlanPage.jsx +++ b/src/components/SemesterPlanPage.jsx @@ -1,11 +1,22 @@ // The page that holds the semester list. import React from 'react'; +import { Row, Col } from 'react-bootstrap'; import SemesterListContainer from '../containers/SemesterListContainer'; +import NavPanel from './NavPanel'; +import styles from '../../public/stylesheets/pages.css'; const SemesterPlanPage = () => ( -
- -
+ + {/* col attributes resize/reorder for different size screens */} + + + + +
    + +
+ +
); export default SemesterPlanPage; From 9cdf6eb544447dfc9fb65ffab9faacc4703dff25 Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Tue, 2 May 2017 03:31:27 -0400 Subject: [PATCH 07/40] Split Fall and Spring Semesters into Columns --- public/stylesheets/semester.css | 4 ++++ src/components/NavPanel.jsx | 4 ++-- src/components/Semester.jsx | 3 ++- src/components/SemesterList.jsx | 25 +++++++++++++++++++++--- src/components/SemesterReserve.jsx | 3 ++- src/containers/SemesterListContainer.jsx | 18 +++++++++++++++++ 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 public/stylesheets/semester.css 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/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(
  • - { semester }: + { semester }:
      {courseList.map(course => ( +const SemesterList = ({ fallSemesters, springSemesters }) => (

      Plan by Semester

        -
        - {semesters.map(semester => + + {/* col attributes resize/reorder for different size screens */} + + {fallSemesters.map(semester => + , + )} + + + +
        + {springSemesters.map(semester => , )} + +
        + +
      ); SemesterList.propTypes = { semesters: PropTypes.arrayOf(PropTypes.string).isRequired, + fallSemesters: PropTypes.arrayOf(PropTypes.string).isRequired, + springSemesters: PropTypes.arrayOf(PropTypes.string).isRequired, }; export default SemesterList; diff --git a/src/components/SemesterReserve.jsx b/src/components/SemesterReserve.jsx index cfedad2..1bb699b 100644 --- a/src/components/SemesterReserve.jsx +++ b/src/components/SemesterReserve.jsx @@ -1,11 +1,12 @@ import React, { PropTypes } from 'react'; import CourseBlockContainer from '../containers/CourseBlockContainer'; +import styles from './../../public/stylesheets/semester.css'; const SemesterReserve = ({ courseList, connectDropTarget }) => ( // Indicate node should react to drop target events connectDropTarget(
    • - Unassigned Courses: + Unassigned Courses:
        {courseList.map(course => { return semesterList; }; +const makeFallSemesterList = (entryYear) => { + const fallSemesterList = []; + for (let i = 0; i < 4; i += 1) { + fallSemesterList.push('Fall' + shortenYear(entryYear + i)); + } + return fallSemesterList; +}; + +const makeSpringSemesterList = (entryYear) => { + const springSemesterList = []; + for (let i = 0; i < 4; i += 1) { + springSemesterList.push('Spring' + shortenYear(entryYear + i + 1)); + } + return springSemesterList; +}; + const mapStateToProps = state => ({ semesters: makeSemesterList(state.Student.entryYear), + fallSemesters: makeFallSemesterList(state.Student.entryYear), + springSemesters: makeSpringSemesterList(state.Student.entryYear), }); const SemesterListContainer = connect( From f787e9dec9b48e79a45003d258bcada49d5fd08d Mon Sep 17 00:00:00 2001 From: Jeremy Garcia Date: Tue, 2 May 2017 09:19:54 -0400 Subject: [PATCH 08/40] fix: linter error --- src/actions/actions.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 98ce53a..4d39d14 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -136,6 +136,10 @@ export const updatePlan = plannedCourses => ( }; $.post('/updateplan', data) .done(response => (dispatch(updatePlanSuccess(response)))) + .fail((err, status) => console.error(err, status)); + } +); + // update login form username export const updateUsername = username => ({ From b1c817617b78196db54610c59b31d19a2a95fbe0 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 16:09:51 -0400 Subject: [PATCH 09/40] Hotfix registration to add sane default name --- routes/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 66cf17a..a0efa81 100644 --- a/routes/index.js +++ b/routes/index.js @@ -42,10 +42,17 @@ 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); } + // 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); From 53654016cd4143560a28f9524879034d744065fe Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Sun, 30 Apr 2017 22:39:37 -0400 Subject: [PATCH 10/40] Added Button to Save Course Plan --- src/components/SemesterList.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index cbf4caa..ca57de7 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -3,7 +3,7 @@ import React, { PropTypes } from 'react'; import SemesterContainer from '../containers/SemesterContainer'; import SemesterReserveContainer from '../containers/SemesterReserveContainer'; -const SemesterList = ({ semesters }) => ( +const SemesterList = ({ semesters, onSavePlan }) => (

        Plan by Semester

          @@ -16,11 +16,17 @@ const SemesterList = ({ semesters }) => ( )}
        +
        + +
        ); SemesterList.propTypes = { semesters: PropTypes.arrayOf(PropTypes.string).isRequired, + onSavePlan: PropTypes.func.isRequired, }; export default SemesterList; From b8831eb8a0c5af96b8d30e559e33682b269e7122 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:04:26 -0400 Subject: [PATCH 11/40] Add button to bottom of page --- src/components/CoursePlanner.jsx | 2 ++ src/components/SemesterPlanPage.jsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/CoursePlanner.jsx b/src/components/CoursePlanner.jsx index ee2a9da..f2c1bc4 100644 --- a/src/components/CoursePlanner.jsx +++ b/src/components/CoursePlanner.jsx @@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'; import { Row, Col } from 'react-bootstrap'; import AddCourseDropdown from './AddCourseDropdown'; +import UpdatePlanContainer from '../containers/UpdatePlanContainer'; import NavPanel from './NavPanel'; import styles from '../../public/stylesheets/pages.css'; @@ -24,6 +25,7 @@ const CoursePlanner = ({ categories, onCourseSelect }) => ( />, )}
      + diff --git a/src/components/SemesterPlanPage.jsx b/src/components/SemesterPlanPage.jsx index 8a29b6d..b79384d 100644 --- a/src/components/SemesterPlanPage.jsx +++ b/src/components/SemesterPlanPage.jsx @@ -1,10 +1,12 @@ // The page that holds the semester list. import React from 'react'; import SemesterListContainer from '../containers/SemesterListContainer'; +import UpdatePlanContainer from '../containers/UpdatePlanContainer'; const SemesterPlanPage = () => (
      +
      ); From 3b5ae7d7b9222b30444bb8f8cfa1fef94a8ee8ed Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:05:05 -0400 Subject: [PATCH 12/40] Remove button from component --- src/components/SemesterList.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index ca57de7..3304928 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -16,11 +16,6 @@ const SemesterList = ({ semesters, onSavePlan }) => ( )}
    -
    - -
    ); From e4724d9cd8c203d3de1fe250bee8e2eeff299a41 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:06:08 -0400 Subject: [PATCH 13/40] Create a button to save plan --- src/components/UpdatePlan.jsx | 16 +++++++++++++++ src/containers/UpdatePlanContainer.jsx | 27 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/components/UpdatePlan.jsx create mode 100644 src/containers/UpdatePlanContainer.jsx diff --git a/src/components/UpdatePlan.jsx b/src/components/UpdatePlan.jsx new file mode 100644 index 0000000..f6108d6 --- /dev/null +++ b/src/components/UpdatePlan.jsx @@ -0,0 +1,16 @@ +import React, { PropTypes } from 'react'; + +const UpdatePlan = ({ onClick }) => ( + +); + +UpdatePlan.propTypes = { + onClick: PropTypes.func.isRequired, +}; + +export default UpdatePlan; diff --git a/src/containers/UpdatePlanContainer.jsx b/src/containers/UpdatePlanContainer.jsx new file mode 100644 index 0000000..552a4bb --- /dev/null +++ b/src/containers/UpdatePlanContainer.jsx @@ -0,0 +1,27 @@ +import { connect } from 'react-redux'; +import { updatePlan } from '../actions/actions'; +import UpdatePlan from '../components/UpdatePlan'; + +const mapStateToProps = state => ({ + plannedCourses: state.Student.plannedCourses, +}); + +const mergeProps = (stateProps, dispatchProps) => { + const { plannedCourses } = stateProps; + const { dispatch } = dispatchProps; + + return { + onClick: (e) => { + e.preventDefault(); + dispatch(updatePlan(plannedCourses)); + }, + }; +}; + +const UpdatePlanContainer = connect( + mapStateToProps, + null, + mergeProps, +)(UpdatePlan); + +export default UpdatePlanContainer; From a84b2328a0c3616a35f7527990442a51eabe40b2 Mon Sep 17 00:00:00 2001 From: Jeremy Garcia Date: Tue, 2 May 2017 09:19:54 -0400 Subject: [PATCH 14/40] fix: linter error --- src/actions/actions.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 2d6ffb5..349bc1d 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -121,6 +121,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', From 8e024814b510303732bab43e3d38f3174cee358d Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 16:09:51 -0400 Subject: [PATCH 15/40] Hotfix registration to add sane default name --- routes/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 66cf17a..a0efa81 100644 --- a/routes/index.js +++ b/routes/index.js @@ -42,10 +42,17 @@ 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); } + // 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); From 2054466faf28616b7ccfe1a114dbc44d3cb051db Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 17:13:01 -0400 Subject: [PATCH 16/40] re-add missing action (?) --- src/actions/actions.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 938a0a0..c63ffbf 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -102,6 +102,12 @@ export const logout = data => ( } ); +// Update plan button +export const updatePlanSuccess = data => ({ + type: 'UPDATE_PLAN_SUCCESS', + isSuccess: data.success, +}); + // login backend interaction export const login = (username, password) => ( (dispatch) => { From 7928142de44b67f23f7e16f5418a5042486ace82 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 17:14:05 -0400 Subject: [PATCH 17/40] Never mind T______T --- src/actions/actions.jsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index c63ffbf..938a0a0 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -102,12 +102,6 @@ export const logout = data => ( } ); -// Update plan button -export const updatePlanSuccess = data => ({ - type: 'UPDATE_PLAN_SUCCESS', - isSuccess: data.success, -}); - // login backend interaction export const login = (username, password) => ( (dispatch) => { From 78282777975945f25bf4373572f6ee3c2a055636 Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Sun, 30 Apr 2017 22:39:37 -0400 Subject: [PATCH 18/40] Added Button to Save Course Plan --- src/components/SemesterList.jsx | 8 +++++++- src/containers/SemesterListContainer.jsx | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index cbf4caa..ca57de7 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -3,7 +3,7 @@ import React, { PropTypes } from 'react'; import SemesterContainer from '../containers/SemesterContainer'; import SemesterReserveContainer from '../containers/SemesterReserveContainer'; -const SemesterList = ({ semesters }) => ( +const SemesterList = ({ semesters, onSavePlan }) => (

    Plan by Semester

      @@ -16,11 +16,17 @@ const SemesterList = ({ semesters }) => ( )}
    +
    + +
    ); SemesterList.propTypes = { semesters: PropTypes.arrayOf(PropTypes.string).isRequired, + onSavePlan: PropTypes.func.isRequired, }; export default SemesterList; diff --git a/src/containers/SemesterListContainer.jsx b/src/containers/SemesterListContainer.jsx index 7a73405..17d2096 100644 --- a/src/containers/SemesterListContainer.jsx +++ b/src/containers/SemesterListContainer.jsx @@ -17,6 +17,10 @@ const makeSemesterList = (entryYear) => { const mapStateToProps = state => ({ semesters: makeSemesterList(state.Student.entryYear), + onSavePlan: (e) => { + e.preventDefault(); + // dispatch() + }, }); const SemesterListContainer = connect( From 3b234dbec1c64335ea25dfc186aa2ada1cbe3634 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:04:26 -0400 Subject: [PATCH 19/40] Add button to bottom of page --- src/components/SemesterPlanPage.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/SemesterPlanPage.jsx b/src/components/SemesterPlanPage.jsx index 8a29b6d..b79384d 100644 --- a/src/components/SemesterPlanPage.jsx +++ b/src/components/SemesterPlanPage.jsx @@ -1,10 +1,12 @@ // The page that holds the semester list. import React from 'react'; import SemesterListContainer from '../containers/SemesterListContainer'; +import UpdatePlanContainer from '../containers/UpdatePlanContainer'; const SemesterPlanPage = () => (
    +
    ); From 1975d7eafd33c095bd4988d8698167768f2604a9 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:05:05 -0400 Subject: [PATCH 20/40] Remove button from component --- src/components/SemesterList.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index ca57de7..3304928 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -16,11 +16,6 @@ const SemesterList = ({ semesters, onSavePlan }) => ( )} -
    - -
    ); From faa9fb23eb6ba04f01baf54a03d7029fe682ead1 Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:06:08 -0400 Subject: [PATCH 21/40] Create a button to save plan --- src/components/UpdatePlan.jsx | 16 +++++++++++++++ src/containers/UpdatePlanContainer.jsx | 27 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/components/UpdatePlan.jsx create mode 100644 src/containers/UpdatePlanContainer.jsx diff --git a/src/components/UpdatePlan.jsx b/src/components/UpdatePlan.jsx new file mode 100644 index 0000000..f6108d6 --- /dev/null +++ b/src/components/UpdatePlan.jsx @@ -0,0 +1,16 @@ +import React, { PropTypes } from 'react'; + +const UpdatePlan = ({ onClick }) => ( + +); + +UpdatePlan.propTypes = { + onClick: PropTypes.func.isRequired, +}; + +export default UpdatePlan; diff --git a/src/containers/UpdatePlanContainer.jsx b/src/containers/UpdatePlanContainer.jsx new file mode 100644 index 0000000..552a4bb --- /dev/null +++ b/src/containers/UpdatePlanContainer.jsx @@ -0,0 +1,27 @@ +import { connect } from 'react-redux'; +import { updatePlan } from '../actions/actions'; +import UpdatePlan from '../components/UpdatePlan'; + +const mapStateToProps = state => ({ + plannedCourses: state.Student.plannedCourses, +}); + +const mergeProps = (stateProps, dispatchProps) => { + const { plannedCourses } = stateProps; + const { dispatch } = dispatchProps; + + return { + onClick: (e) => { + e.preventDefault(); + dispatch(updatePlan(plannedCourses)); + }, + }; +}; + +const UpdatePlanContainer = connect( + mapStateToProps, + null, + mergeProps, +)(UpdatePlan); + +export default UpdatePlanContainer; From c8692ac730781f2144c3f6b52a8d79f3185adfa4 Mon Sep 17 00:00:00 2001 From: Jeremy Garcia Date: Tue, 2 May 2017 09:19:54 -0400 Subject: [PATCH 22/40] fix: linter error --- src/actions/actions.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index f1d48fa..6eb5e76 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -142,6 +142,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', From 0dcf17cdda8cc3cd74a71e94ff18c4bb88b102d8 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 16:09:51 -0400 Subject: [PATCH 23/40] Hotfix registration to add sane default name --- routes/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 66cf17a..a0efa81 100644 --- a/routes/index.js +++ b/routes/index.js @@ -42,10 +42,17 @@ 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); } + // 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); From 0fe0c951f3d61e97e5762549be7b3b39e044989a Mon Sep 17 00:00:00 2001 From: rsiegel812 Date: Sun, 30 Apr 2017 22:39:37 -0400 Subject: [PATCH 24/40] Added Button to Save Course Plan --- src/components/SemesterList.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index 3304928..ca57de7 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -16,6 +16,11 @@ const SemesterList = ({ semesters, onSavePlan }) => ( )} +
    + +
    ); From 48483ff868c85feb41c5aa9ed096b1c331c9b98c Mon Sep 17 00:00:00 2001 From: arianaolson419 Date: Tue, 2 May 2017 02:05:05 -0400 Subject: [PATCH 25/40] Remove button from component --- src/components/SemesterList.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/SemesterList.jsx b/src/components/SemesterList.jsx index ca57de7..3304928 100644 --- a/src/components/SemesterList.jsx +++ b/src/components/SemesterList.jsx @@ -16,11 +16,6 @@ const SemesterList = ({ semesters, onSavePlan }) => ( )} -
    - -
    ); From dd6c1bdaf3126cf4debd9cc9ea1738ef1926db52 Mon Sep 17 00:00:00 2001 From: Jeremy Garcia Date: Tue, 2 May 2017 09:19:54 -0400 Subject: [PATCH 26/40] fix: linter error --- src/actions/actions.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 6eb5e76..240e902 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -154,6 +154,18 @@ export const updatePlan = plannedCourses => ( } ); +// 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', From f58847e13e3374ef07440ffb2a838087f97dc406 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 17:13:01 -0400 Subject: [PATCH 27/40] re-add missing action (?) --- src/actions/actions.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 240e902..137c650 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -116,6 +116,12 @@ export const logout = data => ( } ); +// Update plan button +export const updatePlanSuccess = data => ({ + type: 'UPDATE_PLAN_SUCCESS', + isSuccess: data.success, +}); + // login backend interaction export const login = (username, password) => ( (dispatch) => { From d8b70eaeacef1b00e586c10f5634755ff191b08b Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 17:14:05 -0400 Subject: [PATCH 28/40] Never mind T______T --- src/actions/actions.jsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 137c650..240e902 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -116,12 +116,6 @@ export const logout = data => ( } ); -// Update plan button -export const updatePlanSuccess = data => ({ - type: 'UPDATE_PLAN_SUCCESS', - isSuccess: data.success, -}); - // login backend interaction export const login = (username, password) => ( (dispatch) => { From d2c4ee5d28bdb82dced7dbc77c555ccfa74e4d06 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 17:25:43 -0400 Subject: [PATCH 29/40] Finish rebasing --- routes/index.js | 13 +++++++++++++ src/actions/actions.jsx | 16 +++++----------- src/components/CoursePlanner.jsx | 2 ++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/routes/index.js b/routes/index.js index a0efa81..8ae02a1 100644 --- a/routes/index.js +++ b/routes/index.js @@ -87,6 +87,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 240e902..963f4e6 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -142,17 +142,11 @@ 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 plan button +export const updatePlanSuccess = data => ({ + type: 'UPDATE_PLAN_SUCCESS', + isSuccess: data.success, +}); // Save plan of study backend export const updatePlan = plannedCourses => ( 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

    + From 2f15add0afd4fdd0c50a3eb879187e3506d7a019 Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 02:29:19 -0400 Subject: [PATCH 30/40] Touch up style on login page --- public/stylesheets/login-local.css | 30 ------------------- .../{register-new-user.css => login.css} | 18 ++++++++--- src/components/LoginLocal.jsx | 4 +-- src/components/RegisterNewUser.jsx | 5 ++-- 4 files changed, 18 insertions(+), 39 deletions(-) delete mode 100644 public/stylesheets/login-local.css rename public/stylesheets/{register-new-user.css => login.css} (75%) diff --git a/public/stylesheets/login-local.css b/public/stylesheets/login-local.css deleted file mode 100644 index 3ebf865..0000000 --- a/public/stylesheets/login-local.css +++ /dev/null @@ -1,30 +0,0 @@ -.loginblock { - text-align:center; - padding-top: 90px; -} - -.loginblock input { - box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2); - width: 450px; - height: 42px; - border: 1px solid #ccc; - margin-bottom: 20px; - border-radius:5px; - font-size: 14px; - padding: 0 30px 0 50px; - outline: none; -} - -.loginblock button{ - color: #fff; - background-color: #59B2E0; - border-radius: 5px; - font-size: 18px; - height: 50px; - width: 150px; -} - -.loginblock button:hover { - background-color: #53A3CD; - border-radius: 5px; -} diff --git a/public/stylesheets/register-new-user.css b/public/stylesheets/login.css similarity index 75% rename from public/stylesheets/register-new-user.css rename to public/stylesheets/login.css index 411bbae..34c091e 100644 --- a/public/stylesheets/register-new-user.css +++ b/public/stylesheets/login.css @@ -1,21 +1,31 @@ +.loginblock { + text-align:center; + padding-top: 90px; +} + .registerblock { text-align:center; padding-top: 50px; } +.loginblock input, .registerblock input { box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2); width: 450px; height: 42px; - box-sizing: border-box; border: 1px solid #ccc; margin-bottom: 20px; border-radius:5px; font-size: 14px; - padding: 0 20px 0 50px; + padding: 0 20px; outline: none; } +.registerblock input { + box-sizing: border-box; +} + +.loginblock button, .registerblock button{ color: #fff; background-color: #59B2E0; @@ -25,7 +35,7 @@ width: 150px; } +.loginblock button:hover, .registerblock button:hover { background-color: #53A3CD; - border-radius: 5px; -} \ No newline at end of file +} diff --git a/src/components/LoginLocal.jsx b/src/components/LoginLocal.jsx index ab4a937..90a1f32 100644 --- a/src/components/LoginLocal.jsx +++ b/src/components/LoginLocal.jsx @@ -1,12 +1,12 @@ /* The form that a user fills out to log in with an existing account. The user provides their email and password. */ import React, { PropTypes } from 'react'; -import styles from './../../public/stylesheets/login-local.css'; +import styles from './../../public/stylesheets/login.css'; const LoginLocal = ({ username, password, updateUser, updatePassword, onLogin }) => (
    -

    Login with email and password

    +

    Log In to an Existing Account

    (
    -

    Register an account

    -
    +

    Register a New Account

    Date: Tue, 2 May 2017 10:53:42 -0400 Subject: [PATCH 31/40] Adds state logic for login and register error components The login page was crashing on incorrect registers, and also had no way of surfacing error messages. This commit fixes the former problem and adds the state changes necessary to display the latter. --- routes/index.js | 76 +++++++++++++++--------------- src/actions/actions.jsx | 22 ++++++++- src/components/RegisterNewUser.jsx | 2 + src/reducers/Student.jsx | 30 ++++++++++++ 4 files changed, 91 insertions(+), 39 deletions(-) diff --git a/routes/index.js b/routes/index.js index 8ae02a1..f50b369 100644 --- a/routes/index.js +++ b/routes/index.js @@ -45,45 +45,47 @@ router.post('/register', (req, res) => { req.body.password, (regErr, newAccount) => { if (regErr) { console.error(regErr); - } - // 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); - } else { - req.login(account, (loginErr) => { - if (loginErr) { - console.error(loginErr); - } - // load all courses to send to state - Course.find({}, (err, courses) => { - if (err) { - console.error(err); - } else { - const data = { - user: { - username: req.user.username, - name: req.user.name, - id: req.user._id, - entryYear: req.user.entryYear, - major: req.user.major, - plannedCourses: req.user.plannedCourses, - completedCourses: req.user.completedCourses, - }, - courses, - }; - res.json(data); + 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); + } else { + req.login(account, (loginErr) => { + if (loginErr) { + console.error(loginErr); } + // load all courses to send to state + Course.find({}, (err, courses) => { + if (err) { + console.error(err); + } else { + const data = { + user: { + username: req.user.username, + name: req.user.name, + id: req.user._id, + entryYear: req.user.entryYear, + major: req.user.major, + plannedCourses: req.user.plannedCourses, + completedCourses: req.user.completedCourses, + }, + courses, + }; + res.json(data); + } + }); }); - }); - } - }); + } + }); + } }); }); diff --git a/src/actions/actions.jsx b/src/actions/actions.jsx index 77fe670..52f1e22 100644 --- a/src/actions/actions.jsx +++ b/src/actions/actions.jsx @@ -108,6 +108,18 @@ export const receiveUser = json => ({ courses: json.courses, }); +// register action unsuccessful +export const registerError = message => ({ + type: 'REGISTER_ERROR', + message, +}); + +// login action unsuccessful +export const loginError = message => ({ + type: 'LOGIN_ERROR', + message, +}); + // Logout Component export const logoutUser = data => ({ type: 'LOGOUT_USER', @@ -132,7 +144,10 @@ export const login = (username, password) => ( }; $.post('/login', data) .done(response => dispatch(receiveUser(response))) - .fail((err, status) => console.error(err, status)); + .fail((err) => { + const message = 'Error ' + err.status + ': ' + err.responseText; + dispatch(loginError(message)); + }); } ); @@ -145,7 +160,10 @@ export const register = (username, password) => ( }; $.post('/register', data) .done(response => (dispatch(receiveUser(response)))) - .fail((err, status) => console.error(err, status)); + .fail((err) => { + const message = 'Error ' + err.status + ': ' + err.responseText; + dispatch(registerError(message)); + }); } ); diff --git a/src/components/RegisterNewUser.jsx b/src/components/RegisterNewUser.jsx index ed035af..c72e809 100644 --- a/src/components/RegisterNewUser.jsx +++ b/src/components/RegisterNewUser.jsx @@ -2,6 +2,7 @@ The user provides their name, an email, and a password. */ import React, { PropTypes } from 'react'; import styles from './../../public/stylesheets/login.css'; +import Note from './Note'; const RegisterNewUser = ({ username, @@ -13,6 +14,7 @@ const RegisterNewUser = ({

    Register a New Account

    + {/* registerError ? : null */} { } }; +const registerError = (state = '', action) => { + switch (action.type) { + case 'REGISTER_ERROR': + return action.message; + case 'RECEIVE_USER': + return ''; + case 'UPDATE_REGISTER_USERNAME': + return ''; + default: + return state; + } +}; + +const loginError = (state = '', action) => { + switch (action.type) { + case 'LOGIN_ERROR': + return action.message; + case 'RECEIVE_USER': + return ''; + case 'UPDATE_USERNAME': + return ''; + case 'UPDATE_PASSWORD': + return ''; + default: + return state; + } +}; + const settingsInitialState = [ { name: 'setting1', @@ -159,6 +187,8 @@ const Student = combineReducers({ plannedCourses, completedCourses, loggedIn, + registerError, + loginError, settings, }); From 14e6f8a6a37e2d25ce8f2692bd23d4f46ca0dbca Mon Sep 17 00:00:00 2001 From: Logan Davis Date: Tue, 2 May 2017 13:38:29 -0400 Subject: [PATCH 32/40] Fix prop population errors on Login page The connect function wasn't quite woring right, which was causing ugly console errors and incorrect rehydrating. This commit fixes that by adding mapDispatchToProps() and using it right. --- src/components/LoginLocal.jsx | 6 +++--- src/components/RegisterNewUser.jsx | 12 ++++++------ src/containers/LoginContainer.jsx | 24 ++++++++++++++++-------- src/containers/RegisterContainer.jsx | 24 ++++++++++++++++-------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/components/LoginLocal.jsx b/src/components/LoginLocal.jsx index 90a1f32..f581aac 100644 --- a/src/components/LoginLocal.jsx +++ b/src/components/LoginLocal.jsx @@ -3,7 +3,7 @@ The user provides their email and password. */ import React, { PropTypes } from 'react'; import styles from './../../public/stylesheets/login.css'; -const LoginLocal = ({ username, password, updateUser, updatePassword, onLogin }) => ( +const LoginLocal = ({ username, password, updateUser, updatePwd, onLogin }) => (

    Log In to an Existing Account

    @@ -18,7 +18,7 @@ const LoginLocal = ({ username, password, updateUser, updatePassword, onLogin }) placeholder="Password" type="password" value={password} - onChange={updatePassword} + onChange={updatePwd} />