début form
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
563d4b8c73
commit
64e213cf1c
@ -0,0 +1,32 @@
|
|||||||
|
<div [formGroup]="form">
|
||||||
|
|
||||||
|
<h1>Nous contacter</h1>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<label for="name">Nom</label>
|
||||||
|
<input type="text" id="name" name="name" placeholder="Votre nom" required formControlName="from_name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" id="email" name="email" placeholder="Votre email" required formControlName="from_email">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="subject">Sujet</label>
|
||||||
|
<input type="text" id="subject" name="subject" placeholder="Sujet" required formControlName="subject">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="message">Message</label>
|
||||||
|
<textarea id="message" name="message" placeholder="Votre message" required formControlName="message"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button type="submit" [disabled]="!form.valid">Envoyer</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { FormComponent } from './form.component';
|
||||||
|
|
||||||
|
describe('FormComponent', () => {
|
||||||
|
let component: FormComponent;
|
||||||
|
let fixture: ComponentFixture<FormComponent>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [FormComponent]
|
||||||
|
});
|
||||||
|
fixture = TestBed.createComponent(FormComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import emailjs from '@emailjs/browser';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
styleUrls: ['./form.component.css']
|
||||||
|
})
|
||||||
|
export class FormComponent {
|
||||||
|
form: FormGroup;
|
||||||
|
|
||||||
|
constructor(private fb: FormBuilder) {
|
||||||
|
this.form = this.fb.group({
|
||||||
|
from_name: [''],
|
||||||
|
to_name: ['Sankasten'],
|
||||||
|
from_email: [''],
|
||||||
|
subject: [''],
|
||||||
|
message: ['']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async send() {
|
||||||
|
emailjs.init('user_your_user_id');
|
||||||
|
try {
|
||||||
|
let response = await emailjs.send("your_service_id", "your_template_id", {
|
||||||
|
from_name: this.form.value.from_name,
|
||||||
|
to_name: this.form.value.to_name,
|
||||||
|
message: this.form.value.message,
|
||||||
|
from_email: this.form.value.from_email,
|
||||||
|
subject: this.form.value.subject,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Envoi du message:", response);
|
||||||
|
|
||||||
|
alert("Message envoyé avec succès !");
|
||||||
|
this.form.reset();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erreur lors de l'envoi du message:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue