Skip to content
Snippets Groups Projects
Commit cef54516 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix: aptic structure init + admin structurename for claim validation

parent ee0af428
No related branches found
No related tags found
2 merge requests!38Recette,!37Dev
......@@ -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)
......
......@@ -11,4 +11,9 @@ export class PendingStructureDto {
@IsString()
@ApiProperty({ type: String })
readonly structureId: string;
@IsNotEmpty()
@IsString()
@ApiProperty({ type: String })
structureName: string;
}
......@@ -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
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment