import React, { Component } from 'react'; import Modal from '/imports/ui/components/modal/fullscreen/component'; import { defineMessages, injectIntl } from 'react-intl'; import _ from 'lodash'; import HoldButton from '/imports/ui/components/presentation/presentation-toolbar/zoom-tool/holdButton/component'; import { styles } from './styles'; import Icon from '../../icon/component'; const intlMessages = defineMessages({ breakoutRoomTitle: { id: 'app.createBreakoutRoom.title', description: 'modal title', }, breakoutRoomDesc: { id: 'app.createBreakoutRoom.modalDesc', description: 'modal description', }, confirmButton: { id: 'app.createBreakoutRoom.confirm', description: 'confirm button label', }, numberOfRooms: { id: 'app.createBreakoutRoom.numberOfRooms', description: 'number of rooms label', }, duration: { id: 'app.createBreakoutRoom.durationInMinutes', description: 'duration time label', }, randomlyAssign: { id: 'app.createBreakoutRoom.randomlyAssign', description: 'randomly assign label', }, roomName: { id: 'app.createBreakoutRoom.roomName', description: 'room intl to name the breakout meetings', }, }); const MIN_BREAKOUT_ROOMS = 2; const MAX_BREAKOUT_ROOMS = 8; class BreakoutRoom extends Component { constructor(props) { super(props); this.changeNumberOfRooms = this.changeNumberOfRooms.bind(this); this.changeDurationTime = this.changeDurationTime.bind(this); this.increaseDurationTime = this.increaseDurationTime.bind(this); this.decreaseDurationTime = this.decreaseDurationTime.bind(this); this.onCreateBreakouts = this.onCreateBreakouts.bind(this); this.setFreeJoin = this.setFreeJoin.bind(this); this.state = { numberOfRooms: MIN_BREAKOUT_ROOMS, durationTime: 1, freeJoin: false, }; } onCreateBreakouts() { const { createBreakoutRoom, meetingName, intl, } = this.props; const { numberOfRooms, durationTime } = this.state; const rooms = _.range(1, numberOfRooms + 1).map(value => ({ users: [], name: intl.formatMessage(intlMessages.roomName, { 0: meetingName, 1: value, }), freeJoin: this.state.freeJoin, sequence: value, })); createBreakoutRoom(rooms, durationTime, this.state.freeJoin); } setFreeJoin(e) { this.setState({ freeJoin: e.target.checked }); } increaseDurationTime() { this.setState({ durationTime: (1 * this.state.durationTime) + 1 }); } decreaseDurationTime() { const number = ((1 * this.state.durationTime) - 1); this.setState({ durationTime: number < 1 ? 1 : number }); } changeDurationTime(event) { this.setState({ durationTime: Number.parseInt(event.target.value, 10) || '' }); } changeNumberOfRooms(event) { this.setState({ numberOfRooms: Number.parseInt(event.target.value, 10) }); } render() { const { intl } = this.props; return (

{intl.formatMessage(intlMessages.breakoutRoomDesc)}

{intl.formatMessage(intlMessages.randomlyAssign)}

); } } export default injectIntl(BreakoutRoom);