Skip to content

Commit

Permalink
corrected supp/patt view and added more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mau11 committed Jan 26, 2017
1 parent 5149b2d commit 8f039a5
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 121 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_modules
.jshintrc
public/bundle.js
npm-debug.log
.ebextensions

# Elastic Beanstalk Files

Expand Down
25 changes: 11 additions & 14 deletions components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';

// This is the homepage of the application.
export default class App extends React.Component {
constructor(props) {
super(props);
Expand All @@ -13,6 +14,7 @@ export default class App extends React.Component {
this.getUpdates();
}

// Gets data from db to be displayed under new & updates.
getUpdates() {
return fetch('/api/updates', {method: 'GET'})
.then((response) => response.json())
Expand All @@ -23,31 +25,26 @@ export default class App extends React.Component {

render () {
return (

<div className="container">
<div className="mainTitle">
<div className="col-sm-9">
<h2>Welcome to Emanie!
</h2>
<h5>
<i>A community for knitters and crocheters to store and share their crafts.
</i>
<em>A community for knitters and crocheters to store and share their crafts.</em>
</h5>
<img className="mainPics" src="../img/home2.jpg" alt="Basket of Yarn"/>
</div>
<div className="col-sm-3">
<h4><u><i>News & Updates:</i></u>
<h4>
<u><em>News & Updates:</em></u>
</h4>
<div className="box">
{this.state.updates.map(item =>
<div className="news" key={item.id}><b>{'"'+item.notes+'"'}</b><br/>
<small >
<i>{item["DATE_FORMAT(date, '%b %d, %Y')"]}
</i>
</small>
</div>
)}
</div>
<div className="box">
{this.state.updates.map(item =>
<div className="news" key={item.id}><strong>{'"'+item.notes+'"'}</strong><br/>
<small ><em>{item["DATE_FORMAT(date, '%b %d, %Y')"]}</em></small>
</div>)}
</div>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion pages/Contact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class Contact extends React.Component {
}

render () {
// There is a bug here, function renders multiple forms, each time page is visited
(function(d, t){
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = "http://www.foxyform.com/js.php?id=845120&sec_hash=1d3572990c1&width=500px";
Expand All @@ -24,7 +25,7 @@ export default class Contact extends React.Component {
<h4>Questions, Comments, Suggestions?
</h4>
<h5>Please use the form below to contact Emanie.
<br />If you like to report a concern or bug, please head over to the
<br />If you'd like to report a concern or bug, please head over to the
<Link to="report"> Report Issues
</Link> page.
</h5>
Expand Down
66 changes: 32 additions & 34 deletions pages/Update.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,38 @@ export default class Update extends React.Component {
return fetch('/api/users/all', {method: 'GET'})
.then((response) => response.json())
.then((users) => {
for(var i = 0; i < users.length; i++){
for(var key in users[i]){
if(this.state.email === users[i].email){
holder = i;
this.setState({displayName: users[i].displayName});
if($('#display').val()){
var dis = $('#display').val();
this.setState({displayName: dis});
}
this.setState({craftName: users[i].craftName});
if($('#craft').val()){
var newCraftName = $('#craft').val();
this.setState({craftName:newCraftName});
}
this.setState({bio: users[i].bio});
if($('#blurb').val()){
var newBio = $('#blurb').val();
this.setState({bio: newBio});
}
this.setState({pic: users[i].pic});
var selected = $("input[name='pics']:checked").val();
if(selected === 'pic1'){
this.setState({pic: '../img/lightGrey.JPG'});
} else if(selected === 'pic2'){
this.setState({pic: '../img/perfectPink.jpg'});
} else if(selected === 'pic3'){
this.setState({pic: '../img/lightBlue.JPG'});
} else if(selected === 'pic4'){
this.setState({pic: '../img/realTeal.JPG'});
} else if(selected === 'pic5'){
this.setState({pic: '../img/paleYellow.JPG'});
} else if(selected === 'pic6'){
this.setState({pic: '../img/defaultIcon.png'});
}
for(var i = 0; i < users.length; i++){
if(this.state.email === users[i].email){
holder = i;
this.setState({displayName: users[i].displayName});
if($('#display').val()){
var dis = $('#display').val();
this.setState({displayName: dis});
}
this.setState({craftName: users[i].craftName});
if($('#craft').val()){
var newCraftName = $('#craft').val();
this.setState({craftName:newCraftName});
}
this.setState({bio: users[i].bio});
if($('#blurb').val()){
var newBio = $('#blurb').val();
this.setState({bio: newBio});
}
this.setState({pic: users[i].pic});
var selected = $("input[name='pics']:checked").val();
if(selected === 'pic1'){
this.setState({pic: '../img/lightGrey.JPG'});
} else if(selected === 'pic2'){
this.setState({pic: '../img/perfectPink.jpg'});
} else if(selected === 'pic3'){
this.setState({pic: '../img/lightBlue.JPG'});
} else if(selected === 'pic4'){
this.setState({pic: '../img/realTeal.JPG'});
} else if(selected === 'pic5'){
this.setState({pic: '../img/paleYellow.JPG'});
} else if(selected === 'pic6'){
this.setState({pic: '../img/defaultIcon.png'});
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions pages/ViewPatt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ export default class ViewPatt extends React.Component {
this.getUserPatterns();
}

// Get all users' avatar and display name.
// Get all users' patterns
getUserPatterns(){
var holder = []
return fetch('/api/patterns', {method: 'GET'})
.then((response) => response.json())
.then(allPatterns => {
for(var i = 0; i < allPatterns.length; i++){
for(var key in allPatterns[i]){
if(allPatterns[i].email === this.state.email && allPatterns[i].authId === this.state.authId){
this.setState({allPatts: allPatterns});
}
if(allPatterns[i].email === this.state.email && allPatterns[i].authId === this.state.authId){
holder.push(allPatterns[i]);
}
}
this.setState({allPatts: holder});
});
}

Expand Down
26 changes: 11 additions & 15 deletions pages/ViewSupp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ export default class ViewSupp extends React.Component {

// Get user's yarn.
getUserYarn(){
var basket = [];
return fetch('/api/yarn', {method: 'GET'})
.then((response) => response.json())
.then(yarn => {
for(var i = 0; i < yarn.length; i++){
for(var key in yarn[i]){
if(yarn[i].email === this.state.email && yarn[i].authId === this.state.authId){
this.setState({allYarn: yarn});
}
if(yarn[i].email === this.state.email && yarn[i].authId === this.state.authId){
basket.push(yarn[i]);
}
}
})
this.setState({allYarn: basket});
});
}

// Get user's tools.
getUserTools(){
var bin = [];
return fetch('/api/tools', {method: 'GET'})
.then((response) => response.json())
.then(tools => {
for(var i = 0; i < tools.length; i++){
for(var key in tools[i]){
if(tools[i].email === this.state.email && tools[i].authId === this.state.authId){
this.setState({allTools: tools});
}
if(tools[i].email === this.state.email && tools[i].authId === this.state.authId){
bin.push(tools[i]);
}
}
this.setState({allTools: bin});
});
}

Expand Down Expand Up @@ -110,9 +110,7 @@ export default class ViewSupp extends React.Component {
</h4>
</div>
<div className="mainTitle">
<button type="button" className="btn btn-primary active">Edit
</button>
<button type="button" className="btn btn-danger btn-xs btn-center active" id={skein.id} onClick={this.deletingYarn.bind(this)}>Delete
<button type="button" className="btn btn-danger btn-center active" id={skein.id} onClick={this.deletingYarn.bind(this)}>Delete
</button>
<hr />
</div>
Expand Down Expand Up @@ -140,9 +138,7 @@ export default class ViewSupp extends React.Component {
</h4>
</div>
<div className="mainTitle">
<button type="button" className="btn btn-primary active">Edit
</button>
<button type="button" className="btn btn-danger btn-xs btn-center active" id={item.id} onClick={this.deletingTool.bind(this)}>Delete
<button type="button" className="btn btn-danger btn-center active" id={item.id} onClick={this.deletingTool.bind(this)}>Delete
</button>
<hr />
</div>
Expand Down
Loading

0 comments on commit 8f039a5

Please sign in to comment.