summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib')
-rw-r--r--StoneIsland/www/js/lib/account/OrdersView.js1
-rw-r--r--StoneIsland/www/js/lib/account/PaymentView.js1
-rw-r--r--StoneIsland/www/js/lib/account/ProfileView.js65
-rw-r--r--StoneIsland/www/js/lib/account/SettingsView.js1
-rw-r--r--StoneIsland/www/js/lib/account/ShippingView.js1
-rw-r--r--StoneIsland/www/js/lib/auth/SignupView.js14
6 files changed, 76 insertions, 7 deletions
diff --git a/StoneIsland/www/js/lib/account/OrdersView.js b/StoneIsland/www/js/lib/account/OrdersView.js
index f9a2a35c..7283b65c 100644
--- a/StoneIsland/www/js/lib/account/OrdersView.js
+++ b/StoneIsland/www/js/lib/account/OrdersView.js
@@ -13,6 +13,7 @@ var OrdersView = View.extend({
},
show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
app.footer.hide()
document.body.className = "orders"
this.el.className = "list"
diff --git a/StoneIsland/www/js/lib/account/PaymentView.js b/StoneIsland/www/js/lib/account/PaymentView.js
index 4d6ccce5..d61ab5ab 100644
--- a/StoneIsland/www/js/lib/account/PaymentView.js
+++ b/StoneIsland/www/js/lib/account/PaymentView.js
@@ -14,6 +14,7 @@ var PaymentView = FormView.extend({
},
show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
app.footer.show("SAVE", "CANCEL")
document.body.className = "payment"
},
diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js
index 83ab0cdc..9150f874 100644
--- a/StoneIsland/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/www/js/lib/account/ProfileView.js
@@ -12,8 +12,11 @@ var ProfileView = FormView.extend({
},
show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
app.footer.show("SAVE", "CANCEL")
document.body.className = "profile"
+
+ this.preload(auth.user)
},
validate_presence: {
@@ -23,9 +26,69 @@ var ProfileView = FormView.extend({
},
validate_fields: function(data, errors){
- if (! data.CurrentPassword && data.NewPassword) { errors.push([ "CurrentPassword", "Please enter your current password." ]) }
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (! data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) { errors.push([ "CurrentPassword", "Please enter your current password." ]) }
if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) }
if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) }
+ if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+
+ data.BirthDay += "T00:00:00Z"
+ data.YooxLetter = data.YooxLetter || "false"
+ },
+
+ save: function(e){
+ e && e.preventDefault()
+
+ var valid = this.validate()
+ if (valid.errors.length) {
+ this.show_errors(valid.errors)
+ return
+ }
+ else {
+ this.hide_errors()
+ }
+
+ var data = valid.data
+ if (data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) {
+ data.NewPassword = data.NewPassword || data.CurrentPassword
+ data.NewEmail = data.NewEmail || auth.user.Email
+
+ sdk.account.update_mail_and_password({
+ data: {
+ Password: data.CurrentPassword,
+ NewPassword: data.NewPassword || data.CurrentPassword,
+ Email: auth.user,
+ NewEmail: data.NewEmail || auth.user.Email,
+ },
+ success: function(){ console.log("updated password") },
+ error: function(){ console.log("error updating password") },
+ })
+ }
+
+ var submissible_data = _.pick(valid.data, "Name Surname BirthDay Gender YooxLetter".split(" "))
+
+ submissible_data.idUser = auth.user_id
+ submissible_data.AccessToken = auth.access_token
+ submissible_data.Premium = "false"
+ submissible_data.LanguageId = ""
+ submissible_data.SiteCode = "STONEISLAND_US"
+ submissible_data.FuriganaName = ""
+ submissible_data.FuriganaSurname = ""
+ submissible_data.UserPromocode = ""
+ submissible_data.DataProfiling = "true"
+
+ app.curtain.show("loading")
+ sdk.account.update({
+ data: submissible_data,
+ success: function(data){
+ app.curtain.hide("loading")
+ this.success(data)
+ }.bind(this),
+ error: function(data){
+ app.curtain.hide("loading")
+ this.error(data)
+ }.bind(this),
+ })
},
success: function(data){
diff --git a/StoneIsland/www/js/lib/account/SettingsView.js b/StoneIsland/www/js/lib/account/SettingsView.js
index ba871543..81b8b5cc 100644
--- a/StoneIsland/www/js/lib/account/SettingsView.js
+++ b/StoneIsland/www/js/lib/account/SettingsView.js
@@ -12,6 +12,7 @@ var SettingsView = FormView.extend({
},
show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
app.footer.show("SAVE", "CANCEL")
document.body.className = "settings"
},
diff --git a/StoneIsland/www/js/lib/account/ShippingView.js b/StoneIsland/www/js/lib/account/ShippingView.js
index bc4d24ef..f5bf1661 100644
--- a/StoneIsland/www/js/lib/account/ShippingView.js
+++ b/StoneIsland/www/js/lib/account/ShippingView.js
@@ -13,6 +13,7 @@ var ShippingView = FormView.extend({
},
show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
app.footer.show("SAVE", "CANCEL")
document.body.className = "shipping"
},
diff --git a/StoneIsland/www/js/lib/auth/SignupView.js b/StoneIsland/www/js/lib/auth/SignupView.js
index 5d947d41..7f894c3c 100644
--- a/StoneIsland/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/www/js/lib/auth/SignupView.js
@@ -12,7 +12,7 @@ var SignupView = FormView.extend({
"Gender": "U",
"Name": "TestName",
"Surname": "TestSurname",
- "Birthday": "1978-11-12",
+ "BirthDay": "1978-11-12",
"DataProfiling": true,
"DataProfiling2": true,
},
@@ -55,16 +55,17 @@ var SignupView = FormView.extend({
validate_fields: function(data, errors){
if (data.Password.length < 7) { errors.push([ "Password", "Password must be 7 characters or more." ]) }
if (data.Password !== data.Password2) { errors.push([ "Password2", "Passwords don't match." ]) }
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
if (data.Email.toLowerCase() !== data.ConfirmEmail.toLowerCase()) { errors.push([ "ConfirmEmail", "Email addresses don't match." ]) }
if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) }
if (data.DataProfiling2 !== "true") { errors.push([ "DataProfiling2", "You must consent to use this service." ]) }
- if (! data.YooxLetter) { data.YooxLetter = "false" }
+ if (! data.YooxLetter) { data.YooxLetter = false }
delete data.DataProfiling2
delete data.ConfirmEmail
- data.Birthday += "T00:00:00Z"
+ data.BirthDay += "T00:00:00Z"
this.last_data = data
console.log(data)
@@ -84,9 +85,10 @@ var SignupView = FormView.extend({
success: function(data){
console.log('success', data)
auth.user = auth.user || {}
- auth.user.name = this.last_data.Name
- auth.user.surname = this.last_data.Surname
- auth.user.email = this.last_data.Email
+ auth.user.Name = this.last_data.Name
+ auth.user.Surname = this.last_data.Surname
+ auth.user.Email = this.last_data.Email
+ auth.user.BirthDay = this.last_data.BirthDay
app.account.logged_in(function(){ app.router.go("store") })
},