Skip to content

Commit

Permalink
Ajusta formatação e corrige requisição para endpoint do email
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldovictor committed Nov 3, 2023
1 parent a7ba678 commit afb3930
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
13 changes: 8 additions & 5 deletions src/app/pages/suggest-agenda/suggest-agenda.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
width: 330px;
border-radius: 9px;
height: 30px;

padding: 9px 0 10px 28px;
}

form ::placeholder {
font-size: 13px;
font-family: "unb-pro", sans-serif;
padding: 9px 0 10px 28px;

font-family: "unb-pro", sans-serif;
}

.descricao {
Expand All @@ -42,11 +40,11 @@ form ::placeholder {
width: 330px;
border-radius: 9px;
height: 100px;
padding: 9px 0 10px 28px;
}

.descricao::placeholder {
top: -35px;

}

button {
Expand All @@ -61,3 +59,8 @@ span {
font-family: "unb-pro", sans-serif;
font-size: 13px;
}

.input:focus {
outline: none !important;
border: 0.25px solid #00A550;
}
20 changes: 11 additions & 9 deletions src/app/pages/suggest-agenda/suggest-agenda.component.html
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>
35 changes: 18 additions & 17 deletions src/app/pages/suggest-agenda/suggest-agenda.component.ts
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',
Expand All @@ -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!');
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/email.service.ts
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);
}
}
8 changes: 5 additions & 3 deletions src/shared/model/email.model.ts
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[],
) { }
}

0 comments on commit afb3930

Please sign in to comment.