import React from 'react';
import Toggle from '/imports/ui/components/switch/component';
import { defineMessages, injectIntl } from 'react-intl';
import BaseMenu from '../base/component';
import Styled from './styles';
const CHAT_ENABLED = Meteor.settings.public.chat.enabled;
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)}
{CHAT_ENABLED ? (
{intl.formatMessage(intlMessages.messagesLabel)}
{displaySettingsStatus(settings.chatAudioAlerts)}
this.handleToggle('chatAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.chatPushAlerts)}
this.handleToggle('chatPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
) : null}
{intl.formatMessage(intlMessages.userJoinLabel)}
{displaySettingsStatus(settings.userJoinAudioAlerts)}
this.handleToggle('userJoinAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.userJoinPushAlerts)}
this.handleToggle('userJoinPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{intl.formatMessage(intlMessages.userLeaveLabel)}
{displaySettingsStatus(settings.userLeaveAudioAlerts)}
this.handleToggle('userLeaveAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.userLeavePushAlerts)}
this.handleToggle('userLeavePushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{isModerator && showGuestNotification ? (
{intl.formatMessage(intlMessages.guestWaitingLabel)}
{displaySettingsStatus(settings.guestWaitingAudioAlerts)}
this.handleToggle('guestWaitingAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.guestWaitingPushAlerts)}
this.handleToggle('guestWaitingPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
) : null}
{isModerator ? (
{intl.formatMessage(intlMessages.raiseHandLabel)}
{displaySettingsStatus(settings.raiseHandAudioAlerts)}
this.handleToggle('raiseHandAudioAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
{displaySettingsStatus(settings.raiseHandPushAlerts)}
this.handleToggle('raiseHandPushAlerts')}
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
showToggleLabel={showToggleLabel}
/>
) : null}
);
}
}
export default injectIntl(NotificationMenu);