]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/twitch-bot/Controls.js
chat bot settings
[alttp.git] / resources / js / components / twitch-bot / Controls.js
index cc062e8aff53805bf4a78cfa6499c4ab81915cf0..bdc89380fe75c07a4a1ad22e8dd2587661d1ac1b 100644 (file)
@@ -4,6 +4,7 @@ import { Alert, Button, Col, Form, Row } from 'react-bootstrap';
 import { useTranslation } from 'react-i18next';
 import toastr from 'toastr';
 
+import ChatSettingsForm from './ChatSettingsForm';
 import ChannelSelect from '../common/ChannelSelect';
 import ToggleSwitch from '../common/ToggleSwitch';
 
@@ -45,6 +46,16 @@ const Controls = () => {
                }
        }, [channel, t]);
 
+       const saveChatSettings = React.useCallback(async (values) => {
+               try {
+                       const rsp = await axios.post(`/api/channels/${channel.id}/chat-settings`, values);
+                       setChannel(rsp.data);
+                       toastr.success(t('twitchBot.saveSuccess'));
+               } catch (e) {
+                       toastr.error(t('twitchBot.saveError'));
+               }
+       }, [channel, t]);
+
        return <>
                <Row className="mb-4">
                        <Form.Group as={Col} md={6}>
@@ -126,6 +137,10 @@ const Controls = () => {
                                                </Button>
                                        </div>
                                </Form.Group>
+                               <Col md={6}>
+                                       <h3>{t('twitchBot.chatSettings')}</h3>
+                                       <ChatSettingsForm channel={channel} onSubmit={saveChatSettings} />
+                               </Col>
                        </Row>
                :
                        <Alert variant="info">