Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

07 suggest agenda #23

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/app/pages/suggest-agenda/suggest-agenda.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,3 @@ span {
outline: none !important;
border: 0.25px solid #00A550;
}

.required-field {
outline: none !important;
border: 2px solid red;
}
16 changes: 9 additions & 7 deletions src/app/pages/suggest-agenda/suggest-agenda.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<div class="mb-4">
<h1>Sugestão de Pautas</h1>
<form [formGroup]="suggestAgendaForm" (submit)="sendSuggestAgenda()" class="flex flex-col gap-y-3">
<input pInputText type="text" class="input first" name="tema" formControlName="tema" placeholder="Tema" >
<textarea class="input descricao" name="descicao" formControlName="descricao" placeholder="Descrição" required [ngClass]="{'required-field': !isDescricaoFilled}" (change)="onRequiredFieldsChange()"></textarea>
<input pInputText type="text" class="input first" name="quando" formControlName="quando" placeholder="Quando (data e hora)" >
<input pInputText type="text" class="input first" name="local" formControlName="local" placeholder="Local" >
<input pInputText type="text" class="input first" name="responsavel" formControlName="responsavel" placeholder="Responsável" required [ngClass]="{'required-field': !isResponsavelFilled}" (change)="onRequiredFieldsChange()">
<input pInputText type="text" class="input first" name="telefone-responsavel" formControlName="telefoneResponsavel" placeholder="Telefone do Responsável" required [ngClass]="{'required-field': !isTelefoneFilled}" (change)="onRequiredFieldsChange()">
<input pInputText type="text" class="input first" name="email-contato" formControlName="emailContato" placeholder="E-mail para contato" >
<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>
<p style="color:#969696"><small>*Campo obrigatório</small></p>

<button type="submit">
<span *ngIf="isSendingEmail">Enviando...</span>
<span *ngIf="!isSendingEmail">Enviar</span>
Expand Down
12 changes: 0 additions & 12 deletions src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { of, throwError } from 'rxjs';
import { EmailService } from 'src/app/services/email.service';
import { SuggestAgendaComponent } from './suggest-agenda.component';
Expand Down Expand Up @@ -72,17 +71,6 @@ describe('SuggestAgendaComponent', () => {
expect(component.sendSuggestAgenda).toHaveBeenCalled();
});

it('should call onRequiredFieldsChange when responsavel input value changes', () => {
fixture.detectChanges();
spyOn(component, 'onRequiredFieldsChange');

const input = fixture.debugElement.query(By.css('input[name="responsavel"]')).nativeElement;
input.value = 'novo valor';
input.dispatchEvent(new Event('change'));

expect(component.onRequiredFieldsChange).toHaveBeenCalled();
});

it('should call sendEmail', () => {
fixture.detectChanges();
const mySpy = spyOn(emailService, 'sendEmail').and.callThrough();
Expand Down
9 changes: 0 additions & 9 deletions src/app/pages/suggest-agenda/suggest-agenda.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import { AlertService } from 'src/app/services/alert.service';
export class SuggestAgendaComponent implements OnInit {

suggestAgendaForm!: FormGroup;
isDescricaoFilled = false;
isResponsavelFilled = false;
isTelefoneFilled = false;
isSendingEmail = false;

constructor(
Expand Down Expand Up @@ -64,10 +61,4 @@ export class SuggestAgendaComponent implements OnInit {
}
}

onRequiredFieldsChange(): void {
this.isDescricaoFilled = !!this.suggestAgendaForm.value.descricao;
this.isResponsavelFilled = !!this.suggestAgendaForm.value.responsavel;
this.isTelefoneFilled = !!this.suggestAgendaForm.value.telefoneResponsavel;
}

}
Loading