-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajusta formatação e corrige requisição para endpoint do email
- Loading branch information
1 parent
a7ba678
commit afb3930
Showing
5 changed files
with
45 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
src/app/pages/suggest-agenda/suggest-agenda.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
<div class="containner" > | ||
<div> | ||
<h1>Sugestão de Pautas</h1> | ||
<form [formGroup]="suggestAgendaForm" (submit)="sendSuggestAgenda()"> | ||
<input type="text" class="first" name="tema" formControlName="tema" placeholder="Tema" required><br><br> | ||
<textarea class="descricao" name="descicao" formControlName="descricao" placeholder="Descrição" required></textarea><br><br> | ||
<input type="text" class="first" name="quando" formControlName="quando" placeholder="Quando (data e hora)" required><br><br> | ||
<input type="text" class="first" name="local" formControlName="local" placeholder="Local" required><br><br> | ||
<input type="text" class="first" name="responsavel" formControlName="responsavel" placeholder="Responsável" required><br><br> | ||
<input type="text" class="first" name="telefone-responsavel" formControlName="telefoneResponsavel" placeholder="Telefone do Responsável" required><br><br> | ||
<input type="text" class="first" name="email-contato" formControlName="emailContato" placeholder="E-mail para contato" required><br><br> | ||
<button type="submit"><span>Enviar</span></button> | ||
<form [formGroup]="suggestAgendaForm" (submit)="sendSuggestAgenda()" class="flex flex-col gap-y-3"> | ||
<input type="text" class="input first" name="tema" formControlName="tema" placeholder="Tema" > | ||
<textarea class="input descricao" name="descicao" formControlName="descricao" placeholder="Descrição" required></textarea> | ||
<input type="text" class="input first" name="quando" formControlName="quando" placeholder="Quando (data e hora)" > | ||
<input type="text" class="input first" name="local" formControlName="local" placeholder="Local" > | ||
<input type="text" class="input first" name="responsavel" formControlName="responsavel" placeholder="Responsável" required> | ||
<input type="text" class="input first" name="telefone-responsavel" formControlName="telefoneResponsavel" placeholder="Telefone do Responsável" required> | ||
<input type="text" class="input first" name="email-contato" formControlName="emailContato" placeholder="E-mail para contato" > | ||
<div> | ||
<button type="submit"><span>Enviar</span></button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
import { EmailService } from 'src/app/services/email.service'; | ||
import { EmailData } from 'src/shared/model/email.model'; | ||
import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; | ||
|
||
@Component({ | ||
selector: 'app-suggest-agenda', | ||
|
@@ -18,35 +20,34 @@ export class SuggestAgendaComponent implements OnInit{ | |
|
||
ngOnInit(): void { | ||
this.suggestAgendaForm = this.fb.group({ | ||
tema: ['', [Validators.required]], | ||
tema: [''], | ||
descricao: ['', [Validators.required]], | ||
quando: ['', [Validators.required]], | ||
local: ['', [Validators.required]], | ||
quando: [''], | ||
local: [''], | ||
responsavel: ['', [Validators.required]], | ||
telefoneResponsavel: ['', [Validators.required]], | ||
emailContato: ['', [Validators.required]], | ||
emailContato: [''], | ||
}, | ||
); | ||
} | ||
|
||
sendSuggestAgenda(): void{ | ||
console.log('this.suggestAgendaForm', this.suggestAgendaForm.tema); | ||
if (this.suggestAgendaForm.valid) { | ||
const email = new EmailData(); | ||
email.tema = this.suggestAgendaForm.tema; | ||
email.descricao = this.suggestAgendaForm.descricao; | ||
email.local = this.suggestAgendaForm.local; | ||
email.quando = this.suggestAgendaForm.quando; | ||
email.responsavel = this.suggestAgendaForm.responsavel; | ||
email.telefone_responsavel = this.suggestAgendaForm.telefoneResponsavel; | ||
email.email_contato = this.suggestAgendaForm.emailContato; | ||
const emailData = new EmailData(); | ||
emailData.tema = this.suggestAgendaForm.value.tema; | ||
emailData.descricao = this.suggestAgendaForm.value.descricao; | ||
emailData.local = this.suggestAgendaForm.value.local; | ||
emailData.quando = this.suggestAgendaForm.value.quando; | ||
emailData.responsavel = this.suggestAgendaForm.value.responsavel; | ||
emailData.telefone_responsavel = this.suggestAgendaForm.value.telefoneResponsavel; | ||
emailData.email_contato = this.suggestAgendaForm.value.emailContato; | ||
const emailUnB = '[email protected]'; | ||
emailData.email = emailUnB; | ||
emailData.recipients = [emailUnB]; | ||
this.emailService.sendEmail(emailData).subscribe((res: HttpResponse<string>) => { | ||
console.log('email enviado com sucesso'); | ||
alert('Sugestão enviada com sucesso'); | ||
}, | ||
(error: HttpResponseError) => { | ||
console.log('error', error.message); | ||
(error: HttpErrorResponse) => { | ||
alert('error: ' + error.message); | ||
}); | ||
} else { | ||
alert('Preencha todos os campos corretamente!'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
import { IEmail } from 'src/shared/model/email.model'; | ||
import { IEmailData } from 'src/shared/model/email.model'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class EmailService { | ||
private apiUrl = 'http://localhost:8000/pauta/email'; // Ajuste conforme necessário | ||
private apiUrl = 'http://localhost:8080/api/pauta/email'; // Ajuste conforme necessário | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
sendEmail(email: IEmail): Observable<any> { | ||
sendEmail(email: IEmailData): Observable<any> { | ||
return this.http.post(this.apiUrl, email); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
|
||
export interface IEmail { | ||
export interface IEmailData { | ||
tema?: string; | ||
descricao?: string; | ||
quando?: string; | ||
local?: string; | ||
responsavel?: string; | ||
telefone_responsavel?: string; | ||
email_contato?: string; | ||
recipients?: string[]; | ||
} | ||
|
||
export class Email implements IEmail { | ||
export class EmailData implements IEmailData { | ||
constructor( | ||
public tema?: string, | ||
public descricao?: string, | ||
public quando?: string, | ||
public local?: string, | ||
public responsavel?: string, | ||
public telefone_responsavel?: string, | ||
public email_contato?: string | ||
public email_contato?: string, | ||
public recipients?: string[], | ||
) { } | ||
} |