Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
78acec5
Added Button to Save Course Plan
May 1, 2017
30db511
Merge branch 'master' of https://github.com/olin/register into REG-49…
arianaolson419 May 2, 2017
0384850
Add button to bottom of page
arianaolson419 May 2, 2017
320ec9c
Remove button from component
arianaolson419 May 2, 2017
821eeb2
Create a button to save plan
arianaolson419 May 2, 2017
b2a1b32
Add actions to post to /updateplan route
arianaolson419 May 2, 2017
d08d2a4
Merge branch 'master' of https://github.com/olin/register into REG-49…
arianaolson419 May 2, 2017
ea3f849
Merge branch 'master' of https://github.com/olin/register into dev
arianaolson419 May 2, 2017
4c8c01d
Added NavBar to SemesterPlanPage
May 2, 2017
9cdf6eb
Split Fall and Spring Semesters into Columns
May 2, 2017
f787e9d
fix: linter error
May 2, 2017
b1c8176
Hotfix registration to add sane default name
logandavis May 2, 2017
77e73b3
Merge pull request #38 from olin/hotfix-register
logandavis May 2, 2017
5365401
Added Button to Save Course Plan
May 1, 2017
b8831eb
Add button to bottom of page
arianaolson419 May 2, 2017
3b5ae7d
Remove button from component
arianaolson419 May 2, 2017
e4724d9
Create a button to save plan
arianaolson419 May 2, 2017
a84b232
fix: linter error
May 2, 2017
8e02481
Hotfix registration to add sane default name
logandavis May 2, 2017
d7c0f8b
Merge the different spacings T_T
logandavis May 2, 2017
2054466
re-add missing action (?)
logandavis May 2, 2017
7928142
Never mind T______T
logandavis May 2, 2017
7828277
Added Button to Save Course Plan
May 1, 2017
3b234db
Add button to bottom of page
arianaolson419 May 2, 2017
1975d7e
Remove button from component
arianaolson419 May 2, 2017
faa9fb2
Create a button to save plan
arianaolson419 May 2, 2017
c8692ac
fix: linter error
May 2, 2017
0dcf17c
Hotfix registration to add sane default name
logandavis May 2, 2017
0fe0c95
Added Button to Save Course Plan
May 1, 2017
48483ff
Remove button from component
arianaolson419 May 2, 2017
dd6c1bd
fix: linter error
May 2, 2017
f58847e
re-add missing action (?)
logandavis May 2, 2017
d8b70ea
Never mind T______T
logandavis May 2, 2017
d2c4ee5
Finish rebasing
logandavis May 2, 2017
ffb8b49
Finish rebasing
logandavis May 2, 2017
2f15add
Touch up style on login page
logandavis May 2, 2017
028742a
Adds state logic for login and register error components
logandavis May 2, 2017
14e6f8a
Fix prop population errors on Login page
logandavis May 2, 2017
c1cb6fd
Add error bar for registration errors, with styling
logandavis May 2, 2017
0e128d0
Add login error bar
logandavis May 2, 2017
8dd9b53
Merge pull request #39 from olin/REG-69-dev
logandavis May 2, 2017
3177ef3
Add route to calendar page
arianaolson419 May 3, 2017
11f310d
Remove unused function
arianaolson419 May 3, 2017
c183b9b
Added NavBar to SemesterPlanPage
May 2, 2017
785cc77
Split Fall and Spring Semesters into Columns
May 2, 2017
9b61fd7
Add UpdatePlan
logandavis May 3, 2017
2105931
Merge pull request #40 from olin/REG-54/style-calendar-page
logandavis May 3, 2017
63f4b62
Patch referencing errors
arianaolson419 May 3, 2017
6d54e09
Merge branch 'master' of github.com:olin/register into dev
billmwong May 26, 2017
a840091
added run instructions to readme
billmwong May 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions public/stylesheets/semester.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.semesterheading {
font-weight: bold;
font-size: 12pt;
}
22 changes: 21 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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({
Expand Down
19 changes: 19 additions & 0 deletions src/actions/actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/components/CoursePlanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -40,6 +41,7 @@ const CoursePlanner = ({ categories, otherCourses, onCourseSelect, onCourseRemov
</ul>
<h4>Search All Courses</h4>
<SearchFieldContainer />
<UpdatePlanContainer />
</div>
</Col>
</Row>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NavPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const NavPanel = ({ active }) => (
<LinkContainer to="/plan">
<NavItem eventKey={2} className={styles.item}>Create/Edit Plan of Study</NavItem>
</LinkContainer>
<LinkContainer to="#">
<NavItem eventKey={3} className={styles.item} disabled>Other Stuff</NavItem>
<LinkContainer to="/semesterplan">
<NavItem eventKey={3} className={styles.item}>Plan by Semester</NavItem>
</LinkContainer>
</Nav>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Semester.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// A single semester rendered as an <li>. 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(
<li>
{ semester }:
<span className={styles.semesterheading}>{ semester }:</span>
<ul>
{courseList.map(course =>
<CourseBlockContainer
Expand Down
25 changes: 22 additions & 3 deletions src/components/SemesterList.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
// A list containing Semester components.
import React, { PropTypes } from 'react';
import { Row, Col } from 'react-bootstrap';
import SemesterContainer from '../containers/SemesterContainer';
import SemesterReserveContainer from '../containers/SemesterReserveContainer';

const SemesterList = ({ semesters }) => (
const SemesterList = ({ fallSemesters, springSemesters }) => (
<div>
<h1>Plan by Semester</h1>
<ul>
<hr />
{semesters.map(semester =>
<Row>
{/* col attributes resize/reorder for different size screens */}
<Col sm={4} lg={6}>
{fallSemesters.map(semester =>
<SemesterContainer
key={semester}
semester={semester} // ownProps will grab this
/>,
)}
</Col>

<Col sm={4} lg={6}>
<hr />
{springSemesters.map(semester =>
<SemesterContainer
key={semester}
semester={semester} // ownProps will grab this
/>,
)}
</Col>
</Row>

<SemesterReserveContainer />

</ul>
</div>
);

SemesterList.propTypes = {
semesters: PropTypes.arrayOf(PropTypes.string).isRequired,
fallSemesters: PropTypes.arrayOf(PropTypes.string).isRequired,
springSemesters: PropTypes.arrayOf(PropTypes.string).isRequired,
};

export default SemesterList;
19 changes: 16 additions & 3 deletions src/components/SemesterPlanPage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// The page that holds the semester list.
import React from 'react';
import { Row, Col } from 'react-bootstrap';
import SemesterListContainer from '../containers/SemesterListContainer';
import UpdatePlanContainer from '../containers/UpdatePlanContainer';
import NavPanel from './NavPanel';
import styles from '../../public/stylesheets/pages.css';

const SemesterPlanPage = () => (
<div>
<SemesterListContainer />
</div>
<Row>
{/* col attributes resize/reorder for different size screens */}
<Col sm={3} lg={2}>
<NavPanel />
</Col>
<Col sm={9} lg={10}>
<ul className={styles.mainbody}>
<SemesterListContainer />
<UpdatePlanContainer />
</ul>
</Col>
</Row>
);

export default SemesterPlanPage;
3 changes: 2 additions & 1 deletion src/components/SemesterReserve.jsx
Original file line number Diff line number Diff line change
@@ -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(
<li>
Unassigned Courses:
<span className={styles.semesterheading}>Unassigned Courses:</span>
<ul>
{courseList.map(course =>
<CourseBlockContainer
Expand Down
16 changes: 16 additions & 0 deletions src/components/UpdatePlan.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { PropTypes } from 'react';

const UpdatePlan = ({ onClick }) => (
<button
type="button"
onClick={onClick}
>
Save
</button>
);

UpdatePlan.propTypes = {
onClick: PropTypes.func.isRequired,
};

export default UpdatePlan;
16 changes: 12 additions & 4 deletions src/containers/SemesterContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ import { DropTarget } from 'react-dnd';
import Semester from '../components/Semester';

const filterCourse = (semester, completedCourses, plannedCourses) => {
const compare = (a, b) => {
// sort alphabetically by registrarId
const compareByCourseId = (a, b) => {
// sort alphabetically by courseId (where the course code is stored in plannedCourses)
if (a.courseId.toUpperCase() < b.courseId.toUpperCase()) {
return -1;
}
return 1;
};
const compareByRegistrarId = (a, b) => {
// sort alphabetically by registrarId (where the course code is stored in completedCourses)
if (a.registrarId.toUpperCase() < b.registrarId.toUpperCase()) {
return -1;
}
return 1;
};
const filteredCompleted = completedCourses.filter(course =>
course.semester === semester,
).sort(compare);
).sort(compareByRegistrarId);
console.log(plannedCourses, 'plannedCourses');
const filteredPlanned = plannedCourses.filter(course =>
course.semester === semester,
).sort(compare);
).sort(compareByCourseId);
return filteredPlanned.concat(filteredCompleted);
};

Expand Down
18 changes: 18 additions & 0 deletions src/containers/SemesterListContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,26 @@ const makeSemesterList = (entryYear) => {
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(
Expand Down
27 changes: 27 additions & 0 deletions src/containers/UpdatePlanContainer.jsx
Original file line number Diff line number Diff line change
@@ -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;
58 changes: 0 additions & 58 deletions src/reducers/LoginReducer.jsx

This file was deleted.

Loading