From 3baf3d2545ba6ece6b74a64c0def59bd0774cf54 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 10 Jun 2026 16:34:12 +0000
Subject: [PATCH] =Laid the groundwork for an improved DashboardManager.php setup. Have to put it aside so I can get the dang Northeh done though.
---
assets/js/concise/Referral.js | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/assets/js/concise/Referral.js b/assets/js/concise/Referral.js
index f56d939..7764657 100644
--- a/assets/js/concise/Referral.js
+++ b/assets/js/concise/Referral.js
@@ -35,7 +35,7 @@
};
this.forms = this.container.querySelectorAll('form');
- this.popup = new window.jvbPopup({
+ this.popup = window.jvbPopup.registerPopup({
toggle: this.toggle,
popup: this.container,
name: 'Referral Box',
@@ -78,7 +78,7 @@
endpoint: 'referrals/stats',
TTL: 5 * 60 * 1000,
showLoading: false,
- delayFetch: false,
+ delayFetch: true,
filters: {
type: 'dashboard',
user: window.auth.getUser()
@@ -91,7 +91,7 @@
endpoint: 'referrals',
TTL: 10 * 60 * 1000,
showLoading: false,
- delayFetch: false,
+ delayFetch: true,
filters: {
user: window.auth.getUser(),
status: 'all',
@@ -640,8 +640,9 @@
referral_code: formData.get('referral_code')
};
- if (formData.get('cf-turnstile-response')) {
- data['cf-turnstile-response'] = formData.get('cf-turnstile-response');
+ const turnstileInput = form.querySelector('input[name="cf-turnstile-response"]');
+ if (turnstileInput && turnstileInput.value) {
+ data['cf-turnstile-response'] = turnstileInput.value;
}
if (!data.name || !data.email || !data.referral_code) {
@@ -652,18 +653,19 @@
} else if (form.id === 'login-form') {
let data = {
type: 'login',
- email: formData.get('login_email'),
+ user_email: formData.get('login_email'),
context: {
redirect_to: window.location.href + '?seeReferral=1'
}
};
- if (formData.get('cf-turnstile-response')) {
- data['cf-turnstile-response'] = formData.get('cf-turnstile-response');
+ const turnstileInput = form.querySelector('input[name="cf-turnstile-response"]');
+ if (turnstileInput && turnstileInput.value) {
+ data['cf-turnstile-response'] = turnstileInput.value;
}
- if (!data.email) {
+ if (!data['user_email']) {
result.message = 'Please fill in your email';
} else {
- result = await this.makeRequest('magic', data);
+ result = await this.makeRequest('auth/magic', data);
}
}
@@ -682,7 +684,7 @@
async makeRequest(endpoint, data) {
const validEndpoints = [
- 'magic',
+ 'auth/magic',
'auth/register'
];
@@ -690,16 +692,11 @@
return { success: false, message: 'Invalid endpoint' };
}
- const response = await fetch(`${jvbSettings.api}${endpoint}`, {
+ const response = await window.auth.fetch(`${jvbSettings.api}${endpoint}`, {
method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'X-WP-Nonce': window.auth.getNonce(),
- },
body: JSON.stringify(data)
});
- // Add error handling to see the actual response
if (!response.ok) {
const errorText = await response.text();
console.error('Error response:', response.status, errorText);
--
Gitblit v1.10.0