User Management
This commit is contained in:
+20
-9
@@ -1280,6 +1280,7 @@
|
||||
}
|
||||
|
||||
const data = await parseJson(res);
|
||||
console.log("[HR] Users response:", data);
|
||||
buildDropdown(data);
|
||||
hideBanner();
|
||||
} catch (err) {
|
||||
@@ -1296,15 +1297,25 @@
|
||||
function buildDropdown(users) {
|
||||
userSelect.innerHTML =
|
||||
'<option value="">— Select User —</option>';
|
||||
// Normalise: webhook may return a single object or an array
|
||||
const list = Array.isArray(users)
|
||||
? users
|
||||
: users
|
||||
? [users]
|
||||
: [];
|
||||
list.forEach((u) => {
|
||||
const opt = new Option(u.Name, u.Name);
|
||||
userSelect.appendChild(opt);
|
||||
|
||||
// Normalise all shapes n8n may return:
|
||||
// { Name: ["Oliver", "Luka", "Benni"] } ← actual format
|
||||
// [ { Name: "Oliver" }, ... ] ← standard array
|
||||
// { Name: "Oliver" } ← single object
|
||||
let names = [];
|
||||
if (Array.isArray(users)) {
|
||||
// Array of objects: pull .Name from each
|
||||
names = users.map((u) => u.Name).filter(Boolean);
|
||||
} else if (users && Array.isArray(users.Name)) {
|
||||
// Single object with a Name array
|
||||
names = users.Name.filter(Boolean);
|
||||
} else if (users && users.Name) {
|
||||
// Single object with a single Name string
|
||||
names = [users.Name];
|
||||
}
|
||||
|
||||
names.forEach((name) => {
|
||||
userSelect.appendChild(new Option(name, name));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user