Merge pull request #15687 from ramonlsouza/issue-15686
fix: multiple answer translation in live results
This commit is contained in:
commit
3cccbc4b97
@ -79,11 +79,16 @@ class LiveResult extends PureComponent {
|
|||||||
if (responses) {
|
if (responses) {
|
||||||
const response = responses.find(r => r.userId === user.userId);
|
const response = responses.find(r => r.userId === user.userId);
|
||||||
if (response) {
|
if (response) {
|
||||||
const answerKeys = [];
|
const formattedAnswers = [];
|
||||||
response.answerIds.forEach((answerId) => {
|
response.answerIds.forEach((answerId) => {
|
||||||
answerKeys.push(answers[answerId].key);
|
const formattedMessageIndex = answers[answerId].key.toLowerCase();
|
||||||
|
const formattedAnswer = defaultPoll && pollAnswerIds[formattedMessageIndex]
|
||||||
|
? intl.formatMessage(pollAnswerIds[formattedMessageIndex])
|
||||||
|
: answers[answerId].key;
|
||||||
|
|
||||||
|
formattedAnswers.push(formattedAnswer);
|
||||||
});
|
});
|
||||||
answer = answerKeys.join(', ');
|
answer = formattedAnswers.join(', ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,18 +99,13 @@ class LiveResult extends PureComponent {
|
|||||||
})
|
})
|
||||||
.sort(Service.sortUsers)
|
.sort(Service.sortUsers)
|
||||||
.reduce((acc, user) => {
|
.reduce((acc, user) => {
|
||||||
const formattedMessageIndex = user.answer.toLowerCase();
|
|
||||||
return ([
|
return ([
|
||||||
...acc,
|
...acc,
|
||||||
(
|
(
|
||||||
<tr key={_.uniqueId('stats-')}>
|
<tr key={_.uniqueId('stats-')}>
|
||||||
<Styled.ResultLeft>{user.name}</Styled.ResultLeft>
|
<Styled.ResultLeft>{user.name}</Styled.ResultLeft>
|
||||||
<Styled.ResultRight data-test="receivedAnswer">
|
<Styled.ResultRight data-test="receivedAnswer">
|
||||||
{
|
{user.answer}
|
||||||
defaultPoll && pollAnswerIds[formattedMessageIndex]
|
|
||||||
? intl.formatMessage(pollAnswerIds[formattedMessageIndex])
|
|
||||||
: user.answer
|
|
||||||
}
|
|
||||||
</Styled.ResultRight>
|
</Styled.ResultRight>
|
||||||
</tr>
|
</tr>
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user