This commit is contained in:
MOHD ARIFF 2024-12-12 14:30:49 +08:00
parent 970ece5602
commit 45a94c99fc
2 changed files with 5 additions and 6 deletions

View File

@ -101,7 +101,7 @@ namespace PSTW_CentralSystem.Controllers.API
{ {
// Fetch all users excluding those with roles SuperAdmin or SystemAdmin // Fetch all users excluding those with roles SuperAdmin or SystemAdmin
var allUsers = await _authDbContext.Users var allUsers = await _authDbContext.Users
.Include(u => u.Department) .Include(u => u.Department).ThenInclude(d => d!.Company)
.ToListAsync(); .ToListAsync();
foreach (var u in allUsers) foreach (var u in allUsers)
@ -115,7 +115,7 @@ namespace PSTW_CentralSystem.Controllers.API
} }
else else
{ {
userInfo = await _authDbContext.Users.Include(u => u.Department).ToListAsync(); userInfo = await _authDbContext.Users.Include(u => u.Department).ThenInclude(d => d!.Company).ToListAsync();
} }
return Ok(new { UserInfo = userInfo }); return Ok(new { UserInfo = userInfo });

View File

@ -72,9 +72,7 @@
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (data.length > 0) { this.userList = data.userInfo.length ? data.userInfo : [];
this.userList = data.length ? data : [];
}
this.initiateTable(); this.initiateTable();
}) })
.catch(error => { .catch(error => {
@ -121,8 +119,9 @@
}, },
initiateTable() { initiateTable() {
self = this; self = this;
console.log(self.userList)
this.itemDatatable = $('#userDatatable').DataTable({ this.itemDatatable = $('#userDatatable').DataTable({
"data": this.userList, "data": self.userList,
"columns": [ "columns": [
{ {
"title": "UID", "title": "UID",