diff --git a/src/modules/minglaradmin/handlers/getAllHostApplication.ts b/src/modules/minglaradmin/handlers/getAllHostApplication.ts index 0d6056e..b56154a 100644 --- a/src/modules/minglaradmin/handlers/getAllHostApplication.ts +++ b/src/modules/minglaradmin/handlers/getAllHostApplication.ts @@ -37,9 +37,11 @@ export const handler = safeHandler(async ( // Get search query from query parameters const search = event.queryStringParameters?.search || ''; + // Extract userStatus (e.g. 'new') from query parameters + const userStatus = event.queryStringParameters?.userStatus || ''; // Get all host applications from service based on user role - const hostApplications = await minglarService.getAllHostApplications(user.id, user.roleXid, search); + const hostApplications = await minglarService.getAllHostApplications(user.id, user.roleXid, search, userStatus); return { statusCode: 200, diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index 751ca8a..2dcd75f 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -485,7 +485,7 @@ export class MinglarService { }) } - async getAllHostApplications(userId: number, userRoleXid: number, search?: string) { + async getAllHostApplications(userId: number, userRoleXid: number, search?: string, userStatus?: string) { // Build where clause based on user role const whereClause: any = { isActive: true, @@ -494,7 +494,7 @@ export class MinglarService { notIn: [ROLE.CO_ADMIN, ROLE.ACCOUNT_MANAGER] }, } - }; + }; // Add search filter if search query is provided if (search && search.trim() !== '') { @@ -518,12 +518,10 @@ export class MinglarService { }; } } - - // If user is Co_Admin or Account_Manager, filter by assigned hosts only - if (userRoleXid === ROLE.CO_ADMIN || userRoleXid === ROLE.ACCOUNT_MANAGER) { - whereClause.accountManagerXid = userId; + // Apply userStatus filter (case-insensitive) e.g. userStatus=new / NEW / New + if (userStatus && userStatus.trim().toLowerCase() === MINGLAR_STATUS_DISPLAY.NEW.toLowerCase()) { + whereClause.adminStatusDisplay = MINGLAR_STATUS_DISPLAY.NEW; } - // If user is Minglar Admin, show all hosts (no additional filter needed) const hostHeaders = await this.prisma.hostHeader.findMany({ where: whereClause, @@ -532,6 +530,26 @@ export class MinglarService { hostStatusDisplay: true, createdAt: true, companyName: true, + assignedOn: true, + cities: { + select: { + id: true, + cityName: true, + } + }, + adminStatusDisplay: true, + countries: { + select: { + id: true, + countryName: true, + } + }, + states: { + select: { + id: true, + stateName: true, + } + }, user: { select: { id: true, @@ -563,7 +581,12 @@ export class MinglarService { host: host.user, hostStatusDisplay: host.hostStatusDisplay, submittedOn: host.createdAt, - accountManager: host.accountManager || null + accountManager: host.accountManager || null, + companyName: host.companyName || null, + city: host.cities || null, + state: host.states || null, + country: host.countries || null, + assignedOn: host.assignedOn || null, })); }