fix
This commit is contained in:
@@ -1029,20 +1029,20 @@ async function loadUserData() {
|
|||||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
dbg("\u2190 User data", data);
|
dbg("\u2190 User data", data);
|
||||||
// unwrap envelope
|
// unwrap envelope: plain array or {data:[...]}
|
||||||
if (data && !Array.isArray(data) && Array.isArray(data.data)) {
|
if (Array.isArray(data)) {
|
||||||
data = data.data[0];
|
|
||||||
} else if (Array.isArray(data)) {
|
|
||||||
const first = data[0];
|
const first = data[0];
|
||||||
data =
|
data =
|
||||||
first && typeof first === "object" && "json" in first
|
first && typeof first === "object" && "json" in first
|
||||||
? first.json
|
? first.json
|
||||||
: first;
|
: first;
|
||||||
|
} else if (data && !Array.isArray(data) && Array.isArray(data.data)) {
|
||||||
|
data = data.data[0];
|
||||||
}
|
}
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
const invoiceEmail = stripQuotes(
|
const invoiceEmail = stripQuotes(
|
||||||
data.invoice_email || data.invoiceEmail || "",
|
data.invoice_mail || data.invoice_email || data.invoiceEmail || "",
|
||||||
);
|
);
|
||||||
const invInput = document.getElementById("invoice-email-input");
|
const invInput = document.getElementById("invoice-email-input");
|
||||||
if (invInput && invoiceEmail) invInput.value = invoiceEmail;
|
if (invInput && invoiceEmail) invInput.value = invoiceEmail;
|
||||||
@@ -1066,9 +1066,10 @@ async function loadUserData() {
|
|||||||
function copyAffiliateCode() {
|
function copyAffiliateCode() {
|
||||||
const code = document.getElementById("acct-affiliate-code")?.textContent;
|
const code = document.getElementById("acct-affiliate-code")?.textContent;
|
||||||
if (!code || code === "—") return;
|
if (!code || code === "—") return;
|
||||||
|
const link = `https://derez.ai?utm_source=${encodeURIComponent(code)}`;
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
.writeText(code)
|
.writeText(link)
|
||||||
.then(() => toast("Affiliate code copied!", "success"));
|
.then(() => toast("Affiliate link copied!", "success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeUserPanel() {
|
function closeUserPanel() {
|
||||||
|
|||||||
+1
-1
@@ -928,7 +928,7 @@
|
|||||||
onclick="copyAffiliateCode()"
|
onclick="copyAffiliateCode()"
|
||||||
style="display: none"
|
style="display: none"
|
||||||
>
|
>
|
||||||
Copy
|
Copy Affiliate Link
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user