diff --git a/src/admin/admin.controller.ts b/src/admin/admin.controller.ts index 9a60f52df62f655ba9c13c47875e2b0cd39c8d93..2866987d4d2565cf46e9978b29c135feadd5f3de 100644 --- a/src/admin/admin.controller.ts +++ b/src/admin/admin.controller.ts @@ -40,6 +40,24 @@ export class AdminController { return await this.structuresService.findAllUnclaimed(); } + @UseGuards(JwtAuthGuard, RolesGuard) + @Roles('admin') + @Get('adminStructuresList') + @ApiOperation({ description: 'Get pending structre for validation' }) + public async getAdminStructuresList(): Promise<any> { + const structuresList = { claimed: [], inClaim: [], toClaim: [] }; + structuresList.inClaim = await this.getPendingAttachments(); + structuresList.toClaim = (await this.structuresService.findAllUnclaimed()).filter( + (demand) => !structuresList.inClaim.find((elem) => elem.structureId == demand.structureId) + ); + structuresList.claimed = (await this.structuresService.findAll()).filter( + (demand) => + !structuresList.inClaim.find((elem) => elem.structureId == demand.id) && + !structuresList.toClaim.find((elem) => elem.structureId == demand.id) + ); + return structuresList; + } + @UseGuards(JwtAuthGuard, RolesGuard) @Roles('admin') @Post('validatePendingStructure')