From 9f27db217e5f5542bd770c2e59da50873ca54af3 Mon Sep 17 00:00:00 2001 From: evanska348 Date: Mon, 5 Mar 2018 20:10:39 -0800 Subject: [PATCH 01/11] added email state to app --- .DS_Store | Bin 8196 -> 8196 bytes myapp/src/App.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.DS_Store b/.DS_Store index 729469a77cfb7cff1ecc6456e369af411f1b0a84..f14dec17d8eaccb1a99cb4d7ed396cc269a52eb0 100644 GIT binary patch delta 20 bcmZp1XmQw}DadYSXriNFY_{1z@CqLQJ!A!- delta 20 bcmZp1XmQw}DadYWX`-WGY_Zuu@CqLQJ-h{} diff --git a/myapp/src/App.js b/myapp/src/App.js index eb7324d..cea717a 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -10,18 +10,37 @@ import { NavLink } from 'react-router-dom'; class App extends Component { - constructor(props) { - super(props); + constructor() { + super(); + this.handleData = this.handleData.bind(this); + this.state = { + email: '', + }; + } + + handleData(data) { + this.setState({ + email: data + }); } render() { return (
- {/*

Find your Climb!

*/}

Find your Climb!

+ {/* {firebase.auth().fetchProvidersForEmail(this.state.email) + .then(providers => { + if (providers.length === 0) { + + } else { + +
Profile
+
+ } + })} */}
Routes
@@ -33,7 +52,10 @@ class App extends Component { - + + ( + + )} />
@@ -68,6 +90,7 @@ class LoginPage extends Component { componentDidMount() { this.stopWatchingAuth = firebase.auth().onAuthStateChanged(firebaseUser => { if (firebaseUser) { + this.props.handlerFromParent(this.state.email); this.setState({ user: firebaseUser, errorMessage: '', @@ -106,14 +129,12 @@ class LoginPage extends Component { handleSignIn() { //A callback function for logging in existing users - /* Sign in the user */ firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password) .catch((err) => { console.log(err) this.setState({ errorMessage: err.message }) }); - } handleSignOut() { From 44cbf91985392dc4ce2f062d70ca84346c80adb3 Mon Sep 17 00:00:00 2001 From: Sohrab Date: Mon, 5 Mar 2018 23:20:29 -0800 Subject: [PATCH 02/11] Adding to databse --- myapp/src/App.js | 62 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/myapp/src/App.js b/myapp/src/App.js index cea717a..3a11221 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -271,10 +271,11 @@ class RoutesPage extends Component { } class ClimbCard extends React.Component { - constructor() { - super() + constructor(props) { + super(props) this.state = { - isHidden: true + isHidden: true, + } } toggleHidden() { @@ -282,6 +283,58 @@ class ClimbCard extends React.Component { isHidden: !this.state.isHidden }) } + // componentWillMount() { + // this.firebaseRef = new Firebase("https://ReactFireTodoApp.firebaseio.com/items/"); + // this.firebaseRef.on("child_added", function (dataSnapshot) { + // this.items.push(dataSnapshot.val()); + // this.setState({ + // items: this.items + // }); + // }.bind(this)); + // } + + pushLikeToFireBase() { + console.log("IM PUSHING"); + let UserRef = firebase.database().ref('Users'); + let dataName = this.props.name; + Object.keys(UserRef).forEach((key) => { + + if (key === this.state.email) { + UserRef.child(key).child('Climbs').push({ + Name: this.props.name, + Type: this.props.type, + Rating: this.props.rating, + Stars: this.props.stars, + Pitches: this.props.pitches, + Location: this.props.location + + }).catch(err => console.log(err)); + } else { + firebase.database().ref('Users/' + key).set( + + { + 'Climbs': + { + dataName: { + Name: this.props.name, + Type: this.props.type, + Rating: this.props.rating, + Stars: this.props.stars, + Pitches: this.props.pitches, + Location: this.props.location + } + + } + } + + + ).catch(err => console.log(err)); + } + }) + } + + + render() { let pitches = this.props.pitches; if (pitches === '') { @@ -300,8 +353,11 @@ class ClimbCard extends React.Component {

Stars: {this.props.stars}

Pitches: {pitches}

Location: {this.props.location}

+
+ } + {} ) } From a85ec1879684d620d329275e4743a83fac8c3d37 Mon Sep 17 00:00:00 2001 From: evanska348 Date: Mon, 5 Mar 2018 23:23:08 -0800 Subject: [PATCH 03/11] added logout functionality --- myapp/src/App.js | 110 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 35 deletions(-) diff --git a/myapp/src/App.js b/myapp/src/App.js index cea717a..bd374bc 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -12,51 +12,68 @@ class App extends Component { constructor() { super(); - this.handleData = this.handleData.bind(this); + // this.handleData = this.handleData.bind(this); + this.handleLogout = this.handleLogout.bind(this); + this.handleUser = this.handleUser.bind(this); this.state = { - email: '', + user: '' }; } - handleData(data) { + handleLogout() { + this.setState({ + user: '' + }); + firebase.auth().signOut() + .catch((err) => { + console.log(err) + }) + } + + handleUser(data) { + console.log(data) this.setState({ - email: data + user: data }); } render() { + console.log(this.state.email) return (
+

Find your Climb!

- {/* {firebase.auth().fetchProvidersForEmail(this.state.email) - .then(providers => { - if (providers.length === 0) { - - } else { - -
Profile
-
- } - })} */} + {this.state.user !== '' && + +
Profile
+
+ } +
Routes
Types
- -
Login
-
+ {this.state.user === '' ? + +
Login
+
+ : + + } - ( - + )} /> + ( + + )} />
@@ -90,7 +107,7 @@ class LoginPage extends Component { componentDidMount() { this.stopWatchingAuth = firebase.auth().onAuthStateChanged(firebaseUser => { if (firebaseUser) { - this.props.handlerFromParent(this.state.email); + this.props.history.push("/routes"); this.setState({ user: firebaseUser, errorMessage: '', @@ -98,12 +115,16 @@ class LoginPage extends Component { password: '', username: '' }); + this.props.handlerFromParent(this.state.user); } else { this.setState({ user: null }); //null out the saved state } }) } + componentWillUnmount() { + this.stopWatchingAuth(); + } handleSignUp() { /* Create a new user and save their information */ @@ -131,25 +152,33 @@ class LoginPage extends Component { /* Sign in the user */ firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password) + .then(user => { + this.setState({ + user: user + }) + this.props.history.push("/profile"); + console.clear() + console.log(user) + }) .catch((err) => { - console.log(err) + console.log(err.message) this.setState({ errorMessage: err.message }) }); } - handleSignOut() { - this.setState({ errorMessage: null }); //clear old error + // handleSignOut() { + // this.setState({ errorMessage: null }); //clear old error - /* Sign out the user, and update the state */ - firebase.auth().signOut() - .then(() => { - this.setState({ user: null }); //null out the saved state - }) - .catch((err) => { - console.log(err) - this.setState({ errorMessage: err.message }) - }) - } + // /* Sign out the user, and update the state */ + // firebase.auth().signOut() + // .then(() => { + // this.setState({ user: null }); //null out the saved state + // }) + // .catch((err) => { + // console.log(err) + // this.setState({ errorMessage: err.message }) + // }) + // } handleChange(event) { let field = event.target.name; //which input @@ -206,9 +235,9 @@ class LoginPage extends Component { - + */}
); @@ -510,4 +539,15 @@ class AboutPage extends Component { } + +class ProfilePage extends Component { + + render() { + return ( +
+ {/*

{this.props.email}

*/} +
+ ); + } +} export default App; From 259f755455f5ed016dbfda2ebcf44fbaca1b856a Mon Sep 17 00:00:00 2001 From: Sohrab Date: Tue, 6 Mar 2018 01:28:12 -0800 Subject: [PATCH 04/11] Succesfully adds onto firebase --- myapp/src/App.css | 4 +- myapp/src/App.js | 99 ++++++++++++++++++++++------------------------- 2 files changed, 49 insertions(+), 54 deletions(-) diff --git a/myapp/src/App.css b/myapp/src/App.css index 5660ac2..dc4bce3 100644 --- a/myapp/src/App.css +++ b/myapp/src/App.css @@ -147,10 +147,10 @@ button { } button:after { - content: '\00bb'; + /* content: '\00bb'; */ position: absolute; opacity: 0; top: 0; - right: -20px; + /* right: -20px; */ transition: 0.5s; } \ No newline at end of file diff --git a/myapp/src/App.js b/myapp/src/App.js index 9af1298..8ebdc84 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -31,14 +31,12 @@ class App extends Component { } handleUser(data) { - console.log(data) this.setState({ user: data }); } render() { - console.log(this.state.email) return (
@@ -63,10 +61,18 @@ class App extends Component {
Login
: - + } - + {this.state.user === '' ? + ( + + )} /> + : + ( + + )} /> + } ( )} /> @@ -107,7 +113,7 @@ class LoginPage extends Component { componentDidMount() { this.stopWatchingAuth = firebase.auth().onAuthStateChanged(firebaseUser => { if (firebaseUser) { - this.props.history.push("/routes"); + // this.props.history.push("/routes"); this.setState({ user: firebaseUser, errorMessage: '', @@ -156,9 +162,6 @@ class LoginPage extends Component { this.setState({ user: user }) - this.props.history.push("/profile"); - console.clear() - console.log(user) }) .catch((err) => { console.log(err.message) @@ -166,20 +169,6 @@ class LoginPage extends Component { }); } - // handleSignOut() { - // this.setState({ errorMessage: null }); //clear old error - - // /* Sign out the user, and update the state */ - // firebase.auth().signOut() - // .then(() => { - // this.setState({ user: null }); //null out the saved state - // }) - // .catch((err) => { - // console.log(err) - // this.setState({ errorMessage: err.message }) - // }) - // } - handleChange(event) { let field = event.target.name; //which input let value = event.target.value; //what value @@ -287,7 +276,7 @@ class RoutesPage extends Component { this.handleSubmit(latLongParams)} />
- +
@@ -312,6 +301,7 @@ class ClimbCard extends React.Component { isHidden: !this.state.isHidden }) } + // componentWillMount() { // this.firebaseRef = new Firebase("https://ReactFireTodoApp.firebaseio.com/items/"); // this.firebaseRef.on("child_added", function (dataSnapshot) { @@ -323,48 +313,49 @@ class ClimbCard extends React.Component { // } pushLikeToFireBase() { + // if (!this.props.uid) { console.log("IM PUSHING"); let UserRef = firebase.database().ref('Users'); let dataName = this.props.name; + let foundKey = false; Object.keys(UserRef).forEach((key) => { - - if (key === this.state.email) { + if (key === this.props.uid) { + foundKey = true; UserRef.child(key).child('Climbs').push({ Name: this.props.name, Type: this.props.type, Rating: this.props.rating, Stars: this.props.stars, Pitches: this.props.pitches, - Location: this.props.location + Location: this.props.location, + Id: this.props.id }).catch(err => console.log(err)); - } else { - firebase.database().ref('Users/' + key).set( - - { - 'Climbs': - { - dataName: { - Name: this.props.name, - Type: this.props.type, - Rating: this.props.rating, - Stars: this.props.stars, - Pitches: this.props.pitches, - Location: this.props.location - } - - } - } - - - ).catch(err => console.log(err)); } - }) + } + ) + if (!foundKey) { + firebase.database().ref('Users/' + this.props.uid + '/Climbs/' + this.props.id + "/").set( + { + Name: this.props.name, + Type: this.props.type, + Rating: this.props.rating, + Stars: this.props.stars, + Pitches: this.props.pitches, + Location: this.props.location, + Id: this.props.id + } + ).catch(err => console.log(err)); + } + + foundKey = false; } + // } render() { + console.log(this.props.uid) let pitches = this.props.pitches; if (pitches === '') { pitches = "N/A"; @@ -382,11 +373,17 @@ class ClimbCard extends React.Component {

Stars: {this.props.stars}

Pitches: {pitches}

Location: {this.props.location}

+ {this.props.uid === '' && + + } + {this.props.uid !== '' && + + } } - {} + ) } @@ -399,11 +396,9 @@ class ClimbList extends React.Component { let dict = _(this.props.routes) .countBy('type') .value() - let arr = []; let combined = 0; Object.keys(dict).forEach((key) => { - console.log(key, dict[key]); if (!key.includes(',')) { arr.push({ name: key, value: dict[key] }) } else { @@ -457,7 +452,7 @@ class ClimbList extends React.Component {
{ this.props.routes.map((climb) => - ) }
@@ -511,7 +506,7 @@ class ClimbParam extends React.Component { onChange={this.handleChange} />
- +

Notable Locations:

From b2d9bdbe126298dab4889ef99a8b325f809a7b89 Mon Sep 17 00:00:00 2001 From: Sohrab Date: Tue, 6 Mar 2018 02:16:53 -0800 Subject: [PATCH 05/11] Like Counter works --- myapp/src/App.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/myapp/src/App.js b/myapp/src/App.js index 8ebdc84..93e715a 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -312,6 +312,21 @@ class ClimbCard extends React.Component { // }.bind(this)); // } + countLikesToFireBase() { + console.log("IM FUCKIN PUSHING CALM UR TITS"); + firebase.database().ref('Post/' + this.props.id + "/Likes").transaction(function (Likes) { + console.log("likes", Likes); + if (Likes) { + + Likes = Likes + 1; + } else { + Likes = 1; + } + return Likes; + }); + + } + pushLikeToFireBase() { // if (!this.props.uid) { console.log("IM PUSHING"); @@ -379,6 +394,11 @@ class ClimbCard extends React.Component { } {this.props.uid !== '' && + + } + {this.props.uid !== '' && + + }
From 75152c7fff886750073d282c11e79efa13f544d2 Mon Sep 17 00:00:00 2001 From: Sohrab Date: Tue, 6 Mar 2018 04:42:11 -0800 Subject: [PATCH 06/11] Just needs some Css tweaking and comments --- myapp/src/App.css | 5 ++++ myapp/src/App.js | 62 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/myapp/src/App.css b/myapp/src/App.css index dc4bce3..3329bc9 100644 --- a/myapp/src/App.css +++ b/myapp/src/App.css @@ -1,3 +1,8 @@ +footer { + bottom: 0; + position: fixed; +} + .App { text-align: center; top: 0; diff --git a/myapp/src/App.js b/myapp/src/App.js index 93e715a..b299f20 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -78,7 +78,7 @@ class App extends Component { )} /> ( - + )} /> @@ -293,7 +293,7 @@ class ClimbCard extends React.Component { super(props) this.state = { isHidden: true, - + likes: '' } } toggleHidden() { @@ -313,7 +313,7 @@ class ClimbCard extends React.Component { // } countLikesToFireBase() { - console.log("IM FUCKIN PUSHING CALM UR TITS"); + firebase.database().ref('Post/' + this.props.id + "/Likes").transaction(function (Likes) { console.log("likes", Likes); if (Likes) { @@ -327,9 +327,11 @@ class ClimbCard extends React.Component { } + + pushLikeToFireBase() { // if (!this.props.uid) { - console.log("IM PUSHING"); + let UserRef = firebase.database().ref('Users'); let dataName = this.props.name; let foundKey = false; @@ -343,6 +345,7 @@ class ClimbCard extends React.Component { Stars: this.props.stars, Pitches: this.props.pitches, Location: this.props.location, + Image: this.props.img, Id: this.props.id }).catch(err => console.log(err)); @@ -358,6 +361,7 @@ class ClimbCard extends React.Component { Stars: this.props.stars, Pitches: this.props.pitches, Location: this.props.location, + Image: this.props.img, Id: this.props.id } ).catch(err => console.log(err)); @@ -367,7 +371,13 @@ class ClimbCard extends React.Component { } // } - + componentDidMount() { + firebase.database().ref('Post/' + this.props.id + "/Likes").on('value', (snapshot) => { + this.setState({ + likes: snapshot.val() + }); + }) + } render() { console.log(this.props.uid) @@ -388,6 +398,7 @@ class ClimbCard extends React.Component {

Stars: {this.props.stars}

Pitches: {pitches}

Location: {this.props.location}

+

Likes: {this.state.likes === '' ? "0" : this.state.likes}

{this.props.uid === '' && @@ -612,12 +623,47 @@ class AboutPage extends Component { class ProfilePage extends Component { + constructor(props) { + super(props) + this.state = { + climbs: '' + } + } + + componentDidMount() { + if (this.props.uid !== undefined) { + let ref = firebase.database().ref('Users').child(this.props.uid).child('Climbs'); + ref.on('value', (snapshot) => { + this.setState({ + climbs: snapshot.val() + }); + console.log(this.state.climbs); + + console.log(snapshot.val()) + }) + + } + } render() { return ( -
- {/*

{this.props.email}

*/} -
+ + < div > +

Welcome to your Profile!

+

Here are your saved climbs!

+
+
+ + {this.state.climbs !== null && + Object.keys(this.state.climbs).map((climb) => + // console.log(this.state.climbs[climb])) + < ClimbCard uid={this.props.uid} key={this.state.climbs[climb].Id} id={this.state.climbs[climb].Id} img={this.state.climbs[climb].Image} name={this.state.climbs[climb].Name} type={this.state.climbs[climb].Type} + rating={this.state.climbs[climb].Rating} stars={this.state.climbs[climb].Stars} pitches={this.state.climbs[climb].Pitches} location={this.state.climbs[climb].Location} />) + } + +
+
+ ); } } From fe64820b320216ac4565a0aa97d73b0884d1bca4 Mon Sep 17 00:00:00 2001 From: evanska348 Date: Tue, 6 Mar 2018 05:02:49 -0800 Subject: [PATCH 07/11] fixed some styling --- myapp/src/App.css | 10 +++++----- myapp/src/App.js | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/myapp/src/App.css b/myapp/src/App.css index 3329bc9..11f5b52 100644 --- a/myapp/src/App.css +++ b/myapp/src/App.css @@ -1,8 +1,3 @@ -footer { - bottom: 0; - position: fixed; -} - .App { text-align: center; top: 0; @@ -158,4 +153,9 @@ button:after { top: 0; /* right: -20px; */ transition: 0.5s; +} + +footer { + bottom: 0; + position: fixed; } \ No newline at end of file diff --git a/myapp/src/App.js b/myapp/src/App.js index b299f20..5df5079 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -560,6 +560,11 @@ class ClimbParam extends React.Component {

Lat: 46.9454

Lon: -119.9873

+
+
SmithRock
+

Lat: 44.3682

+

Lon: -121.1406

+
); } From 39b0d56cf956dad8bc93cae89a4545a1d0d9ea91 Mon Sep 17 00:00:00 2001 From: Sohrab Date: Tue, 6 Mar 2018 05:14:40 -0800 Subject: [PATCH 08/11] comments are done --- myapp/src/App.css | 15 +++++++++------ myapp/src/App.js | 49 ++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/myapp/src/App.css b/myapp/src/App.css index 3329bc9..71cef39 100644 --- a/myapp/src/App.css +++ b/myapp/src/App.css @@ -1,8 +1,3 @@ -footer { - bottom: 0; - position: fixed; -} - .App { text-align: center; top: 0; @@ -60,7 +55,7 @@ nav { text-align: center; } -h1, footer { +h1 { margin: 0; padding: 1.5vh; padding-left: 1.5vw; @@ -158,4 +153,12 @@ button:after { top: 0; /* right: -20px; */ transition: 0.5s; +} + +footer { + bottom: 0; + position: fixed; + padding-left: 1rem; + padding-bottom: 0; + margin-bottom: 0; } \ No newline at end of file diff --git a/myapp/src/App.js b/myapp/src/App.js index b299f20..defc13e 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -5,14 +5,15 @@ import firebase from 'firebase'; import 'firebase/auth'; import 'firebase/database'; import { PieChart, Pie, Cell } from 'recharts'; -import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; +import { BrowserRouter as Router, Route } from 'react-router-dom'; import { NavLink } from 'react-router-dom'; + +//Renders the website class App extends Component { constructor() { super(); - // this.handleData = this.handleData.bind(this); this.handleLogout = this.handleLogout.bind(this); this.handleUser = this.handleUser.bind(this); this.state = { @@ -20,6 +21,7 @@ class App extends Component { }; } + //Handles Logout handleLogout() { this.setState({ user: '' @@ -36,6 +38,7 @@ class App extends Component { }); } + //Renders Header and Nav Links to other parts of the website render() { return (
@@ -88,6 +91,7 @@ class App extends Component { } } +//Renders the homepage class WelcomePage extends Component { render() { return ( @@ -101,6 +105,7 @@ class WelcomePage extends Component { } } +//Renders the login page class LoginPage extends Component { constructor(props) { super(props); @@ -131,6 +136,8 @@ class LoginPage extends Component { componentWillUnmount() { this.stopWatchingAuth(); } + + //Function that signs user up and stores their data in firebase handleSignUp() { /* Create a new user and save their information */ @@ -153,6 +160,8 @@ class LoginPage extends Component { this.setState({ errorMessage: err.message }) }) } + + handleSignIn() { //A callback function for logging in existing users @@ -234,6 +243,7 @@ class LoginPage extends Component { } //skykomish valley +//Default numbers for when website is first rendered const DEFAULTS = { lat: '47.8207', lon: '-121.5551', @@ -241,6 +251,7 @@ const DEFAULTS = { maxDist: 10 }; +//Renders the page that shows routes class RoutesPage extends Component { constructor(props) { @@ -248,6 +259,7 @@ class RoutesPage extends Component { this.loadData(DEFAULTS.lat, DEFAULTS.lon, DEFAULTS.numRoutes, DEFAULTS.maxDist) } + //Brings the data from the mountain project.com using an api call loadData(lat, lon, numRoutes, maxDist) { let url = "https://www.mountainproject.com/data/get-routes-for-lat-lon?key=200219054-5692fe76fab0e0f8dbdddb64cba1f33b&lat=" + lat + "&lon=" + lon + "&maxDistance=" + maxDist + "&maxResults=" + numRoutes; fetch(url) @@ -288,6 +300,7 @@ class RoutesPage extends Component { } } +//The card that shows the data of the rock climbing areas class ClimbCard extends React.Component { constructor(props) { super(props) @@ -302,16 +315,8 @@ class ClimbCard extends React.Component { }) } - // componentWillMount() { - // this.firebaseRef = new Firebase("https://ReactFireTodoApp.firebaseio.com/items/"); - // this.firebaseRef.on("child_added", function (dataSnapshot) { - // this.items.push(dataSnapshot.val()); - // this.setState({ - // items: this.items - // }); - // }.bind(this)); - // } + //Counts the number of likes per location and stores it on firebase countLikesToFireBase() { firebase.database().ref('Post/' + this.props.id + "/Likes").transaction(function (Likes) { @@ -328,10 +333,8 @@ class ClimbCard extends React.Component { } - + //Saves a location that the user chose on firebase so that it can be viewed on their profile later pushLikeToFireBase() { - // if (!this.props.uid) { - let UserRef = firebase.database().ref('Users'); let dataName = this.props.name; let foundKey = false; @@ -369,7 +372,7 @@ class ClimbCard extends React.Component { foundKey = false; } - // } + componentDidMount() { firebase.database().ref('Post/' + this.props.id + "/Likes").on('value', (snapshot) => { @@ -421,6 +424,7 @@ class ClimbCard extends React.Component { } +//Generates a list of card climbing routes and the pie chart class ClimbList extends React.Component { render() { @@ -449,6 +453,7 @@ class ClimbList extends React.Component { return color; } + let colorArray = []; for (let i = 0; i < 5; i++) { colorArray[i] = getRandomColor(); @@ -461,19 +466,11 @@ class ClimbList extends React.Component { outerRadius={200} innerRadius={180} label={(something) => something.name} > - - - - - - - -
@@ -492,6 +489,8 @@ class ClimbList extends React.Component { } } + +// Takes in the user entered parameters and renders the form to submit them in class ClimbParam extends React.Component { constructor(props) { super(props); @@ -565,6 +564,8 @@ class ClimbParam extends React.Component { } } + +//Renders the about page containing information on types of bouldering class AboutPage extends Component { render() { @@ -621,7 +622,7 @@ class AboutPage extends Component { } - +//Redners the profile page which holds the user's saved climbing routes class ProfilePage extends Component { constructor(props) { super(props) From 3c55dce72540f008b6952732cd7d50a2314e13e6 Mon Sep 17 00:00:00 2001 From: evanska348 Date: Tue, 6 Mar 2018 05:26:53 -0800 Subject: [PATCH 09/11] god when will this merge conflict end --- myapp/src/App.css | 5 ++++- myapp/src/App.js | 49 ++++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/myapp/src/App.css b/myapp/src/App.css index 11f5b52..71cef39 100644 --- a/myapp/src/App.css +++ b/myapp/src/App.css @@ -55,7 +55,7 @@ nav { text-align: center; } -h1, footer { +h1 { margin: 0; padding: 1.5vh; padding-left: 1.5vw; @@ -158,4 +158,7 @@ button:after { footer { bottom: 0; position: fixed; + padding-left: 1rem; + padding-bottom: 0; + margin-bottom: 0; } \ No newline at end of file diff --git a/myapp/src/App.js b/myapp/src/App.js index 5df5079..c15d1ce 100644 --- a/myapp/src/App.js +++ b/myapp/src/App.js @@ -5,14 +5,15 @@ import firebase from 'firebase'; import 'firebase/auth'; import 'firebase/database'; import { PieChart, Pie, Cell } from 'recharts'; -import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; +import { BrowserRouter as Router, Route } from 'react-router-dom'; import { NavLink } from 'react-router-dom'; + +//Renders the website class App extends Component { constructor() { super(); - // this.handleData = this.handleData.bind(this); this.handleLogout = this.handleLogout.bind(this); this.handleUser = this.handleUser.bind(this); this.state = { @@ -20,6 +21,7 @@ class App extends Component { }; } + //Handles Logout handleLogout() { this.setState({ user: '' @@ -36,6 +38,7 @@ class App extends Component { }); } + //Renders Header and Nav Links to other parts of the website render() { return (
@@ -88,6 +91,7 @@ class App extends Component { } } +//Renders the homepage class WelcomePage extends Component { render() { return ( @@ -101,6 +105,7 @@ class WelcomePage extends Component { } } +//Renders the login page class LoginPage extends Component { constructor(props) { super(props); @@ -131,6 +136,8 @@ class LoginPage extends Component { componentWillUnmount() { this.stopWatchingAuth(); } + + //Function that signs user up and stores their data in firebase handleSignUp() { /* Create a new user and save their information */ @@ -153,6 +160,8 @@ class LoginPage extends Component { this.setState({ errorMessage: err.message }) }) } + + handleSignIn() { //A callback function for logging in existing users @@ -234,6 +243,7 @@ class LoginPage extends Component { } //skykomish valley +//Default numbers for when website is first rendered const DEFAULTS = { lat: '47.8207', lon: '-121.5551', @@ -241,6 +251,7 @@ const DEFAULTS = { maxDist: 10 }; +//Renders the page that shows routes class RoutesPage extends Component { constructor(props) { @@ -248,6 +259,7 @@ class RoutesPage extends Component { this.loadData(DEFAULTS.lat, DEFAULTS.lon, DEFAULTS.numRoutes, DEFAULTS.maxDist) } + //Brings the data from the mountain project.com using an api call loadData(lat, lon, numRoutes, maxDist) { let url = "https://www.mountainproject.com/data/get-routes-for-lat-lon?key=200219054-5692fe76fab0e0f8dbdddb64cba1f33b&lat=" + lat + "&lon=" + lon + "&maxDistance=" + maxDist + "&maxResults=" + numRoutes; fetch(url) @@ -288,6 +300,7 @@ class RoutesPage extends Component { } } +//The card that shows the data of the rock climbing areas class ClimbCard extends React.Component { constructor(props) { super(props) @@ -302,16 +315,8 @@ class ClimbCard extends React.Component { }) } - // componentWillMount() { - // this.firebaseRef = new Firebase("https://ReactFireTodoApp.firebaseio.com/items/"); - // this.firebaseRef.on("child_added", function (dataSnapshot) { - // this.items.push(dataSnapshot.val()); - // this.setState({ - // items: this.items - // }); - // }.bind(this)); - // } + //Counts the number of likes per location and stores it on firebase countLikesToFireBase() { firebase.database().ref('Post/' + this.props.id + "/Likes").transaction(function (Likes) { @@ -328,10 +333,8 @@ class ClimbCard extends React.Component { } - + //Saves a location that the user chose on firebase so that it can be viewed on their profile later pushLikeToFireBase() { - // if (!this.props.uid) { - let UserRef = firebase.database().ref('Users'); let dataName = this.props.name; let foundKey = false; @@ -369,7 +372,7 @@ class ClimbCard extends React.Component { foundKey = false; } - // } + componentDidMount() { firebase.database().ref('Post/' + this.props.id + "/Likes").on('value', (snapshot) => { @@ -421,6 +424,7 @@ class ClimbCard extends React.Component { } +//Generates a list of card climbing routes and the pie chart class ClimbList extends React.Component { render() { @@ -449,6 +453,7 @@ class ClimbList extends React.Component { return color; } + let colorArray = []; for (let i = 0; i < 5; i++) { colorArray[i] = getRandomColor(); @@ -461,19 +466,11 @@ class ClimbList extends React.Component { outerRadius={200} innerRadius={180} label={(something) => something.name} > - - - - - - - -
@@ -492,6 +489,8 @@ class ClimbList extends React.Component { } } + +// Takes in the user entered parameters and renders the form to submit them in class ClimbParam extends React.Component { constructor(props) { super(props); @@ -570,6 +569,8 @@ class ClimbParam extends React.Component { } } + +//Renders the about page containing information on types of bouldering class AboutPage extends Component { render() { @@ -626,7 +627,7 @@ class AboutPage extends Component { } - +//Redners the profile page which holds the user's saved climbing routes class ProfilePage extends Component { constructor(props) { super(props) From 28f37f03fa64862a79937ac7b0dfb7d8c44242ec Mon Sep 17 00:00:00 2001 From: Sohrab Date: Tue, 6 Mar 2018 05:28:27 -0800 Subject: [PATCH 10/11] pushing final changes --- myapp/package-lock.json | 56 +++++++++++++++++++++++++++++++++++++++++ myapp/package.json | 4 +++ 2 files changed, 60 insertions(+) diff --git a/myapp/package-lock.json b/myapp/package-lock.json index 0c13121..321aab5 100644 --- a/myapp/package-lock.json +++ b/myapp/package-lock.json @@ -1320,6 +1320,11 @@ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.3.tgz", "integrity": "sha512-MsAhsUW1GxCdgYSO6tAfZrNapmUKk7mWx/k5mFY/A1gBtkaCaNapTg+FExCw1r9yeaZhqx/xPg43xgTFH6KL5w==" }, + "base64url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", + "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=" + }, "batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -4984,6 +4989,57 @@ "assert-plus": "1.0.0" } }, + "gh-pages": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.1.0.tgz", + "integrity": "sha512-ZpDkeOVmIrN5mz+sBWDz5zmTqcbNJzI/updCwEv/7rrSdpTNlj1B5GhBqG7f4Q8p5sJOdnBV0SIqxJrxtZQ9FA==", + "requires": { + "async": "2.6.0", + "base64url": "2.0.0", + "commander": "2.11.0", + "fs-extra": "4.0.3", + "globby": "6.1.0", + "graceful-fs": "4.1.11", + "rimraf": "2.6.2" + }, + "dependencies": { + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" + } + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "requires": { + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "4.1.11" + } + } + } + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", diff --git a/myapp/package.json b/myapp/package.json index 2d24d5c..dcbbd81 100644 --- a/myapp/package.json +++ b/myapp/package.json @@ -2,8 +2,10 @@ "name": "myapp", "version": "0.1.0", "private": true, + "homepage": "http://students.washington.edu/sseera/info343/p4-climbingApp/", "dependencies": { "firebase": "^4.10.1", + "gh-pages": "^1.1.0", "react": "^16.2.0", "react-dom": "^16.2.0", "react-router-dom": "^4.2.2", @@ -11,6 +13,8 @@ "recharts": "^1.0.0-beta.10" }, "scripts": { + "predeploy": "npm run build", + "deploy": "gh-pages -d build", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", From c3bef00ec2c6ce5d615e148596e4c72abf53853a Mon Sep 17 00:00:00 2001 From: evanska348 Date: Tue, 6 Mar 2018 05:34:16 -0800 Subject: [PATCH 11/11] added homepage --- myapp/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myapp/package.json b/myapp/package.json index dcbbd81..bc1b8f5 100644 --- a/myapp/package.json +++ b/myapp/package.json @@ -2,7 +2,6 @@ "name": "myapp", "version": "0.1.0", "private": true, - "homepage": "http://students.washington.edu/sseera/info343/p4-climbingApp/", "dependencies": { "firebase": "^4.10.1", "gh-pages": "^1.1.0", @@ -12,6 +11,7 @@ "react-scripts": "1.1.1", "recharts": "^1.0.0-beta.10" }, + "homepage": "https://students.washington.edu/evanzhao/info343/p4-climbingApp/", "scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build", @@ -20,4 +20,4 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } -} +} \ No newline at end of file