Skip to content

Commit

Permalink
Customer account page (mrvautin#124)
Browse files Browse the repository at this point in the history
* Adding customer login & account page support

* Added account link

* Sorting orders on account page

* Small UI fixes

* Removed debugs

* Added tests

Co-authored-by: Mark Moffat <[email protected]>
  • Loading branch information
mrvautin and Mark Moffat authored Mar 17, 2020
1 parent 6b9f4b2 commit 78e06e5
Show file tree
Hide file tree
Showing 19 changed files with 411 additions and 32 deletions.
3 changes: 3 additions & 0 deletions lib/schemas/editCustomer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$id": "editCustomer",
"type": "object",
"properties": {
"company": {
"type": "string"
},
"email": {
"type": "string",
"format": "emailAddress"
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/admin.min.js

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions public/javascripts/expressCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ $(document).ready(function (){
e.preventDefault();
});

$('#customerloginForm').on('click', function(e){
if(!e.isDefaultPrevented()){
e.preventDefault();
$.ajax({
method: 'POST',
url: '/customer/login_action',
data: {
loginEmail: $('#email').val(),
loginPassword: $('#password').val()
}
})
.done(function(msg){
window.location = '/customer/account';
})
.fail(function(msg){
showNotification(msg.responseJSON.message, 'danger');
});
}
e.preventDefault();
});

// call update settings API
$('#customerLogin').on('click', function(e){
if(!e.isDefaultPrevented()){
Expand Down Expand Up @@ -270,6 +291,37 @@ $(document).ready(function (){
e.preventDefault();
});

// Customer saving own details
$('#customerSave').validator().on('click', function(e){
e.preventDefault();
if($('#customer-form').validator('validate').has('.has-error').length === 0){
$.ajax({
method: 'POST',
url: '/customer/update',
data: {
email: $('#shipEmail').val(),
company: $('#shipCompany').val(),
firstName: $('#shipFirstname').val(),
lastName: $('#shipLastname').val(),
address1: $('#shipAddr1').val(),
address2: $('#shipAddr2').val(),
country: $('#shipCountry').val(),
state: $('#shipState').val(),
postcode: $('#shipPostcode').val(),
phone: $('#shipPhoneNumber').val(),
password: $('#newCustomerPassword').val(),
orderComment: $('#orderComment').val()
}
})
.done(function(){
showNotification('Customer saved', 'success');
})
.fail(function(msg){
showNotification(msg.responseJSON.message, 'danger');
});
}
});

$(document).on('click', '.image-next', function(e){
var thumbnails = $('.thumbnail-image');
var index = 0;
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/expressCart.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions public/stylesheets/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ body .popover {
[role="main"] {
padding-top: 20px;
margin-bottom: 20px;
min-height: 100%;
height: 100%;
}
@media (min-width: 768px) {
[role="main"] {
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions public/stylesheets/less/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ body .popover{display:none !important; }
[role="main"] {
padding-top: 20px;
margin-bottom: 20px;
min-height: 100%;
height: 100%;
}

@media (min-width: 768px) {
Expand Down
Loading

0 comments on commit 78e06e5

Please sign in to comment.