import React from 'react'; import axios from 'axios'; import MessageSetting from './MessageSetting.jsx'; import ModuleSettings from '../common/ModuleSettings.jsx'; import SettingCheckbox from '../common/SettingCheckbox.jsx'; import RichSettingSelect from '../common/RichSettingSelect.jsx'; import Variables from '../common/Variables.jsx'; import Loader from './../common/Loader.jsx'; export default class Announcements extends ModuleSettings { constructor(props) { super(props); this.state = { announcements: {}, channels: [], isLoading: true, }; } async componentWillMount() { try { let response = await axios.get(`/api/modules/${this.props.match.params.id}/announcements`); this.setState({ announcements: response.data.announcements, channels: response.data.channels, isLoading: false, }); } catch (e) { this.setState({ error: 'Failed to get data, try again later' }); } } handleChannel = (selectedOption) => { let announcements = this.state.announcements; announcements.channel = selectedOption.value || false; this.setState({ announcements }); } render() { if (this.state.isLoading) { return ; } const module = this.props.data.module; const announcements = this.state.announcements; let channels = this.state.channels.filter(c => c.type === 0); const channelOptions = channels.map(c => ({ value: c.id, label: c.name })); const defaultChannel = channels.find(c => c.id === announcements.channel); return (

Announcements {this.ModuleToggle}

Join Messages

Leave Messages

Ban Messages

Variables

You can use these variables in the message boxes below.

); } }