diff --git a/src/admin/admin.controller.ts b/src/admin/admin.controller.ts index a3cb5fea6e5bab0a79fea575f49d689658e80238..858a0dcdb25829e013a48935db7ac788246edd2a 100644 --- a/src/admin/admin.controller.ts +++ b/src/admin/admin.controller.ts @@ -32,12 +32,19 @@ export class AdminController { @ApiOperation({ description: 'Validate structure ownership' }) public async validatePendingStructure(@Body() pendingStructureDto: PendingStructureDto) { const structure = await this.structuresService.findOne(pendingStructureDto.structureId); - return this.usersService.validatePendingStructure( + await this.usersService.validatePendingStructure( pendingStructureDto.userEmail, pendingStructureDto.structureId, structure.structureName, true ); + const pendingStructure = await this.usersService.getPendingStructures(); + return await Promise.all( + pendingStructure.map(async (structure) => { + structure.structureName = (await this.structuresService.findOne(structure.structureId)).structureName; + return structure; + }) + ); } @UseGuards(JwtAuthGuard, RolesGuard) @@ -46,11 +53,18 @@ export class AdminController { @ApiOperation({ description: 'Refuse structure ownership' }) public async refusePendingStructure(@Body() pendingStructureDto: PendingStructureDto) { const structure = await this.structuresService.findOne(pendingStructureDto.structureId); - return this.usersService.validatePendingStructure( + await this.usersService.validatePendingStructure( pendingStructureDto.userEmail, pendingStructureDto.structureId, structure.structureName, false ); + const pendingStructure = await this.usersService.getPendingStructures(); + return await Promise.all( + pendingStructure.map(async (structure) => { + structure.structureName = (await this.structuresService.findOne(structure.structureId)).structureName; + return structure; + }) + ); } }