send votestack and reload poll config

This commit is contained in:
Tykayn 2021-05-20 14:23:57 +02:00 committed by tykayn
parent c95f481af9
commit b23155172a
2 changed files with 6 additions and 21 deletions

View File

@ -117,7 +117,7 @@ export class ApiService {
* @param poll
* @param vote_stack
*/
public sendNewVoteStackOfPoll(poll: Poll, vote_stack: Stack): Observable<any> {
public sendNewVoteStackOfPoll(poll: Poll, vote_stack: Stack): Promise<void> {
// api_new_vote_stack POST ANY ANY /api/v1/poll/{id}/answer
console.log('vote_stack', vote_stack);
@ -133,14 +133,7 @@ export class ApiService {
headers,
};
return this.http.post(url, vote_stack, {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Accept,Accept-Language,Content-Language,Content-Type',
},
});
return this.axiosInstance.post(url, vote_stack);
}
//////////

View File

@ -88,19 +88,11 @@ export class ConsultationComponent implements OnInit, OnDestroy {
}
addVoteStack(): void {
this.api.sendNewVoteStackOfPoll(this.poll, this.storageService.vote_stack).subscribe((resp) => {
console.log('sendNewVoteStackOfPoll resp', resp);
this.toastService.display('envoi du vote ....');
this.api.sendNewVoteStackOfPoll(this.poll, this.storageService.vote_stack).then((resp) => {
console.log('resp', resp);
this.toastService.display('vote ajouté', 'success');
if (resp) {
const response: Promise<Poll | undefined> = this.api.getPollByCustomUrl(this.poll.custom_url);
response.then((res: Poll | undefined) => {
this.pollService._poll.next(res);
});
} else {
this.toastService.display('erreur à la réception du nouveau vote', 'error');
}
this.pollService.loadPollBycustom_url(this.poll.custom_url);
});
}