Skip to content

Commit

Permalink
Merge branch 'master' into modal
Browse files Browse the repository at this point in the history
  • Loading branch information
hrmstockdale authored May 23, 2019
2 parents 864da09 + e36da2e commit a8cf430
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 31 deletions.
22 changes: 5 additions & 17 deletions src/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const splash = require("./splashPage");
const conductPage = require("./conductPage");
const signup = require("./signupPage");
const matchBuddiesPage = require("./matchBuddiesPage");
// const userProfilePage = require("./userProfilePage");

const location = require("./location");

Expand All @@ -30,28 +31,15 @@ router.get("/sign-up", signup.get);
router.get("/congrats-page", congratsPage.get);
router.get("/match-buddies-page", matchBuddiesPage.get);
router.get("/report-page", reportPage.get);
router.get("/user-profile", userProfilePage.get);

const {returnMatchedUsers} = require('../model/queries/getMatchUsers.js');
const { returnMatchedUsers } = require("../model/queries/getMatchUsers.js");
router.get("/search-settings", (req, res, next) => {
// res.redirect("/match-buddies-page");

const {
agePref,
distancePref,
genderPref,
expPref,
goalPref
} = req.query;




console.log('req.query:', req.query)
const { agePref, distancePref, genderPref, expPref, goalPref } = req.query;
// console.log('req.query:', req.query)
returnMatchedUsers(parseInt(agePref), genderPref, expPref)
.then(response => {
console.log(response)
res.render("matchBuddiesPage", {usersArr: response})
console.log(response)
})
});

Expand Down
3 changes: 3 additions & 0 deletions src/controller/userProfilePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// exports.get = (req, res) => {
// res.render("userProfilePage", { layout: "userProfile" });
// };
9 changes: 6 additions & 3 deletions src/model/queries/getMatchUsers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
const db = require("../db_connections")


// SELECT * FROM users LEFT JOIN users_goals ON users.users_id = users_goals.users_id WHERE (users.age, users.gender, users.experience) = ($1, $2, $3)

const returnMatchedUsers = (age, gender, experience) => {
return db
.query(
"SELECT * FROM users LEFT JOIN users_goals ON users.users_id = users_goals.users_id WHERE (users.age, users.gender, users.experience) = ($1, $2, $3)",
"SELECT * FROM (SELECT * FROM users LEFT JOIN users_goals ON users.users_id = users_goals.users_id WHERE (users.age, users.gender, users.experience) =($1, $2, $3)) q1 INNER JOIN goals ON q1.goals_id = goals.goals_id",
[age, gender, experience]
)
.then(response => {
console.log('returnMatchedUsers: ',response)
console.log('args: ', age, gender, experience)
console.log('returnMatchedUsers: ',response);
console.log('args: ', age, gender, experience);

return response.rows;
})
Expand Down
13 changes: 13 additions & 0 deletions src/views/layouts/userProfile.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{!-- <!DOCTYPE html>
<html lang="en">
{{> htmlHead}}
<body class="flex-body">
<div class="container-content">
{{> header}}
{{{ body }}}
</div>
</body>
{{> footer}}
</html> --}}
12 changes: 6 additions & 6 deletions src/views/matchBuddiesPage.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="container-main">
<h1 class="sub-title">Search</h1>
<p class="main-paragraph">Here is a list of buddies, based on your search preferences</p>
{{> matchedBuddy }}
{{> matchedBuddy }}
{{> matchedBuddy }}
{{> matchedBuddy }}
{{> matchedBuddy }}
{{> matchedBuddy }}
{{#each usersArr}}

{{> matchedBuddy profile=this}}

{{else}}
<h3>oops, there are no profiles that match those search Preferences</h3>
{{/each}}
</div>
10 changes: 5 additions & 5 deletions src/views/partials/matchedBuddy.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<div class="buddy-match-grid">
<img src="./assets/profile-pic.png" alt="Ryan" class="matched-buddle-img box1">
<p class="box2 box2-paragraph">Ryan McAvoy, 28</p>

<img src="./assets/profile-pic.png" alt="name" class="matched-buddle-img box1">
<p class="box2 box2-paragraph">{{this.users_name}}, {{this.age}}</p>
{{!-- <p class="box3">age: 28</p> --}}
<p class="box4">Morning</p>
<p class="box5">Beginner</p>
<p class="box6">Losing Weight</p>
<p class="box5">{{this.experience}}</p>
<p class="box6">{{this.goal_name}}</p>
<p class="box7">Build Muscle</p>

<button id='modelBtn'>I like this GYMBUDDY</button>
Expand All @@ -23,5 +24,4 @@
</div>
</div>
</div>

</div>
17 changes: 17 additions & 0 deletions src/views/userProfilePage.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{!-- <img class='arrow-icon' src="./assets/right-arrow.png" alt="arrow">
<h1 class="sub-title">Profile</h1>
<img src="./assets/profile-pic.png" alt="Ryan" class="profile-img">
<p class="main-paragraph">Ryan McAvoy, 28</p>
<div class="container">
<p class="p-border">Morning</p>
<p class="p-border">Beginner</p>
<p class="p-border">Lose Weight</p>
<p class="p-border">Build Muscle</p>
</div>
<input type="text" placeholder="BIO..." class="input-box">
<div class="container-btn">
<button class="btn__round">Maybe Not</button>
<button class="btn__round">GymBuddy</button>
</div> --}}

0 comments on commit a8cf430

Please sign in to comment.