From 36c1f9621b9de834612b097772d47786fd4cb4d9 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Fri, 19 May 2017 15:27:25 -0700 Subject: [PATCH 01/12] (feat) Add favorites link on main bar and favorite button to uni-list. --- client/src/components/Header.jsx | 3 +++ client/src/components/ResultListEntry.jsx | 1 + 2 files changed, 4 insertions(+) diff --git a/client/src/components/Header.jsx b/client/src/components/Header.jsx index 584f899..1f15a5d 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -5,6 +5,9 @@ const Header = () => {
UforU
+
+ Favorite Universities +
); diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx index d2bca2a..d70a85c 100644 --- a/client/src/components/ResultListEntry.jsx +++ b/client/src/components/ResultListEntry.jsx @@ -16,6 +16,7 @@ class ResultListEntry extends React.Component { {college.name}

{college.description}

+ ); From 5d87c86e6d8e72db14a1387d52d003f66f97240f Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 10:54:01 -0700 Subject: [PATCH 02/12] (Feat) Pass favorite universities link/method from top level parent. --- client/src/components/Container.jsx | 2 +- client/src/components/Header.jsx | 4 ++-- client/src/components/ResultListEntry.jsx | 11 ++++++++++- client/src/components/Results.jsx | 15 +++++++++++++-- client/src/index.jsx | 12 +++++++++++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/client/src/components/Container.jsx b/client/src/components/Container.jsx index cf60f43..cdaa940 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/Header.jsx b/client/src/components/Header.jsx index 1f15a5d..a6dedaa 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -1,4 +1,4 @@ -const Header = () => { +const Header = (props) => { return ( diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx index d70a85c..bfb7f5e 100644 --- a/client/src/components/ResultListEntry.jsx +++ b/client/src/components/ResultListEntry.jsx @@ -4,6 +4,15 @@ 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) { + console.log(this.props.college); + this.props.handleFav(this.props.college); } render () { @@ -16,7 +25,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..9fe9e45 100644 --- a/client/src/components/Results.jsx +++ b/client/src/components/Results.jsx @@ -9,8 +9,13 @@ class Results extends React.Component { super(props); this.state = { - colleges: [] + colleges: [], + favColleges: [] }; + let fav = this.state.favColleges.splice(0); + JSON.stringify(fav); + document.cookie = fav; + this.handleFavColleges = this.handleFavColleges.bind(this); } componentDidMount() { @@ -46,11 +51,17 @@ class Results extends React.Component { }); } + handleFavColleges(college) { + var prev = this.state.favColleges; + prev.push(college); + this.setState({favColleges: prev}) + } + render() { return (
{this.state.colleges.map((college, i) => { - return ; + return ; })}
); diff --git a/client/src/index.jsx b/client/src/index.jsx index d69d5ee..a2ed4bd 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -10,10 +10,20 @@ import Survey from './components/Survey.jsx'; import CommentsPage from './components/CommentsPage.jsx'; class App extends React.Component { + constructor(props){ + super(props); + this.state = { + favColleges: [] + } + this.handleFav = this.handleFav.bind(this); + } + handleFav(){ + console.log("Yall DJ house parties."); + } render() { return ( - + From 52d3df1ad642c69218106f0810e0044388822894 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 11:27:47 -0700 Subject: [PATCH 03/12] (feat) Installed js-cookie library. --- client/src/components/Results.jsx | 4 ++-- client/src/index.jsx | 3 ++- package.json | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx index 9fe9e45..1c45a7d 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 { @@ -14,7 +14,7 @@ class Results extends React.Component { }; let fav = this.state.favColleges.splice(0); JSON.stringify(fav); - document.cookie = fav; + Cookies.set = ("prateek", "is cool"); this.handleFavColleges = this.handleFavColleges.bind(this); } diff --git a/client/src/index.jsx b/client/src/index.jsx index a2ed4bd..cb00fa3 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -2,6 +2,7 @@ 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'; @@ -18,7 +19,7 @@ class App extends React.Component { this.handleFav = this.handleFav.bind(this); } handleFav(){ - console.log("Yall DJ house parties."); + console.log(Cookies.get("prateek")); } 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", From a8a83aa34faadfe56703f6bcca92ce5ce4f4d6de Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 14:25:34 -0700 Subject: [PATCH 04/12] (feat)Add react router link (n/c). --- client/src/components/Results.jsx | 15 ++++++++++----- client/src/index.jsx | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx index 1c45a7d..7259673 100644 --- a/client/src/components/Results.jsx +++ b/client/src/components/Results.jsx @@ -12,10 +12,8 @@ class Results extends React.Component { colleges: [], favColleges: [] }; - let fav = this.state.favColleges.splice(0); - JSON.stringify(fav); - Cookies.set = ("prateek", "is cool"); this.handleFavColleges = this.handleFavColleges.bind(this); + this.handleCookies = this.handleCookies.bind(this); } componentDidMount() { @@ -52,9 +50,16 @@ class Results extends React.Component { } handleFavColleges(college) { - var prev = this.state.favColleges; - prev.push(college); + let prev = this.state.favColleges; + let col = college; + prev.push(col); this.setState({favColleges: prev}) + this.handleCookies(); + } + + handleCookies(){ + let fav = this.state.favColleges.slice(0); + Cookies.set("colleges", fav); } render() { diff --git a/client/src/index.jsx b/client/src/index.jsx index cb00fa3..4a572cb 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -14,19 +14,23 @@ class App extends React.Component { constructor(props){ super(props); this.state = { + fav: false, favColleges: [] } - this.handleFav = this.handleFav.bind(this); + this.handleFav = this.handleFav.bind(this); } + handleFav(){ - console.log(Cookies.get("prateek")); + this.state.fav = true; } + render() { return ( - + + From 925cca9e4897522d03c8a5849e4ec337156103dc Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 14:57:48 -0700 Subject: [PATCH 05/12] (feat) Implement favorite university feature/ route. --- client/src/components/FavoritesPage.jsx | 27 +++++++++++++++++++++++++ client/src/components/Header.jsx | 3 ++- client/src/index.jsx | 6 ++++-- public/styles.css | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 client/src/components/FavoritesPage.jsx diff --git a/client/src/components/FavoritesPage.jsx b/client/src/components/FavoritesPage.jsx new file mode 100644 index 0000000..4f84e64 --- /dev/null +++ b/client/src/components/FavoritesPage.jsx @@ -0,0 +1,27 @@ +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") + }; + } + + 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 a6dedaa..f78975e 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -1,3 +1,4 @@ +import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router'; const Header = (props) => { return ( diff --git a/client/src/index.jsx b/client/src/index.jsx index 4a572cb..5ffd653 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -6,6 +6,7 @@ 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'; @@ -21,7 +22,8 @@ class App extends React.Component { } handleFav(){ - this.state.fav = true; + this.state.fav = true; + console.log(Cookies.getJSON("colleges")); } render() { @@ -30,7 +32,7 @@ class App extends React.Component { - +
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; } From 4ae04fb5f442239baa001b9a0ea4cfb82b004b96 Mon Sep 17 00:00:00 2001 From: Eric Pan Date: Sat, 20 May 2017 15:07:24 -0700 Subject: [PATCH 06/12] (bug) Try connecting sockets without URL --- client/src/components/CommentsBody.jsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/client/src/components/CommentsBody.jsx b/client/src/components/CommentsBody.jsx index 4beacb5..39555b6 100644 --- a/client/src/components/CommentsBody.jsx +++ b/client/src/components/CommentsBody.jsx @@ -12,18 +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); } From 195812a37fd1ee0088db0053fb3b2f6566c0ee60 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Fri, 19 May 2017 15:27:25 -0700 Subject: [PATCH 07/12] (feat) Add favorites link on main bar and favorite button to uni-list. --- client/src/components/Header.jsx | 3 +++ client/src/components/ResultListEntry.jsx | 1 + 2 files changed, 4 insertions(+) diff --git a/client/src/components/Header.jsx b/client/src/components/Header.jsx index 584f899..1f15a5d 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -5,6 +5,9 @@ const Header = () => {
UforU
+
+ Favorite Universities +
); diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx index d2bca2a..d70a85c 100644 --- a/client/src/components/ResultListEntry.jsx +++ b/client/src/components/ResultListEntry.jsx @@ -16,6 +16,7 @@ class ResultListEntry extends React.Component { {college.name}

{college.description}

+ ); From 1ec4ff2cb13e559f891c3fadc9d7dd427d31bba0 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 10:54:01 -0700 Subject: [PATCH 08/12] (Feat) Pass favorite universities link/method from top level parent. --- client/src/components/Container.jsx | 2 +- client/src/components/Header.jsx | 4 ++-- client/src/components/ResultListEntry.jsx | 11 ++++++++++- client/src/components/Results.jsx | 15 +++++++++++++-- client/src/index.jsx | 12 +++++++++++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/client/src/components/Container.jsx b/client/src/components/Container.jsx index cf60f43..cdaa940 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/Header.jsx b/client/src/components/Header.jsx index 1f15a5d..a6dedaa 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -1,4 +1,4 @@ -const Header = () => { +const Header = (props) => { return ( diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx index d70a85c..bfb7f5e 100644 --- a/client/src/components/ResultListEntry.jsx +++ b/client/src/components/ResultListEntry.jsx @@ -4,6 +4,15 @@ 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) { + console.log(this.props.college); + this.props.handleFav(this.props.college); } render () { @@ -16,7 +25,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..9fe9e45 100644 --- a/client/src/components/Results.jsx +++ b/client/src/components/Results.jsx @@ -9,8 +9,13 @@ class Results extends React.Component { super(props); this.state = { - colleges: [] + colleges: [], + favColleges: [] }; + let fav = this.state.favColleges.splice(0); + JSON.stringify(fav); + document.cookie = fav; + this.handleFavColleges = this.handleFavColleges.bind(this); } componentDidMount() { @@ -46,11 +51,17 @@ class Results extends React.Component { }); } + handleFavColleges(college) { + var prev = this.state.favColleges; + prev.push(college); + this.setState({favColleges: prev}) + } + render() { return (
{this.state.colleges.map((college, i) => { - return ; + return ; })}
); diff --git a/client/src/index.jsx b/client/src/index.jsx index d69d5ee..a2ed4bd 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -10,10 +10,20 @@ import Survey from './components/Survey.jsx'; import CommentsPage from './components/CommentsPage.jsx'; class App extends React.Component { + constructor(props){ + super(props); + this.state = { + favColleges: [] + } + this.handleFav = this.handleFav.bind(this); + } + handleFav(){ + console.log("Yall DJ house parties."); + } render() { return ( - + From a772c66bb5b1511dd5578bbe621eeeb53e3545f9 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 11:27:47 -0700 Subject: [PATCH 09/12] (feat) Installed js-cookie library. --- client/src/components/Results.jsx | 4 ++-- client/src/index.jsx | 3 ++- package.json | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx index 9fe9e45..1c45a7d 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 { @@ -14,7 +14,7 @@ class Results extends React.Component { }; let fav = this.state.favColleges.splice(0); JSON.stringify(fav); - document.cookie = fav; + Cookies.set = ("prateek", "is cool"); this.handleFavColleges = this.handleFavColleges.bind(this); } diff --git a/client/src/index.jsx b/client/src/index.jsx index a2ed4bd..cb00fa3 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -2,6 +2,7 @@ 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'; @@ -18,7 +19,7 @@ class App extends React.Component { this.handleFav = this.handleFav.bind(this); } handleFav(){ - console.log("Yall DJ house parties."); + console.log(Cookies.get("prateek")); } 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", From 383e50da170f94aba2c81c0fbbf5c1f831db9d35 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 14:25:34 -0700 Subject: [PATCH 10/12] (feat)Add react router link (n/c). --- client/src/components/Results.jsx | 15 ++++++++++----- client/src/index.jsx | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx index 1c45a7d..7259673 100644 --- a/client/src/components/Results.jsx +++ b/client/src/components/Results.jsx @@ -12,10 +12,8 @@ class Results extends React.Component { colleges: [], favColleges: [] }; - let fav = this.state.favColleges.splice(0); - JSON.stringify(fav); - Cookies.set = ("prateek", "is cool"); this.handleFavColleges = this.handleFavColleges.bind(this); + this.handleCookies = this.handleCookies.bind(this); } componentDidMount() { @@ -52,9 +50,16 @@ class Results extends React.Component { } handleFavColleges(college) { - var prev = this.state.favColleges; - prev.push(college); + let prev = this.state.favColleges; + let col = college; + prev.push(col); this.setState({favColleges: prev}) + this.handleCookies(); + } + + handleCookies(){ + let fav = this.state.favColleges.slice(0); + Cookies.set("colleges", fav); } render() { diff --git a/client/src/index.jsx b/client/src/index.jsx index cb00fa3..4a572cb 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -14,19 +14,23 @@ class App extends React.Component { constructor(props){ super(props); this.state = { + fav: false, favColleges: [] } - this.handleFav = this.handleFav.bind(this); + this.handleFav = this.handleFav.bind(this); } + handleFav(){ - console.log(Cookies.get("prateek")); + this.state.fav = true; } + render() { return ( - + + From 11f9f9c33d2867f6347c7fb5d4158b834f44d805 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Sat, 20 May 2017 14:57:48 -0700 Subject: [PATCH 11/12] (feat) Implement favorite university feature/ route. --- client/src/components/FavoritesPage.jsx | 27 +++++++++++++++++++++++++ client/src/components/Header.jsx | 3 ++- client/src/index.jsx | 6 ++++-- public/styles.css | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 client/src/components/FavoritesPage.jsx diff --git a/client/src/components/FavoritesPage.jsx b/client/src/components/FavoritesPage.jsx new file mode 100644 index 0000000..4f84e64 --- /dev/null +++ b/client/src/components/FavoritesPage.jsx @@ -0,0 +1,27 @@ +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") + }; + } + + 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 a6dedaa..f78975e 100644 --- a/client/src/components/Header.jsx +++ b/client/src/components/Header.jsx @@ -1,3 +1,4 @@ +import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router'; const Header = (props) => { return ( diff --git a/client/src/index.jsx b/client/src/index.jsx index 4a572cb..5ffd653 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -6,6 +6,7 @@ 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'; @@ -21,7 +22,8 @@ class App extends React.Component { } handleFav(){ - this.state.fav = true; + this.state.fav = true; + console.log(Cookies.getJSON("colleges")); } render() { @@ -30,7 +32,7 @@ class App extends React.Component { - +
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; } From 22482ca3ce9165d59a624b9d4053ba7e660e3f28 Mon Sep 17 00:00:00 2001 From: bhattprateek Date: Mon, 22 May 2017 09:07:48 -0700 Subject: [PATCH 12/12] (refactor) Fix duplicate favorites. --- client/src/components/Container.jsx | 2 +- client/src/components/FavoritesPage.jsx | 9 ++++++++- client/src/components/ResultListEntry.jsx | 1 - client/src/components/Results.jsx | 18 +++++++++++++++--- client/src/index.jsx | 12 ++---------- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/client/src/components/Container.jsx b/client/src/components/Container.jsx index cdaa940..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 index 4f84e64..4b0ab2c 100644 --- a/client/src/components/FavoritesPage.jsx +++ b/client/src/components/FavoritesPage.jsx @@ -11,13 +11,20 @@ class FavoritesPage extends React.Component { 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 ; + return ; })}
); diff --git a/client/src/components/ResultListEntry.jsx b/client/src/components/ResultListEntry.jsx index bfb7f5e..800f76f 100644 --- a/client/src/components/ResultListEntry.jsx +++ b/client/src/components/ResultListEntry.jsx @@ -11,7 +11,6 @@ class ResultListEntry extends React.Component { } addToFav(e) { - console.log(this.props.college); this.props.handleFav(this.props.college); } diff --git a/client/src/components/Results.jsx b/client/src/components/Results.jsx index 7259673..d631e01 100644 --- a/client/src/components/Results.jsx +++ b/client/src/components/Results.jsx @@ -52,9 +52,21 @@ class Results extends React.Component { handleFavColleges(college) { let prev = this.state.favColleges; let col = college; - prev.push(col); - this.setState({favColleges: prev}) - this.handleCookies(); + 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(){ diff --git a/client/src/index.jsx b/client/src/index.jsx index 5ffd653..1a86e63 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -15,21 +15,13 @@ class App extends React.Component { constructor(props){ super(props); this.state = { - fav: false, - favColleges: [] - } - this.handleFav = this.handleFav.bind(this); - } - - handleFav(){ - this.state.fav = true; - console.log(Cookies.getJSON("colleges")); + } } render() { return ( - +