Update app.js
This commit is contained in:
@@ -1402,9 +1402,17 @@ async function loadAffiliateLinks() {
|
|||||||
function renderAffiliateLinks(data) {
|
function renderAffiliateLinks(data) {
|
||||||
const body = document.getElementById("affiliate-links-body");
|
const body = document.getElementById("affiliate-links-body");
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
const rows = Array.isArray(data) ? data : data && data.data ? data.data : [];
|
// data is either { areas: [...] } or [{ areas: [...] }] or { data: [...] }
|
||||||
const areas =
|
let areas = [];
|
||||||
rows.length && Array.isArray(rows[0].areas) ? rows[0].areas : [];
|
if (data && Array.isArray(data.areas)) {
|
||||||
|
areas = data.areas;
|
||||||
|
} else if (data && Array.isArray(data.data)) {
|
||||||
|
const first = data.data[0];
|
||||||
|
if (first && Array.isArray(first.areas)) areas = first.areas;
|
||||||
|
} else if (Array.isArray(data)) {
|
||||||
|
const first = data[0];
|
||||||
|
if (first && Array.isArray(first.areas)) areas = first.areas;
|
||||||
|
}
|
||||||
const filtered = areas.filter((a) => a.text && a.link);
|
const filtered = areas.filter((a) => a.text && a.link);
|
||||||
if (!filtered.length) {
|
if (!filtered.length) {
|
||||||
body.innerHTML =
|
body.innerHTML =
|
||||||
|
|||||||
Reference in New Issue
Block a user