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
var allUsers = await _authDbContext.Users
.Include(u => u.Department)
.Include(u => u.Department).ThenInclude(d => d!.Company)
.ToListAsync();
foreach (var u in allUsers)
@ -115,7 +115,7 @@ namespace PSTW_CentralSystem.Controllers.API
}
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 });

View File

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