Skip to content

Commit

Permalink
Merge 6f72ea3 into 19f58c6
Browse files Browse the repository at this point in the history
  • Loading branch information
chidimo committed May 28, 2019
2 parents 19f58c6 + 6f72ea3 commit ae1a4fd
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 202 deletions.
1 change: 1 addition & 0 deletions UI/authentication.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1 class="authentication_title">Create your account</h1>
</footer>
</div>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="./js/authentication.js"></script>
</body>
</html>
21 changes: 19 additions & 2 deletions UI/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ label {
display: block;
}

/* names */

.capitalize {
text-transform: capitalize;
}

/* tables */
.table_wrapper {
overflow-x: auto;
Expand Down Expand Up @@ -275,7 +281,6 @@ ul.base_ul {
}

.submenu_username a {
text-transform: capitalize;
margin: 0;
font-size: 16px;
}
Expand Down Expand Up @@ -526,6 +531,18 @@ footer {

/* Dashboard */

#mailverification {
padding: 5px;
margin-bottom: 10px;
font-size: 28px;
}

#mailverification button {
width: 100%;
height: 60px;
font-size: 28px;
}

.card {
padding: 10px;
width: 450px;
Expand All @@ -547,7 +564,7 @@ footer {
overflow: hidden;
}

.fa-check-circle {
.status-ok {
color: green;
}

Expand Down
29 changes: 17 additions & 12 deletions UI/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<li>
<a id="profile_dropdown" href="#" class="">
<span class="micro_avatar_wrapper">
<img class="micro_avatar" src="https://s3.eu-west-2.amazonaws.com/quick-credit/profile_photos/1" alt="">
<img class="photos micro_avatar" alt="">
</span>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -50,7 +50,7 @@
<ul id="sub_menu">
<div class="submenu_username">
<a href="./dashboard.html">
<div>chidi orji matthew</div>
<div><span class="capitalize firstname"></span> <span class="capitalize lastname"></span></div>
</a>
</div>
<hr class="submenu_hr">
Expand All @@ -62,7 +62,7 @@
<hr class="submenu_hr">
<li>
<a href="authentication.html">
<div class="sub_routes">Logout</div>
<div id="logout" class="sub_routes">Logout</div>
</a>
</li>
</ul>
Expand All @@ -74,17 +74,22 @@

<section id="dashboard">
<div class="container">
<h2 class="page_heading">Orji Chidi <i class="fas fa-check-circle"></i></h2>
<h2 class="page_heading"><span class='capitalize firstname'></span> <span class='capitalize lastname'></span> <i class="fas fa-check-circle"></i></h2>

<hr class="section_divider">

<div id="mailverification">
<p>Your email address has not been confirmed. Click the box below to get your verification email</p>

<button class="">Get confirmation email</button>
</div>

<div class="user_information">

<div class="user_card card">
<div
class="user_photo"
style="background-image: url('https://s3.eu-west-2.amazonaws.com/quick-credit/profile_photos/1')"
id="dp"
class="user_photo"
style="background-image: url('https://s3.eu-west-2.amazonaws.com/quick-credit/profile_photos/1')"
>
<svg
id="profile_pix"
Expand Down Expand Up @@ -112,15 +117,15 @@ <h2 class="page_heading">Orji Chidi <i class="fas fa-check-circle"></i></h2>
<hr class="card_divider">

<div class="user_info">
<h3>Orji Chidi <i class="fas fa-check-circle"></i></h3>
<p>email@address.com</p>
<p>+2341234567890</p>
<h3><span class='capitalize lastname'></span> <span class='capitalize firstname'></span> <i class="fas fa-check-circle"></i></h3>
<p><span id="email"></span></p>
<p><span id="phone"></span></p>
</div>
</div>

<div class="user_address card">
<p><span class="addresses">Home</span>: 21 Olugbani street, Off Governor road, By Bayota motel, Ikotun Egbe, Lagos</p>
<p><span class="addresses">Office</>:</span> Andela EPIC Towers, 235 Ikorodu Road, By Niger Insurance House</p>
<p><span class="addresses">Home</span>: <span class="capitalize" id="home"></span></p>
<p><span class="addresses">Office</>:</span> <span class="capitalize" id="office"></span></p>
</div>
</div>

Expand Down
87 changes: 33 additions & 54 deletions UI/js/authentication.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
const signin_form = document.getElementById('signin_form');
const signup_form = document.getElementById('signup_form');

Expand Down Expand Up @@ -26,73 +27,51 @@ activate_signup.addEventListener('click', e => {
activate_form(activate_signup, activate_signin);
});


const base_url = 'https://qcredit.herokuapp.com/api/v1';
// const base_url = 'http://localhost:3000';
// const base_url = 'http://localhost:3000/api/v1';
const signupEndpoint = `${base_url}/auth/signup`;
const signinEndpoint = `${base_url}/auth/signin`;

signin_form.addEventListener('submit', e => {
e.preventDefault();
const email = document.getElementById('signin_email').value;
const password = document.getElementById('signin_password').value;

const body = { email, password };

const options = {
method: 'POST',
body: JSON.stringify(body),
const save_user = async (endpoint, body, redirect_to) => {
const config = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'PUT, GET, POST',
},
};
fetch(signinEndpoint, options)
.then(response => {
if (response.status !== 200) {
console.log('Request error ', response.status);
}
return response.json(); })
.then(resp => {
console.log('response ', resp);
if (resp.error) { alert(resp.error); }
else {
localStorage.setItem('QCtoken', resp.data.token);
window.location = './dashboard.html';
}
});
try {
const { data, status
} = await axios.post(endpoint, body, config);
const user = data.data;
if ((status === 200) || (status === 201)) {
localStorage.QCToken = user.token;
localStorage.user = JSON.stringify(user);
window.location = redirect_to;
}
}
catch (e) {
const { response } = e;
const { data, status, statusText } = response;
console.log(`
${JSON.stringify(data)}, \n ${status}, \n ${statusText}`);
}
};

signin_form.addEventListener('submit', async e => {
e.preventDefault();
const email = document.getElementById('signin_email').value;
const password = document.getElementById('signin_password').value;
const body = JSON.stringify({ email, password });
save_user(signinEndpoint, body, './dashboard.html');
});

signup_form.addEventListener('click', e => {
signup_form.addEventListener('submit', async e => {
e.preventDefault();
const email = document.getElementById('signup_email').value;
const password = document.getElementById('signup_password').value;
const confirm_password = document.getElementById('confirm_password').value;
const firstname = document.getElementById('first_name').value;
const lastname = document.getElementById('last_name').value;

const body = { email, password, confirm_password };

const options = {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
},
};
fetch(signupEndpoint, options)
.then(response => {
if (response.status !== 200) {
console.log('Request error ', response.status);
}
return response.json(); })
.then(resp => {
console.log('response ', resp);
if (resp.error) { alert(resp.error); }
else {
localStorage.setItem('QCtoken', resp.data.token);
window.location = './dashboard.html';
}
});
const body = JSON.stringify({ email, password, confirm_password });
save_user(signupEndpoint, body, './profile.edit.html');
});
Loading

0 comments on commit ae1a4fd

Please sign in to comment.