Commit b046bb63 authored by Cliff Li's avatar Cliff Li Committed by Sandro Lutz
Browse files

Add success/error message for email signup.

parent 8fdfe11e
...@@ -144,6 +144,8 @@ ...@@ -144,6 +144,8 @@
"events.delete_signup": "Anmeldung löschen", "events.delete_signup": "Anmeldung löschen",
"events.loading": "Laden...", "events.loading": "Laden...",
"events.load_more": "Mehr Events laden", "events.load_more": "Mehr Events laden",
"events.emailsignup_success": "Anmeldung erfolgreich.",
"events.emailsignup_fail": "Anmeldung fehlgeschlagen. Probier es später wieder.",
"companies.contact_information": "Kontakt-Informationen", "companies.contact_information": "Kontakt-Informationen",
"companies.email": "Email", "companies.email": "Email",
"companies.phone": "Telefon", "companies.phone": "Telefon",
......
...@@ -159,6 +159,8 @@ ...@@ -159,6 +159,8 @@
"errors.not_found.text": "The page you are looking for could not be found.", "errors.not_found.text": "The page you are looking for could not be found.",
"errors.translation_unavailable": "Translation not available.", "errors.translation_unavailable": "Translation not available.",
"errors.shown_language": "Showing text in %{shown_language}", "errors.shown_language": "Showing text in %{shown_language}",
"events.emailsignup_success": "Sign up successful.",
"events.emailsignup_fail": "Sign up failed. Try again later.",
"filtered_list.show_filter": "Show filter", "filtered_list.show_filter": "Show filter",
"filtered_list.hide_filter": "Hide filter", "filtered_list.hide_filter": "Hide filter",
"filtered_list.show_list": "Back to the list" "filtered_list.show_list": "Back to the list"
......
...@@ -23,6 +23,7 @@ class EventSignupForm extends JSONSchemaForm { ...@@ -23,6 +23,7 @@ class EventSignupForm extends JSONSchemaForm {
this.email = ''; this.email = '';
this.emailErrors = []; this.emailErrors = [];
this.emailValid = false; this.emailValid = false;
this.emailSignup = null;
if (isLoggedIn()) { if (isLoggedIn()) {
this.event.loadSignup().then(() => { this.event.loadSignup().then(() => {
if (this.event.signupData) { if (this.event.signupData) {
...@@ -35,8 +36,10 @@ class EventSignupForm extends JSONSchemaForm { ...@@ -35,8 +36,10 @@ class EventSignupForm extends JSONSchemaForm {
async signup() { async signup() {
try { try {
await this.event.signup(super.getValue(), this.email); await this.event.signup(super.getValue(), this.email);
this.emailSignup = 'success';
} catch (err) { } catch (err) {
log(err); log(err);
this.emailSignup = 'fail';
} }
} }
...@@ -71,10 +74,15 @@ class EventSignupForm extends JSONSchemaForm { ...@@ -71,10 +74,15 @@ class EventSignupForm extends JSONSchemaForm {
} }
return m('form', { onsubmit: () => false }, elements); return m('form', { onsubmit: () => false }, elements);
} else if (this.event.allow_email_signup) { } else if (this.event.allow_email_signup) {
const elements = this.renderFormElements(); if (!this.emailSignup) {
elements.push(this._renderEmailField()); const elements = this.renderFormElements();
elements.push(this._renderSignupButton()); elements.push(this._renderEmailField());
return m('form', { onsubmit: () => false }, elements); elements.push(this._renderSignupButton());
return m('form', { onsubmit: () => false }, elements);
} else if (this.emailSignup) {
if (this.emailSignup === 'success') return m('span', i18n('events.emailsignup_success'));
if (this.emailSignup === 'fail') return m('span', i18n('events.emailsignup_fail'));
}
} }
return m('div', [ return m('div', [
m('span', `${i18n('events.amiv_members_only')} `), m('span', `${i18n('events.amiv_members_only')} `),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment