diff --git a/src/admin/admin.controller.ts b/src/admin/admin.controller.ts index fe16c656f87b81aa1387fddd78904e413ab715da..a3cb5fea6e5bab0a79fea575f49d689658e80238 100644 --- a/src/admin/admin.controller.ts +++ b/src/admin/admin.controller.ts @@ -16,8 +16,14 @@ export class AdminController { @Roles('admin') @Get('pendingStructures') @ApiOperation({ description: 'Get pending structre for validation' }) - public getPendingAttachments(): Promise<PendingStructureDto[]> { - return this.usersService.getPendingStructures(); + public async getPendingAttachments(): Promise<PendingStructureDto[]> { + 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) diff --git a/src/admin/dto/pending-structure.dto.ts b/src/admin/dto/pending-structure.dto.ts index 67db3710579161c25baefdce81f0462a7e73cdb6..e07fd91f860cc5468be1e2449ce05897a26b1465 100644 --- a/src/admin/dto/pending-structure.dto.ts +++ b/src/admin/dto/pending-structure.dto.ts @@ -11,4 +11,9 @@ export class PendingStructureDto { @IsString() @ApiProperty({ type: String }) readonly structureId: string; + + @IsNotEmpty() + @IsString() + @ApiProperty({ type: String }) + structureName: string; } diff --git a/src/structures/services/aptic-structures.service.ts b/src/structures/services/aptic-structures.service.ts index 854a83f047b2b876adacd32265f1b789f81ca994..fff5c3326547acc5f68bebbc93d0e81ef050b198 100644 --- a/src/structures/services/aptic-structures.service.ts +++ b/src/structures/services/aptic-structures.service.ts @@ -49,12 +49,25 @@ export class ApticStructuresService { if (!exist) { Logger.log(`Create structure : ${structure.presence_name}`, 'ApticStructuresService - createApticStructures'); const createdStructure = new this.structureModel(); - createdStructure.coord = [structure.gps_lng, structure.gps_lat]; + // Known fields createdStructure.structureName = structure.presence_name; createdStructure.contactPhone = structure.presence_phone; + // Unkown fields (but mandatory) + createdStructure.contactMail = 'unknown@unknown.com'; createdStructure.labelsQualifications = ['passNumerique']; + createdStructure.structureType = 'autre'; + createdStructure.pmrAccess = false; + createdStructure.accessModality = ['accesLibre']; + createdStructure.publics = ['toutPublic']; createdStructure.accountVerified = true; + createdStructure.freeWorkShop = false; + createdStructure.nbComputers = null; + createdStructure.nbPrinters = null; + createdStructure.nbScanners = null; + createdStructure.nbTablets = null; + createdStructure.nbNumericTerminal = null; // Address + createdStructure.coord = [structure.gps_lng, structure.gps_lat]; createdStructure.address = this.formatAddress(structure); createdStructure.save(); // Send admin weird structure mail diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 0de3143a240cc0fa3fb42d06dfb675ae3af4ba7f..045ac5a8a821215393fa5a0b22b998f84ceee027 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -122,7 +122,10 @@ export class StructuresService { if (address && address.geometry) { structure.coord = address.geometry.coordinates; } else { - Logger.error(`No coord found: ${structure.address.street}`, 'StructureService'); + Logger.error( + `No coord found for: ${structure.address.numero} ${structure.address.street} ${structure.address.commune}`, + 'StructureService' + ); structure.coord = []; } resolve(structure);