| | |
| | | }; |
| | | |
| | | this.forms = this.container.querySelectorAll('form'); |
| | | console.log(this.forms); |
| | | this.popup = new window.jvbPopup({ |
| | | toggle: this.toggle, |
| | | popup: this.container, |
| | |
| | | * Handle form submission |
| | | */ |
| | | async handleFormSubmit(event) { |
| | | console.log('Form Submission!'); |
| | | window.debouncer.cancel('check-referral'); |
| | | event.preventDefault(); |
| | | console.log('Still working?'); |
| | | |
| | | const form = event.target; |
| | | |
| | |
| | | try { |
| | | |
| | | let result = {success: false, message: ''}; |
| | | console.log(form); |
| | | console.log(form.id); |
| | | if (form.id === 'referral-code-form') { |
| | | if (!formData.get('name')) { |
| | | result.message += 'We need your name to know who you are.'; |
| | |
| | | data.context = {}; |
| | | data.context['redirect_to'] = window.location.href+'?seeReferral=1'; |
| | | console.log('Making Request with: ', data); |
| | | result = await this.makeRequest('magic-link', data); |
| | | result = await this.makeRequest('magic', data); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | async makeRequest(endpoint, data) { |
| | | if (![ |
| | | 'magic-link', |
| | | 'magic', |
| | | 'referrals/register', |
| | | 'referrals/check-code' |
| | | ].includes(endpoint)) { |