|
|
|
@ -307,6 +307,20 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* conversion to send to back |
|
|
|
|
* @param choiceList |
|
|
|
|
*/ |
|
|
|
|
convertChoicesAnsweredToSend(choiceList) { |
|
|
|
|
const converted = choiceList.map(elem => { |
|
|
|
|
return { |
|
|
|
|
choice_id: elem.id, |
|
|
|
|
value: elem.answer |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
console.log('converted', converted); |
|
|
|
|
return converted; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* POST |
|
|
|
@ -318,11 +332,11 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
voteStack = { |
|
|
|
|
pseudo: this.myName, |
|
|
|
|
email: this.myEmail, |
|
|
|
|
answers: this.answers |
|
|
|
|
votes: this.convertChoicesAnsweredToSend(this.currentPoll.choices), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.http.post( |
|
|
|
|
`${this.baseHref}/poll/${this.pollId}/vote`, |
|
|
|
|
`${this.baseHref}/poll/${this.currentPoll.id}/vote`, |
|
|
|
|
voteStack, |
|
|
|
|
this.makeHeaders()) |
|
|
|
|
.subscribe((res: any) => { |
|
|
|
|