import React from 'react';
import Toggle from '/imports/ui/components/common/switch/component';
import { defineMessages, injectIntl } from 'react-intl';
import BaseMenu from '../base/component';
import Styled from './styles';
import { isChatEnabled } from '/imports/ui/services/features';
const intlMessages = defineMessages({
notificationSectionTitle: {
id: 'app.submenu.notification.SectionTitle',
description: 'Notification section title',
},
notificationSectionDesc: {
id: 'app.submenu.notification.Desc',
description: 'provides extra info for notification section',
},
audioAlertLabel: {
id: 'app.submenu.notification.audioAlertLabel',
description: 'audio notification label',
},
pushAlertLabel: {
id: 'app.submenu.notification.pushAlertLabel',
description: 'push notifiation label',
},
messagesLabel: {
id: 'app.submenu.notification.messagesLabel',
description: 'label for chat messages',
},
userJoinLabel: {
id: 'app.submenu.notification.userJoinLabel',
description: 'label for chat messages',
},
userLeaveLabel: {
id: 'app.submenu.notification.userLeaveLabel',
description: 'label for user leave notifications',
},
guestWaitingLabel: {
id: 'app.submenu.notification.guestWaitingLabel',
description: 'label for guests waiting for approval',
},
raiseHandLabel: {
id: 'app.submenu.notification.raiseHandLabel',
description: 'label for raise hand emoji notifications',
},
});
class NotificationMenu extends BaseMenu {
constructor(props) {
super(props);
this.state = {
settingsName: 'notification',
settings: props.settings,
};
}
render() {
const {
intl,
isModerator,
showGuestNotification,
showToggleLabel,
displaySettingsStatus,
} = this.props;
const { settings } = this.state;
return (
{intl.formatMessage(intlMessages.notificationSectionTitle)}
{intl.formatMessage(intlMessages.notificationSectionDesc)}
{intl.formatMessage(intlMessages.audioAlertLabel)}
{intl.formatMessage(intlMessages.pushAlertLabel)}
{isChatEnabled() ? (
{intl.formatMessage(intlMessages.messagesLabel)}
{displaySettingsStatus(settings.chatAudioAlerts)}
this.handleToggle('chatAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)} - ${displaySettingsStatus(settings.chatAudioAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.chatPushAlerts)}
this.handleToggle('chatPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)} - ${displaySettingsStatus(settings.chatPushAlerts, true)}`}
showToggleLabel={showToggleLabel}
data-test="chatPopupAlertsBtn"
/>
) : null}
{intl.formatMessage(intlMessages.userJoinLabel)}
{displaySettingsStatus(settings.userJoinAudioAlerts)}
this.handleToggle('userJoinAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)} - ${displaySettingsStatus(settings.userJoinAudioAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.userJoinPushAlerts)}
this.handleToggle('userJoinPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)} - ${displaySettingsStatus(settings.userJoinPushAlerts, true)}`}
showToggleLabel={showToggleLabel}
data-test="userJoinPopupAlerts"
/>
{intl.formatMessage(intlMessages.userLeaveLabel)}
{displaySettingsStatus(settings.userLeaveAudioAlerts)}
this.handleToggle('userLeaveAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)} - ${displaySettingsStatus(settings.userLeaveAudioAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.userLeavePushAlerts)}
this.handleToggle('userLeavePushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)} - ${displaySettingsStatus(settings.userLeavePushAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{isModerator && showGuestNotification ? (
{intl.formatMessage(intlMessages.guestWaitingLabel)}
{displaySettingsStatus(settings.guestWaitingAudioAlerts)}
this.handleToggle('guestWaitingAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)} - ${displaySettingsStatus(settings.guestWaitingAudioAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.guestWaitingPushAlerts)}
this.handleToggle('guestWaitingPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)} - ${displaySettingsStatus(settings.guestWaitingPushAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
) : null}
{isModerator ? (
{intl.formatMessage(intlMessages.raiseHandLabel)}
{displaySettingsStatus(settings.raiseHandAudioAlerts)}
this.handleToggle('raiseHandAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)} - ${displaySettingsStatus(settings.raiseHandAudioAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.raiseHandPushAlerts)}
this.handleToggle('raiseHandPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)} - ${displaySettingsStatus(settings.raiseHandPushAlerts, true)}`}
showToggleLabel={showToggleLabel}
/>
) : null}
);
}
}
export default injectIntl(NotificationMenu);