diff --git a/src/controller/index.js b/src/controller/index.js index 2c75431..573973f 100644 --- a/src/controller/index.js +++ b/src/controller/index.js @@ -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"); @@ -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) }) }); diff --git a/src/controller/userProfilePage.js b/src/controller/userProfilePage.js new file mode 100644 index 0000000..a0de911 --- /dev/null +++ b/src/controller/userProfilePage.js @@ -0,0 +1,3 @@ +// exports.get = (req, res) => { +// res.render("userProfilePage", { layout: "userProfile" }); +// }; diff --git a/src/model/queries/getMatchUsers.js b/src/model/queries/getMatchUsers.js index e49a315..7ebbd97 100644 --- a/src/model/queries/getMatchUsers.js +++ b/src/model/queries/getMatchUsers.js @@ -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; }) diff --git a/src/views/layouts/userProfile.hbs b/src/views/layouts/userProfile.hbs new file mode 100644 index 0000000..b34a39a --- /dev/null +++ b/src/views/layouts/userProfile.hbs @@ -0,0 +1,13 @@ +{{!-- + +{{> htmlHead}} + + +
+ {{> header}} + {{{ body }}} +
+ +{{> footer}} + + --}} \ No newline at end of file diff --git a/src/views/matchBuddiesPage.hbs b/src/views/matchBuddiesPage.hbs index 357f3af..191b5b0 100644 --- a/src/views/matchBuddiesPage.hbs +++ b/src/views/matchBuddiesPage.hbs @@ -1,11 +1,11 @@

Search

Here is a list of buddies, based on your search preferences

- {{> matchedBuddy }} - {{> matchedBuddy }} - {{> matchedBuddy }} - {{> matchedBuddy }} - {{> matchedBuddy }} - {{> matchedBuddy }} + {{#each usersArr}} + {{> matchedBuddy profile=this}} + + {{else}} +

oops, there are no profiles that match those search Preferences

+ {{/each}}
\ No newline at end of file diff --git a/src/views/partials/matchedBuddy.hbs b/src/views/partials/matchedBuddy.hbs index f1c969b..5a281e4 100644 --- a/src/views/partials/matchedBuddy.hbs +++ b/src/views/partials/matchedBuddy.hbs @@ -1,10 +1,11 @@
- Ryan -

Ryan McAvoy, 28

+ + name +

{{this.users_name}}, {{this.age}}

{{!--

age: 28

--}}

Morning

-

Beginner

-

Losing Weight

+

{{this.experience}}

+

{{this.goal_name}}

Build Muscle

@@ -23,5 +24,4 @@
- \ No newline at end of file diff --git a/src/views/userProfilePage.hbs b/src/views/userProfilePage.hbs new file mode 100644 index 0000000..b4fa469 --- /dev/null +++ b/src/views/userProfilePage.hbs @@ -0,0 +1,17 @@ +{{!-- arrow +

Profile

+Ryan +

Ryan McAvoy, 28

+
+

Morning

+

Beginner

+

Lose Weight

+

Build Muscle

+
+ + + +
+ + +
--}} \ No newline at end of file