Skip to content

Commit

Permalink
Adiciona indicação de que o email está sendo enviado
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldovictor committed Nov 11, 2023
1 parent da6c9ce commit 394953d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/pages/suggest-agenda/suggest-agenda.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ <h1>Sugestão de Pautas</h1>
<input type="text" class="input first" name="telefone-responsavel" formControlName="telefoneResponsavel" placeholder="Telefone do Responsável" required [ngClass]="{'required-field': !isTelefoneFilled}" (change)="onRequiredFieldsChange()">
<input type="text" class="input first" name="email-contato" formControlName="emailContato" placeholder="E-mail para contato" >
<div class="">
<button type="p-auto submit"><span>Enviar</span></button>
<button type="p-auto submit">
<span *ngIf="isSendingEmail">Enviando...</span>
<span *ngIf="!isSendingEmail">Enviar</span>
</button>
</div>
</form>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/app/pages/suggest-agenda/suggest-agenda.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class SuggestAgendaComponent implements OnInit {
isDescricaoFilled = false;
isResponsavelFilled = false;
isTelefoneFilled = false;
isSendingEmail = false;

constructor(
private fb: FormBuilder,
Expand Down Expand Up @@ -46,11 +47,15 @@ export class SuggestAgendaComponent implements OnInit {
emailData.email_contato = this.suggestAgendaForm.value.emailContato;
const emailUnB = '[email protected]';
emailData.recipients = [emailUnB];
this.isSendingEmail = true;
this.emailService.sendEmail(emailData).subscribe((res: HttpResponse<string>) => {
alert('Sugestão enviada com sucesso');
},
(error: HttpErrorResponse) => {
alert('error: ' + error.message);
},
() => {
this.isSendingEmail = false;
});
} else {
alert('Preencha os campos obrigatórios!');
Expand Down

0 comments on commit 394953d

Please sign in to comment.