Skip to content

Commit

Permalink
Merge pull request #3 from jzolo22/newUserForm
Browse files Browse the repository at this point in the history
new user form
  • Loading branch information
jonnyhak authored Jan 8, 2021
2 parents 1d16212 + 65ee5b6 commit 75fb801
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintcache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/index.js":"1","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/NavBar.js":"2","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/HomePage.js":"3","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/redux/actions.js":"4","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/reportWebVitals.js":"5","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/TrailShow.js":"6","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/LoginForm.js":"7","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/containers/TrailsList.js":"8","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/Trail.js":"9","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/SearchForm.js":"10","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/Profile.js":"11","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/TrailForm.js":"12"},{"size":866,"mtime":1609951773218,"results":"13","hashOfConfig":"14"},{"size":1753,"mtime":1609971700087,"results":"15","hashOfConfig":"14"},{"size":5274,"mtime":1610062934027,"results":"16","hashOfConfig":"14"},{"size":4338,"mtime":1609951773221,"results":"17","hashOfConfig":"14"},{"size":362,"mtime":1608848533095,"results":"18","hashOfConfig":"14"},{"size":2847,"mtime":1610037007108,"results":"19","hashOfConfig":"14"},{"size":1224,"mtime":1610037561329,"results":"20","hashOfConfig":"14"},{"size":3499,"mtime":1610050376293,"results":"21","hashOfConfig":"14"},{"size":367,"mtime":1610044126424,"results":"22","hashOfConfig":"14"},{"size":1160,"mtime":1610047600221,"results":"23","hashOfConfig":"14"},{"size":7569,"mtime":1610065212668,"results":"24","hashOfConfig":"14"},{"size":2391,"mtime":1610062689055,"results":"25","hashOfConfig":"14"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},"6dmgbn",{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"39"},{"filePath":"40","messages":"41","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/index.js",[],["52","53"],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/NavBar.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/HomePage.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/redux/actions.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/reportWebVitals.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/TrailShow.js",["54","55"],"import React from 'react'\nimport { addUserTrail } from '../redux/actions'\nimport {connect} from 'react-redux'\n// import REACT_APP_GOOGLE_API_KEY from '../.env'\n\nclass TrailShow extends React.Component {\n\n state = {\n clicked: false\n }\n\n addUserTrail = () => {\n let date = new Date()\n this.props.addUserTrail({ \n trail_id: this.props.trailObj.id,\n user_id: this.props.user.user.id,\n date: date\n })\n window.alert(\"Trail added to your list!\")\n }\n\n clickDirections = () => {\n this.setState({clicked: !this.state.clicked})\n }\n\n hours = (mins) => {\n let hours = Math.floor(mins / 60) \n let minutes = mins % 60\n if (hours === 1) {\n return `${hours} hour and ${minutes} minutes to complete` \n } else if (minutes === 1) {\n return `${hours} hours and ${minutes} minute to complete` \n } else {\n return `${hours} hours and ${minutes} minutes to complete` \n }\n \n }\n \n render(){\n console.log(this.props)\n return (\n <div className=\"trail-show\">\n <h1>{this.props.trailObj.name}</h1>\n <h2>in {this.props.trailObj.location}</h2>\n <button onClick={this.addUserTrail}>Add To My Trails</button>\n <img src={this.props.trailObj.image_url} alt={this.props.trailObj.name} />\n <h3>Length: {this.props.trailObj.length} miles</h3>\n <h4>{this.hours(this.props.trailObj.duration)} </h4>\n <h3>Difficulty level: {this.props.trailObj.difficulty}</h3>\n\n {this.state.clicked? null :\n <iframe className=\"map\" src={`https://www.google.com/maps/embed/v1/place?key=${process.env.REACT_APP_GOOGLE_API_KEY}&q=${this.props.trailObj.name} ${this.props.trailObj.location}&zoom=8`}> </iframe>\n } \n\n {this.state.clicked? \n <iframe className=\"map\" src={`https://www.google.com/maps/embed/v1/directions?key=${process.env.REACT_APP_GOOGLE_API_KEY}&origin=${this.props.user.user.city}&destination=${this.props.trailObj.name} ${this.props.trailObj.location}&mode=driving&zoom=8`}> \n </iframe>\n : null}\n \n \n <br />\n <button onClick={this.clickDirections}>\n {this.state.clicked ? \"See trail on map\" : \"Get directions\" }\n </button>\n\n\n \n </div>\n )\n }\n}\n\nconst mapStateToProps = (state) => {\n return {user: state.user}\n}\n\nconst mapDispatchToProps = (dispatch) => {\n return {\n addUserTrail: (userTrailObj) => dispatch(addUserTrail(userTrailObj))\n }\n}\n\nexport default connect(mapStateToProps, mapDispatchToProps)(TrailShow)","/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/LoginForm.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/containers/TrailsList.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/Trail.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/SearchForm.js",["56"],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/Profile.js",[],"/Users/juliazolotarev/Documents/Flatiron/assignments/Mod-4/trails-with-friends/trails-with-friends-frontend/src/components/TrailForm.js",[],{"ruleId":"57","replacedBy":"58"},{"ruleId":"59","replacedBy":"60"},{"ruleId":"61","severity":1,"message":"62","line":52,"column":17,"nodeType":"63","endLine":52,"endColumn":206},{"ruleId":"61","severity":1,"message":"62","line":56,"column":21,"nodeType":"63","endLine":56,"endColumn":273},{"ruleId":"64","severity":1,"message":"65","line":2,"column":9,"nodeType":"66","messageId":"67","endLine":2,"endColumn":16},"no-native-reassign",["68"],"no-negated-in-lhs",["69"],"jsx-a11y/iframe-has-title","<iframe> elements must have a unique title property.","JSXOpeningElement","no-unused-vars","'connect' is defined but never used.","Identifier","unusedVar","no-global-assign","no-unsafe-negation"]
[{"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/index.js":"1","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/redux/reducer.js":"2","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/HomePage.js":"3","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/LoginForm.js":"4","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/TrailShow.js":"5","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/Trail.js":"6","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/redux/actions.js":"7","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/containers/TrailsList.js":"8","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/NavBar.js":"9","/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/NewUserForm.js":"10"},{"size":866,"mtime":1609771189093,"results":"11","hashOfConfig":"12"},{"size":1848,"mtime":1609971498512,"results":"13","hashOfConfig":"12"},{"size":5287,"mtime":1610072323109,"results":"14","hashOfConfig":"12"},{"size":1224,"mtime":1610068795788,"results":"15","hashOfConfig":"12"},{"size":2847,"mtime":1610072078579,"results":"16","hashOfConfig":"12"},{"size":367,"mtime":1610068795793,"results":"17","hashOfConfig":"12"},{"size":4338,"mtime":1609899844746,"results":"18","hashOfConfig":"12"},{"size":3499,"mtime":1610068795798,"results":"19","hashOfConfig":"12"},{"size":1753,"mtime":1609970421979,"results":"20","hashOfConfig":"12"},{"size":1957,"mtime":1610070992054,"results":"21","hashOfConfig":"12"},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"24"},"15x815f",{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"24"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"31","messages":"32","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/index.js",[],["43","44"],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/redux/reducer.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/HomePage.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/LoginForm.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/TrailShow.js",["45","46"],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/Trail.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/redux/actions.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/containers/TrailsList.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/NavBar.js",[],"/Users/jonathanhakimian/Desktop/Flatiron/Trails_With_Friends/trails-with-friends-frontend/src/components/NewUserForm.js",[],{"ruleId":"47","replacedBy":"48"},{"ruleId":"49","replacedBy":"50"},{"ruleId":"51","severity":1,"message":"52","line":52,"column":17,"nodeType":"53","endLine":52,"endColumn":206},{"ruleId":"51","severity":1,"message":"52","line":56,"column":21,"nodeType":"53","endLine":56,"endColumn":273},"no-native-reassign",["54"],"no-negated-in-lhs",["55"],"jsx-a11y/iframe-has-title","<iframe> elements must have a unique title property.","JSXOpeningElement","no-global-assign","no-unsafe-negation"]
37 changes: 36 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nav > a:hover {
list-style-type: none;
/* padding-left: 15%; */
margin-right: 15%;
margin-left: 30%;
color: #ffffff;
}

