Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added thumbs buttons, tried to make them work and failed #61

Merged
merged 1 commit into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const interest = require('./interest');
const review = require('./add-review');
const error = require('./error');
const thumbsup = require('./thumbsup');
// const thumbsdown = require('./thumbsdown');


router.get('/interest/:planet', interest.get);
router.get('/', home);

router.get('/interest/:planet', interest.get);
router.get('/results/:distance', getPlanets);
// router.get('/planets/interest/:planet', interest.get);
router.get('/planets/:planet', planet.get);
router.get('/thumbsup', thumbsup.get)
router.get('/thumbsup', thumbsup.get);
// router.get('/thumbsdown', thumbsdown.get);
router.post('/add-review', review.post);
router.use(error.client);
router.use(error.server);
Expand Down
Empty file added src/controllers/thumbsdown.js
Empty file.
7 changes: 4 additions & 3 deletions src/controllers/thumbsup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const thumbsup = require('../model/queries/addthumbsup.js');

exports.get = (req, res) => {
const {review} = req.params; //currently planet id
console.log ('Attempting to thumbsup ',review);
thumbsup (review);
const {review} = req.params;
console.log(req);
console.log ('Attempting to thumbsup ', review);
thumbsup(review);
res.redirect(`/planets/${planet}`)

}
3 changes: 1 addition & 2 deletions src/model/queries/addthumbsup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ const thumbsup = (reviewId) => {
newThumbsup = res.rows[0].likes +1;
query="UPDATE reviews SET likes =$1;";
dbConnection.query (query, [newThumbsup], (err,res) => {
if (err) console.log ('thumbs up failed on UPDATE. Noone cares.');
if (err) console.log ('thumbs up failed on UPDATE. Noone cares.');
else {
console.log ('thumbs up suceeded. Noone cares.');

}
});
}
Expand Down
11 changes: 7 additions & 4 deletions src/views/planet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h4>{{this.planetData.temperature}}</h4>
<h4>{{this.planetData.weather}}</h4>
<h4>{{this.planetData.interest}} people are interested -
<form id="interest-form" action="/interest/{{this.planetData.id}}" method='GET'>
<form id="interest-form" action="/interest/{{this.planetData.id}}" method='GET'>
<input type="submit" name="submit" class="interest-button">Are you?
</form>
</h4>
Expand All @@ -22,12 +22,15 @@
{{#each reviewArray}}
<article>
<h3>{{this.username}}</h3>
<h4>{{this.content}}</h4>
<h4>"{{this.content}}"</h4>
Thumbs up: {{this.likes}}
<form id="thumbsup-form" action="/thumbsup/{{this.planetData.id}}/{{this.foundReviews.id}}" method='GET'>
<input type="submit" name="submit" value="" class="likes-button">Like
<form id="thumbsup-form" action="/thumbsup" method='GET'>
<input type="submit" name="submit" value="" class="thumbsup-button">Click
</form>
Thumbs down: {{this.dislikes}}
<form id="thumbsdown-form" action="/thumbsdown/{{this.planetData.id}}/{{this.foundReviews.id}}" method='GET'>
<input type="submit" name="submit" value="" class="thumbsdown-button">Click
</form>

</article>
{{/each}}
Expand Down