diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 068170f6..c12b1a72 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8041,17 +8041,21 @@ export class OrganizationController extends Controller { }); let check: number = 0; + let notDelete: string[] = []; await Promise.all( profileLeave.map(async (profile) => { profile.leaveReason = "เกษียณอายุราชการ"; profile.isActive = false; - if (profile.keycloak != null) { + if (profile.keycloak != null && profile.keycloak != "") { const delUserKeycloak = await deleteUser(profile.keycloak); if (delUserKeycloak) { profile.keycloak = ""; profile.roleKeycloaks = []; check += 1; + } else { + // push array not delete + notDelete.push(profile.keycloak); } } @@ -8061,6 +8065,6 @@ export class OrganizationController extends Controller { // จำนวนคนที่ถูกแก้ไขเหตุผลการลาออก const total = profileLeave.length; - return new HttpSuccess({ total, successAmount: check }); + return new HttpSuccess({ total, successAmount: check, notDelete }); } }