2021-09-14 15:31:30 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { makeStyles } from '@material-ui/styles';
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
2021-11-23 13:14:59 +00:00
|
|
|
import { createBreakoutRoomsEvent, sendAnalytics } from '../../../analytics';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { QuickActionButton } from '../../../base/components';
|
|
|
|
import { moveToRoom } from '../../actions';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The room to join.
|
|
|
|
*/
|
|
|
|
room: Object
|
|
|
|
}
|
|
|
|
|
|
|
|
const useStyles = makeStyles(theme => {
|
|
|
|
return {
|
|
|
|
button: {
|
|
|
|
marginRight: `${theme.spacing(2)}px`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const JoinActionButton = ({ room }: Props) => {
|
|
|
|
const styles = useStyles();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
const onJoinRoom = useCallback(e => {
|
|
|
|
e.stopPropagation();
|
2021-11-23 13:14:59 +00:00
|
|
|
sendAnalytics(createBreakoutRoomsEvent('join'));
|
2021-09-14 15:31:30 +00:00
|
|
|
dispatch(moveToRoom(room.jid));
|
|
|
|
}, [ dispatch, room ]);
|
|
|
|
|
|
|
|
return (<QuickActionButton
|
|
|
|
accessibilityLabel = { t('breakoutRooms.actions.join') }
|
|
|
|
className = { styles.button }
|
|
|
|
onClick = { onJoinRoom }
|
|
|
|
testId = { `join-room-${room.id}` }>
|
|
|
|
{t('breakoutRooms.actions.join')}
|
|
|
|
</QuickActionButton>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default JoinActionButton;
|