-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add user profile update functions etc.
Relates #32
- Loading branch information
Showing
7 changed files
with
159 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,64 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link rel="stylesheet" type="text/css" href="./public/style.css"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<nav id="nav" class="nav"> | ||
<div id="nav-profile" class="nav_profile">profile</div> | ||
</nav> | ||
<nav id="nav" class="nav"> | ||
<div id="nav-profile" class="nav_profile">profile</div> | ||
</nav> | ||
|
||
<h1>User profile</h1> | ||
|
||
<p>User profile</p> | ||
<section id="updateZone"> | ||
<form id="updateProfile" class="form"> | ||
Username: | ||
<input id="username" type="text" name="handle" value="" placeholder="" required> | ||
First name: | ||
<input id="firstname" type="text" name="first_name" value="" placeholder="" required> | ||
Last name: | ||
<input id="lastname" type="text" name="last_name" value="" placeholder="" required> | ||
Email: | ||
<input id="email" type="email" name="email" value="" placeholder="" required> | ||
Cohort: | ||
<input id="cohort" type="text" name="cohort" value="" placeholder="" required> | ||
City: | ||
<input id="city" type="text" name="city" value="" placeholder="" required> | ||
Looking for work? | ||
<input type="radio" name="work_looking_status" value="Y">Yes | ||
<input type="radio" name="work_looking_status" value="N">No | ||
About me: | ||
<textarea id="aboutme" name="about_me"> | ||
</textarea> | ||
</form> | ||
<button type="button" id="updateButton" name="updateButton">Update profile</button> | ||
</section> | ||
|
||
<section id="viewZone"> | ||
<p>View zone</p> | ||
</section> | ||
<h2>Update Profile</h2> | ||
<form id="updateProfile" class="form"> | ||
|
||
<label for="">Username:</label> | ||
<input id="username" type="text" name="handle" value="" placeholder="" required> | ||
<label for="">First name:</label> | ||
<input id="firstname" type="text" name="first_name" value="" placeholder="" required> | ||
<label for="">Last name:</label> | ||
<input id="lastname" type="text" name="last_name" value="" placeholder="" required> | ||
<label for="email">Email:</label> | ||
<input id="email" type="email" name="email" value="" placeholder="" required> | ||
<label for="">Cohort:</label> | ||
<input id="cohort" type="text" name="cohort" value="" placeholder="" required> | ||
<label for="">City:</label> | ||
<input id="city" type="text" name="city" value="" placeholder="" required> | ||
<label for="">Looking for work?</label> | ||
<input type="radio" name="work_looking_status" value="Y">Yes | ||
<input type="radio" name="work_looking_status" value="N">No | ||
<label for="">About me:</label> | ||
<textarea id="about_me" name="about_me"></textarea> | ||
<button type="submit" id="updateButton" name="updateButton">Update profile</button> | ||
|
||
</form> | ||
|
||
|
||
<script src="./public/logic.js" type="text/javascript"></script> | ||
<script src="./public/profile.js" type="text/javascript"></script> | ||
<script src="./public/storage.js" type="text/javascript"></script> | ||
</section> | ||
|
||
<section id="viewZone"> | ||
<h2>Profile</h2> | ||
<p id="handle"></p> | ||
<p id="first_name"></p> | ||
<p id="last_name"></p> | ||
<p id="email"></p> | ||
<p id="cohort"></p> | ||
<p id="city"></p> | ||
<p id="work_looking_status"></p> | ||
<p id="about_me"></p> | ||
</section> | ||
|
||
|
||
<script src="./public/logic.js" type="text/javascript"></script> | ||
<script src="./public/profile.js" type="text/javascript"></script> | ||
<script src="./public/storage.js" type="text/javascript"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const dbConnect = require('../database/db_connect'); | ||
|
||
const updateUser = (userID, values, cb)=> { | ||
|
||
var text = ` | ||
UPDATE users | ||
SET ( | ||
handle, | ||
first_name, | ||
last_name, | ||
email, | ||
cohort, | ||
city, | ||
work_looking_status, | ||
about_me | ||
) | ||
= ($1, $2, $3, $4, $5, $6, $7, $8) | ||
WHERE users.id = ${userID} | ||
` | ||
|
||
const addNewUser = { | ||
text: text, | ||
values: values | ||
} | ||
|
||
dbConnect.query(addNewUser, (err,res)=>{ | ||
if (err) { | ||
cb(err); | ||
} else { | ||
cb(null, res); | ||
console.log("Insert new data:", res); | ||
} | ||
}) | ||
} | ||
|
||
module.exports = updateUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters