forked from tykayn/funky-framadate-front
send votestack and reload poll config
This commit is contained in:
parent
c95f481af9
commit
b23155172a
@ -117,7 +117,7 @@ export class ApiService {
|
|||||||
* @param poll
|
* @param poll
|
||||||
* @param vote_stack
|
* @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
|
// api_new_vote_stack POST ANY ANY /api/v1/poll/{id}/answer
|
||||||
|
|
||||||
console.log('vote_stack', vote_stack);
|
console.log('vote_stack', vote_stack);
|
||||||
@ -133,14 +133,7 @@ export class ApiService {
|
|||||||
headers,
|
headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.http.post(url, vote_stack, {
|
return this.axiosInstance.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',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
@ -88,19 +88,11 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addVoteStack(): void {
|
addVoteStack(): void {
|
||||||
this.api.sendNewVoteStackOfPoll(this.poll, this.storageService.vote_stack).subscribe((resp) => {
|
this.toastService.display('envoi du vote ....');
|
||||||
console.log('sendNewVoteStackOfPoll resp', resp);
|
this.api.sendNewVoteStackOfPoll(this.poll, this.storageService.vote_stack).then((resp) => {
|
||||||
|
console.log('resp', resp);
|
||||||
|
|
||||||
this.toastService.display('vote ajouté', 'success');
|
this.pollService.loadPollBycustom_url(this.poll.custom_url);
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user