Expand Down Expand Up @@ -159,6 +160,7 @@ span#time {
color: #ffffff;
position: sticky;
top: 18%;
width: 275px;
/* margin-top: 30%; */
}

Expand All @@ -169,6 +171,7 @@ span#time {
#leaderboard > li {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10%;
}

#leaderboard > li > a {
Expand Down Expand Up @@ -423,9 +426,41 @@ a > img:hover {

.map {
height: 300px;
width: 300px;
width: 500px;
}

.new-user-form {
text-align: center;
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}

.new-user-form > h1 {
color: #ffffff;
text-align: center;
}

.new-user-form .form {
display: grid;
justify-content: center;
justify-items: center;
}

.new-user-form .form > input {
margin-bottom: 10px;
font-size: 20px;
width: 250px;
}

.new-user-form .form > button {
font-size: 18px;
width: 200px;

}





Expand Down
2 changes: 1 addition & 1 deletion src/components/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HomePage extends React.Component {
allUsers = () => {
let usersSortedByMileage = this.props.users.sort((a, b) => this.totalMiles(b) - this.totalMiles(a))

return usersSortedByMileage.map(user => {
return usersSortedByMileage.slice(0, 13).map(user => {
return(
<>
<li>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LoginForm extends Component {
<h1>Log In</h1>
<form onSubmit={this.submitHandler}>
<input type="text" placeholder="username" name="username" value={this.state.username} onChange={this.onChange}/>
<input type="text" placeholder="password" name="password" value={this.state.password} onChange={this.onChange}/>
<input type="password" placeholder="password" name="password" value={this.state.password} onChange={this.onChange}/>
<button id="login-btn">Submit</button>
</form>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/NewUserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class NewUserForm extends Component {

render() {
return (
<div>
<h1>New User Form!</h1>
<form onSubmit={this.submitHandler}>
<div className="new-user-form">
<h1>Sign Up</h1>
<form className="form" onSubmit={this.submitHandler}>
<input type="text" placeholder="name" name="name" value={this.state.name} onChange={this.onChange}/>
<input type="text" placeholder="age" name="age" value={this.state.age} onChange={this.onChange}/>
<input type="text" placeholder="city" name="city" value={this.state.city} onChange={this.onChange}/>
<input type="text" placeholder="username" name="username" value={this.state.username} onChange={this.onChange}/>
<input type="text" placeholder="password" name="password" value={this.state.password} onChange={this.onChange}/>
<input type="text" placeholder="confirm password" name="password_confirmation" value={this.state.password_confirmation} onChange={this.onChange}/>
<input type="password" placeholder="password" name="password" value={this.state.password} onChange={this.onChange}/>
<input type="password" placeholder="confirm password" name="password_confirmation" value={this.state.password_confirmation} onChange={this.onChange}/>
<button>Submit</button>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/TrailShow.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TrailShow extends React.Component {
}

{this.state.clicked?
<iframe className="map" src={`https://www.google.com/maps/embed/v1/directions?key=${process.env.REACT_APP_GOOGLE_API_KEY}&origin=${this.props.user.user.city}&destination=${this.props.trailObj.name} ${this.props.trailObj.location}&mode=driving&zoom=8`}>
<iframe className="map" src={`https://www.google.com/maps/embed/v1/directions?key=${process.env.REACT_APP_GOOGLE_API_KEY}&origin=${this.props.user.user.city}&destination=${this.props.trailObj.name} ${this.props.trailObj.location}&mode=driving&zoom=4`}>
</iframe>
: null}

Expand Down

0 comments on commit 75fb801

Please sign in to comment.