diff --git a/README.md b/README.md
index c8a263e..1eb06bf 100644
--- a/README.md
+++ b/README.md
@@ -9,11 +9,13 @@ Check it out here: https://fortis.onrender.com/
# Planning
-## Schema Tables
-https://whimsical.com/schema-tables-7GaP9mejisBZZMi44Y4iNH#
## Wireframe
+![Picture of my wireframes](/public/images/wireframes.jpg)
+## Schema Tables
+https://whimsical.com/schema-tables-7GaP9mejisBZZMi44Y4iNH#
+![Screenshot of my Schema ERD](/public/images/Schema%20example.png)
# Future features
diff --git a/controllers/user_controller.js b/controllers/user_controller.js
index 5d69e11..164ec7c 100644
--- a/controllers/user_controller.js
+++ b/controllers/user_controller.js
@@ -51,7 +51,14 @@ router.get("/users/:userid/workouts", ensureLoggedIn, (req, res) => {
db.query(sql2, (err, dbJunctionRes) => {
// console.log("exercises in workouts",dbJunctionRes.rows);
const exercisesInWorkouts = dbJunctionRes.rows;
- res.render("current_user_workouts", { workouts, exercisesInWorkouts })
+
+ const sql3 = "SELECT * FROM users where user_id = $1"
+ db.query(sql3, [req.params.userid], (err, dbUsersRes) => {
+ const user = dbUsersRes.rows[0]
+ res.render("user_workouts", { workouts, exercisesInWorkouts, user })
+
+ })
+
})
})
})
@@ -124,14 +131,10 @@ router.post("/users", (req, res) => {
})
router.put("/users/:userid/photo", upload.single("uploadedFile"), (req, res) => {
- // if(!req.file.path) {
- // req.redirect(`/users/${req.params.userid}/photo/edit`)
- // } else { //! ask about this if condition to prevent route breaking
- const sql = `UPDATE users SET profile_photo = $1 where user_id = $2`
- db.query(sql, [req.file.path, req.params.userid], (err, dbRes) => {
- res.redirect(`/users/${req.params.userid}`)
- })
- // }
+ const sql = `UPDATE users SET profile_photo = $1 where user_id = $2`
+ db.query(sql, [req.file.path, req.params.userid], (err, dbRes) => {
+ res.redirect(`/users/${req.params.userid}`)
+ })
})
router.put("/users/:userid/password", (req, res) => {
diff --git a/controllers/workout_controller.js b/controllers/workout_controller.js
index c8db680..4072cfa 100644
--- a/controllers/workout_controller.js
+++ b/controllers/workout_controller.js
@@ -62,7 +62,7 @@ router.get("/workouts/:workoutid/exercise/:exerciseid", ensureLoggedIn, (req, re
//display workout
router.get("/workouts/:id", ensureLoggedIn, (req, res) => {
const sql = "SELECT *, TO_CHAR(workout_date, 'FMMonth DD, YYYY') FROM workouts WHERE workout_id = $1;"
-
+ const userIdLoggedIn = req.session.userId
db.query(sql, [req.params.id], (err, dbRes) => {
const workout = dbRes.rows[0]
const sql2 = "SELECT * FROM exercises JOIN workout_exercise_junction ON exercises.exercise_id = workout_exercise_junction.exercise_id WHERE workout_id = $1 ORDER BY junction_id;"
@@ -71,7 +71,13 @@ router.get("/workouts/:id", ensureLoggedIn, (req, res) => {
const sql3 = "SELECT * FROM log_workout_entries JOIN workout_exercise_junction ON log_workout_entries.junction_id = workout_exercise_junction.junction_id JOIN exercises on exercises.exercise_id = workout_exercise_junction.exercise_id;"
db.query (sql3, (err, dbLogRes) => {
const logdatas = dbLogRes.rows
- res.render("workout_details", { workout, exercises, logdatas })
+ // const sql4 = "SELECT * FROM users JOIN workouts ON users.user_id = workouts.user_id where workout_id = $1"
+ // db.query(sql4, (err, dbUserRes) => {
+ // const
+ // })
+
+
+ res.render("workout_details", { workout, exercises, logdatas, userIdLoggedIn })
})
})
})
diff --git a/db/schema.sql b/db/schema.sql
index 03cfb43..19d0633 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -42,3 +42,7 @@ CREATE TABLE users (
);
-- node seed_dummy_exercises;
-- node seed_dummy_users;
+
+SELECT * FROM users JOIN workouts ON users.user_id = workouts.user_id where workout_id = 5;
+
+SELECT * FROM users JOIN workouts ON users.user_id = workouts.user_id where workout_id = 5 ;
diff --git a/middlewares/ensure_original_user.js b/middlewares/ensure_original_user.js
index 6de9e79..3229f02 100644
--- a/middlewares/ensure_original_user.js
+++ b/middlewares/ensure_original_user.js
@@ -5,4 +5,5 @@ function ensureOriginalUser(req, res, next) {
module.exports = ensureOriginalUser
-// if req.params.userid = req.sesions.userId, then display options to edit
\ No newline at end of file
+// if req.params.userid = req.sesions.userId, then display options to edit
+
diff --git a/middlewares/setCurrentUser.js b/middlewares/setCurrentUser.js
index 8c85f00..a0fa80f 100644
--- a/middlewares/setCurrentUser.js
+++ b/middlewares/setCurrentUser.js
@@ -5,7 +5,7 @@ function setCurrentUser(req, res, next) {
res.locals.currentUser = {}
if (userId) {
- const sql = `SELECT user_id, username, full_name, email FROM users where user_id = ${userId}`
+ const sql = `SELECT user_id, username, full_name, email, profile_photo FROM users where user_id = ${userId}`
db.query (sql, (err, dbRes) => {
if (err) {
console.log(err);
diff --git a/public/css/style.css b/public/css/style.css
index c446dc2..b21582d 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -2,6 +2,7 @@
box-sizing: border-box;
font-family: 'Abel', sans-serif;
margin: 0;
+ /* border: 1px solid red; */
}
body {
@@ -80,8 +81,56 @@ nav ul {
nav li {
list-style: none;
+ /* padding: 0; */
}
+.logged_in img {
+width: auto;
+ text-align: center;
+ margin: 0 auto;
+ border-radius: 5px;
+ height: 50px;
+}
+
+.current_username {
+ font-family: 'Bebas Neue', cursive;
+ color: #522d80;
+}
+
+.logged_in {
+ list-style: none;
+ display: grid;
+ grid-template-columns: 50% 50%;
+}
+
+.btns_logged_in form {
+ padding: 8px 0;
+}
+
+.btns_logged_in button {
+ padding: 0;
+ display: block;
+ text-align: center;
+ background: #989898;
+ border-radius: 3px;
+ color: #fff;
+ width: 60px;
+ height: 20px;
+ font-size: 15px;
+ line-height: 5px;
+ margin: 0 auto;
+}
+
+.btns_logged_in a {
+ color: #fff
+}
+
+.btns_logged_in button:hover {
+ background-color: #582b78;
+ color: #fff;
+}
+
+
main {
width: 80%;
margin: 0px auto;
diff --git a/public/css/user_profile.css b/public/css/user_profile.css
new file mode 100644
index 0000000..eba8eff
--- /dev/null
+++ b/public/css/user_profile.css
@@ -0,0 +1,52 @@
+
+* {
+ /* border: 1px solid red; */
+}
+
+.profile-wrapper {
+ display: grid;
+ grid-template-columns: 40% 60%;
+ margin: 50px 0;
+ gap: 2%;
+}
+
+.user-details {
+ box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
+ border-radius: 10px;
+ border: 6px solid #4B0082;
+}
+
+.user-details h3 {
+ font-family: 'Bebas Neue', cursive;
+ font-size: 4em;
+}
+
+.user-details h4 {
+ font-size: 1.5em;
+}
+
+
+.user-details img {
+ width: 90%;
+ margin: 0 auto;
+}
+
+.user-details button {
+ margin: 10px auto;
+}
+
+.workout-details {
+ box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
+ border-radius: 10px;
+ border: 6px solid #4B0082;
+}
+
+.workout-details ul {
+ padding: 0;
+}
+
+.workout-details li {
+ padding-left: 0;
+ list-style: none;
+ padding-inline-start: 0;
+}
diff --git a/public/css/my_workouts.css b/public/css/user_workouts.css
similarity index 100%
rename from public/css/my_workouts.css
rename to public/css/user_workouts.css
diff --git a/public/images/Schema example.png b/public/images/Schema example.png
new file mode 100644
index 0000000..6fbf8b2
Binary files /dev/null and b/public/images/Schema example.png differ
diff --git a/public/images/wireframes.jpg b/public/images/wireframes.jpg
new file mode 100644
index 0000000..d08ceae
Binary files /dev/null and b/public/images/wireframes.jpg differ
diff --git a/views/edit_user_photo.ejs b/views/edit_user_photo.ejs
index e76247a..c785c11 100644
--- a/views/edit_user_photo.ejs
+++ b/views/edit_user_photo.ejs
@@ -9,11 +9,11 @@
diff --git a/views/layout.ejs b/views/layout.ejs
index 34573a3..439fab4 100644
--- a/views/layout.ejs
+++ b/views/layout.ejs
@@ -31,14 +31,21 @@
Find Athletes
My Workouts
<% if(isLoggedIn()) { %>
-
-
- <%=currentUser.username%>
-
- settings
+
+
+
+
<% } else { %>
Sign In
diff --git a/views/user_details.ejs b/views/user_details.ejs
index d03b3e1..5c82544 100644
--- a/views/user_details.ejs
+++ b/views/user_details.ejs
@@ -1,19 +1,35 @@
-<%=user.username%>
-<%=user.full_name%>
-
+
+
+
+
+
+
+
+ <%=user.username%>
+ <%=user.full_name%>
+
+
+ <% if (Number(userIdLoggedIn) === user.user_id) { %>
+
+ <% } %>
+
+
+
+ Athelete Stats
+
+ Latest Workouts
+
+
+
+
-<% if (Number(userIdLoggedIn) === user.user_id) { %>
-
-<% } %>
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/views/current_user_workouts.ejs b/views/user_workouts.ejs
similarity index 91%
rename from views/current_user_workouts.ejs
rename to views/user_workouts.ejs
index 2ff0c1c..03c6d06 100644
--- a/views/current_user_workouts.ejs
+++ b/views/user_workouts.ejs
@@ -1,8 +1,8 @@
-
+
- My Workouts
+ <%= user.username%> 's Workouts
diff --git a/views/workout_details.ejs b/views/workout_details.ejs
index 5376523..0f9636a 100644
--- a/views/workout_details.ejs
+++ b/views/workout_details.ejs
@@ -6,12 +6,17 @@
Workout Details
<%= workout.name %>
<%= workout.to_char %>
- edit workout name/date
-
+
+ <% if (Number(userIdLoggedIn) === workout.user_id) { %>
+
+ <% } %>
+
@@ -19,30 +24,51 @@
<% for (const exercise of exercises){%>
<%=exercise.name%>
-
edit exercise name
-
+
+ <% if (Number(userIdLoggedIn) === workout.user_id) { %>
+
+ <% } %>
+
<% for (const logdata of logdatas){ %>
<% if (logdata.junction_id === exercise.junction_id) {%>
sets: <%= logdata.sets%>
reps:<%= logdata.reps%>
weight: <%= logdata.weight%>
- edit this set
-
+
+ <% if (Number(userIdLoggedIn) === workout.user_id) { %>
+
+ <% } %>
+
<% } %>
<% } %>
-
add set
+ <% if (Number(userIdLoggedIn) === workout.user_id) { %>
+
+ <% } %>
<% } %>
- Add Exercise
+ <% if (Number(userIdLoggedIn) === workout.user_id) { %>
+
+ <% } %>