46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Component, Inject } from '@angular/core';
|
|
import { environment } from '../../../../environments/environment';
|
|
import { StorageService } from '../../services/storage.service';
|
|
import { ApiService } from '../../services/api.service';
|
|
import { ToastService } from '../../services/toast.service';
|
|
import { DOCUMENT } from '@angular/common';
|
|
|
|
@Component({
|
|
selector: 'app-home',
|
|
templateUrl: './home.component.html',
|
|
styleUrls: ['./home.component.scss'],
|
|
})
|
|
export class HomeComponent {
|
|
public environment = environment;
|
|
public nonexistent_email = '';
|
|
constructor(
|
|
@Inject(DOCUMENT) private document: any,
|
|
public storageService: StorageService,
|
|
public toastService: ToastService,
|
|
private api: ApiService
|
|
) {}
|
|
|
|
searchMyPolls() {
|
|
const email = this.storageService.vote_stack.owner.email;
|
|
this.api.findMyPollsByEmail(email).then(
|
|
(resp) => {
|
|
console.log('resp', resp);
|
|
|
|
if (resp) {
|
|
if (resp.data && resp.data.mail_sent == '1') {
|
|
this.toastService.display("C'est bon, vérifiez votre boite mail");
|
|
}
|
|
}
|
|
},
|
|
(error) => {
|
|
if (error.response.status == '404') {
|
|
this.toastService.display('Aucun sondage géré par cet email : ' + email);
|
|
this.nonexistent_email = email;
|
|
this.document.querySelector('#search_email').select();
|
|
}
|
|
console.log('error', error);
|
|
}
|
|
);
|
|
}
|
|
}
|