forked from tykayn/funky-framadate-front
38 lines
1010 B
TypeScript
38 lines
1010 B
TypeScript
import {Injectable} from '@angular/core';
|
|
import {PollConfig} from './config/PollConfig';
|
|
import {HttpClient} from "@angular/common/http";
|
|
import {environment} from "../environments/environment";
|
|
|
|
|
|
/**
|
|
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
|
|
*/
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ConfigService extends PollConfig {
|
|
myEmail: string;
|
|
myPolls: any;// list of retrieved polls from the backend api
|
|
|
|
|
|
constructor(public http: HttpClient) {
|
|
super();
|
|
}
|
|
|
|
set(key, val) {
|
|
this[key] = val;
|
|
}
|
|
|
|
createPoll() {
|
|
// todo
|
|
console.log('sends the form');
|
|
alert('envoi de formulaire pour création de sondage en XHR à faire');
|
|
const payload = this;
|
|
this.http.post(`${environment.baseApiHref}/poll`, payload)
|
|
.subscribe(res => {
|
|
console.log('res', res)
|
|
},
|
|
err => console.error('err', err))
|
|
}
|
|
}
|