diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index ecaa01eea467f9ac33b4ae75b2d60923171b89e4..5075823924774b30c36cf6d98ab111f7a74ed495 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -194,9 +194,10 @@ export class StructureService { return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email }); } - public sendMailOnStructureError(structureId: string, content: string, profile: User): Observable<boolean> { - console.log('send:', content, ' to:', structureId); - return; - //return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email }); + public sendMailOnStructureError(structureId: string, content: string, profile: User) { + return this.http.post<any>(`${this.baseUrl}/reportStructureError`, { + structureId, + content: content, + }); } } diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.html b/src/app/shared/components/text-input-modal/text-input-modal.component.html index d1835a7f3bfb7c6820c8341cc2f55784e6a993b1..15f690ba6c85d98d7cd41a3ef3c8ae70a80d0805 100644 --- a/src/app/shared/components/text-input-modal/text-input-modal.component.html +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.html @@ -3,12 +3,11 @@ <div class="contentModal" fxLayout="column" fxLayoutAlign="space-around center"> <h3>ATTENTION</h3> <p>{{ content }}</p> - <textarea ng-model="myContent" id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea> + <textarea #myText id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea> <div class="footerModal" fxLayout="row" fxLayoutAlign="space-around center"> - <button class="btn-primary small leave" (click)="closeModal(true)">Confirmer</button> - <button class="btn-primary small" (click)="closeModal(false)">Annuler</button> + <button class="btn-primary small leave" (click)="closeModal(true, myText.value)">Confirmer</button> + <button class="btn-primary small" (click)="closeModal(false, myText.value)">Annuler</button> </div> - {{ myContent }} </div> </div> </div> diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.ts b/src/app/shared/components/text-input-modal/text-input-modal.component.ts index 57a132f12398e7181f4773df59f3d247e5f0400e..524396cda60cc474a8de4e2af85c3a3a06166244 100644 --- a/src/app/shared/components/text-input-modal/text-input-modal.component.ts +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.ts @@ -10,11 +10,12 @@ export class TextInputModalComponent { @Input() public content: string; @Input() public placeholder: string; @Output() closed = new EventEmitter<boolean>(); + @Output() newContent = new EventEmitter<{ content: string; shouldSend: boolean }>(); public myContent: string; constructor() {} - public closeModal(value: boolean): void { - this.closed.emit(value); + public closeModal(shouldSend: boolean, content: string) { + this.newContent.emit({ content, shouldSend }); } } diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html index 5df01d73dc5fe0d8355d96e3275dd778fe44ae74..a4e2d0c4ff5381f70a8bfc300d972e69159fb3bd 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.html +++ b/src/app/structure-list/components/structure-details/structure-details.component.html @@ -385,4 +385,5 @@ 'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur ? Votre commentaire sera envoyé aux administrateurs.' " (closed)="sendErrorEmail($event)" + (newContent)="sendErrorEmail($event)" ></app-text-input-modal> diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index 6203f7c3df0d490cce2087ab726f76ab61a80dba..79042b4009613950ac749f5670025022d78f4dfe 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -295,11 +295,12 @@ export class StructureDetailsComponent implements OnInit { this.structureErrorModalOpenned = !this.structureErrorModalOpenned; } - public sendErrorEmail(shouldSend: boolean, content: string): void { + public sendErrorEmail(modalValue: any): void { this.displayModalError(); - if (shouldSend) { - console.log('conrtent is:', content); - this.structureService.sendMailOnStructureError(this.structure._id, '', this.currentProfile); + if (modalValue.shouldSend) { + this.structureService + .sendMailOnStructureError(this.structure._id, modalValue.content, this.currentProfile) + .subscribe(() => {}); } } }