forked from bigbluebutton/bbb-playback
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
86 lines (76 loc) · 1.88 KB
/
options.js
File metadata and controls
86 lines (76 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React from 'react';
import PropTypes from 'prop-types';
import {
defineMessages,
useIntl,
} from 'react-intl';
import { getPollLabel } from 'utils/data';
import { isEmpty } from 'utils/data/validators';
import './index.scss';
const intlMessages = defineMessages({
options: {
id: 'player.chat.message.poll.options',
description: 'Label for the poll message answer options',
},
yes: {
id: 'player.chat.message.poll.option.yes',
description: 'Label for poll option yes',
},
no: {
id: 'player.chat.message.poll.option.no',
description: 'Label for poll option no',
},
abstention: {
id: 'player.chat.message.poll.option.abstention',
description: 'Label for poll option abstention',
},
true: {
id: 'player.chat.message.poll.option.true',
description: 'Label for poll option true',
},
false: {
id: 'player.chat.message.poll.option.false',
description: 'Label for poll option false',
},
});
const propTypes = {
answers: PropTypes.array,
type: PropTypes.string,
showCorrectAnswer: PropTypes.bool,
};
const defaultProps = {
answers: [],
type: '',
showCorrectAnswer: false,
};
const Options = ({
answers,
type,
showCorrectAnswer,
}) => {
const intl = useIntl();
if (isEmpty(answers)) return null;
return (
<div className="poll-options">
<div className="poll-label">
{intl.formatMessage(intlMessages.options)}
</div>
{answers.map((item) => {
const {
id,
key,
isCorrectAnswer
} = item;
const label = getPollLabel(key, type);
return (
<div>
{id + 1}: {label ? intl.formatMessage(intlMessages[label]) : key} {showCorrectAnswer && isCorrectAnswer && '✅'}
</div>
);
})}
</div>
);
};
Options.propTypes = propTypes;
Options.defaultProps = defaultProps;
export default Options;