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