diff --git a/client/src/components/CommentsBody.jsx b/client/src/components/CommentsBody.jsx
index 85d6b4d..39555b6 100644
--- a/client/src/components/CommentsBody.jsx
+++ b/client/src/components/CommentsBody.jsx
@@ -12,17 +12,7 @@ class CommentsBody extends React.Component {
comments: []
};
- let URL = '';
-
- if (process.env.URL) {
- URL = `${process.env.URL}:${process.env.PORT}`;
- } else {
- URL = 'http://127.0.0.1:3000';
- }
-
- console.log('io.connect URL is:', URL);
-
- this.client = io.connect(URL);
+ this.client = io();
this.postComment = this.postComment.bind(this);
}
diff --git a/client/src/components/Container.jsx b/client/src/components/Container.jsx
index cf60f43..a763833 100644
--- a/client/src/components/Container.jsx
+++ b/client/src/components/Container.jsx
@@ -4,7 +4,7 @@ import Footer from './Footer.jsx';
const Container = (props) => {
return (
-
+
{props.children}
diff --git a/client/src/components/FavoritesPage.jsx b/client/src/components/FavoritesPage.jsx
new file mode 100644
index 0000000..4b0ab2c
--- /dev/null
+++ b/client/src/components/FavoritesPage.jsx
@@ -0,0 +1,34 @@
+import React from 'react';
+import axios from 'axios';
+import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router';
+import Cookies from 'js-cookie';
+import ResultListEntry from './ResultListEntry.jsx';
+
+class FavoritesPage extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ colleges: Cookies.getJSON("colleges")
+ };
+ this.handleFavColleges = this.handleFavColleges.bind(this);
+ }
+
+ handleFavColleges(college) {
+ let prev = this.state.colleges;
+ let col = college;
+ console.log("Edge-Case Handled.");
+ }
+
+ render () {
+ return (
+
+ {this.state.colleges.map((college, i) => {
+ return ;
+ })}
+
+ );
+ }
+}
+
+export default FavoritesPage;
diff --git a/client/src/components/Header.jsx b/client/src/components/Header.jsx
index 584f899..f78975e 100644
--- a/client/src/components/Header.jsx
+++ b/client/src/components/Header.jsx
@@ -1,10 +1,14 @@
-const Header = () => {
+import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router';
+const Header = (props) => {
return (
);
diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx
index d2bca2a..800f76f 100644
--- a/client/src/components/ResultListEntry.jsx
+++ b/client/src/components/ResultListEntry.jsx
@@ -4,6 +4,14 @@ import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRo
class ResultListEntry extends React.Component {
constructor(props) {
super(props);
+ this.state = {
+ favColleges: ""
+ }
+ this.addToFav = this.addToFav.bind(this);
+ }
+
+ addToFav(e) {
+ this.props.handleFav(this.props.college);
}
render () {
@@ -16,6 +24,7 @@ class ResultListEntry extends React.Component {
{college.name}
{college.description}
+
);
diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx
index d047acc..d631e01 100644
--- a/client/src/components/Results.jsx
+++ b/client/src/components/Results.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import axios from 'axios';
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router';
-
+import Cookies from 'js-cookie';
import ResultListEntry from './ResultListEntry.jsx';
class Results extends React.Component {
@@ -9,8 +9,11 @@ class Results extends React.Component {
super(props);
this.state = {
- colleges: []
+ colleges: [],
+ favColleges: []
};
+ this.handleFavColleges = this.handleFavColleges.bind(this);
+ this.handleCookies = this.handleCookies.bind(this);
}
componentDidMount() {
@@ -46,11 +49,36 @@ class Results extends React.Component {
});
}
+ handleFavColleges(college) {
+ let prev = this.state.favColleges;
+ let col = college;
+ let alreadyIn = false;
+ for(let i = 0; i < prev.length; i++){
+ if(col === prev[i]){
+ alreadyIn = true;
+ console.log("Already Favorited");
+ }
+ }
+ if(alreadyIn === false){
+ prev.push(col);
+ this.setState({favColleges: prev})
+ this.handleCookies();
+ }else{
+ this.setState({favColleges: prev})
+ this.handleCookies();
+ }
+ }
+
+ handleCookies(){
+ let fav = this.state.favColleges.slice(0);
+ Cookies.set("colleges", fav);
+ }
+
render() {
return (
{this.state.colleges.map((college, i) => {
- return ;
+ return ;
})}
);
diff --git a/client/src/index.jsx b/client/src/index.jsx
index d69d5ee..d8940cb 100644
--- a/client/src/index.jsx
+++ b/client/src/index.jsx
@@ -2,20 +2,29 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router';
import io from 'socket.io-client';
+import Cookies from 'js-cookie';
import Home from './components/Home.jsx';
import Container from './components/Container.jsx';
+import FavoritesPage from './components/FavoritesPage.jsx'
import Results from './components/Results.jsx';
import Survey from './components/Survey.jsx';
import CommentsPage from './components/CommentsPage.jsx';
class App extends React.Component {
+ constructor(props){
+ super(props);
+ this.state = {
+ }
+ }
+
render() {
return (
+
diff --git a/package.json b/package.json
index 13cfa32..0580c6e 100755
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"express-partials": "^0.3.0",
"express-session": "^1.15.2",
"jquery": "^3.2.1",
+ "js-cookie": "^2.1.4",
"lodash": "^4.17.4",
"morgan": "^1.8.1",
"mysql": "^2.13.0",
diff --git a/public/styles.css b/public/styles.css
index 688c830..6fdec24 100644
--- a/public/styles.css
+++ b/public/styles.css
@@ -212,7 +212,7 @@ input[type=radio] {
/* School name links to school homepage */
a:link {
- color: #373737;
+ color: #C0B283;
text-decoration: none;
}