forked from bigbluebutton/bbb-playback
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
90 lines (81 loc) · 1.88 KB
/
index.js
File metadata and controls
90 lines (81 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
87
88
89
90
import React from 'react';
import PropTypes from 'prop-types';
import {
defineMessages,
useIntl,
} from 'react-intl';
import Options from './options';
import Question from './question';
import Result from './result';
import SystemMessage from 'components/chat/messages/system/message';
import { ID } from 'utils/constants';
import './index.scss';
const intlMessages = defineMessages({
name: {
id: 'player.chat.message.poll.name',
description: 'Label for the poll message name',
},
quiz: {
id: 'player.chat.message.poll.quiz',
description: 'Label for the quiz message name',
},
});
const propTypes = {
active: PropTypes.bool,
answers: PropTypes.array,
question: PropTypes.string,
responders: PropTypes.number,
timestamp: PropTypes.number,
type: PropTypes.string,
isQuiz: PropTypes.bool,
showCorrectAnswer: PropTypes.bool,
};
const defaultProps = {
active: false,
answers: [],
question: '',
responders: 0,
timestamp: 0,
type: '',
isQuiz: false,
showCorrectAnswer: false,
};
const Poll = ({
active,
answers,
question,
responders,
timestamp,
type,
isQuiz,
showCorrectAnswer,
}) => {
const intl = useIntl();
return (
<SystemMessage
active={active}
icon={ID.POLLS}
name={isQuiz ? intl.formatMessage(intlMessages.quiz) : intl.formatMessage(intlMessages.name)}
timestamp={timestamp}
>
<Question question={question} />
<Result
answers={answers}
responders={responders}
/>
<Options
answers={answers}
type={type}
showCorrectAnswer={showCorrectAnswer}
/>
</SystemMessage>
);
};
Poll.propTypes = propTypes;
Poll.defaultProps = defaultProps;
// Checks the message active state
const areEqual = (prevProps, nextProps) => {
if (prevProps.active !== nextProps.active) return false;
return true;
};
export default React.memo(Poll, areEqual);