]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/twitch-bot/ChatSettingsForm.js
adlib chat
[alttp.git] / resources / js / components / twitch-bot / ChatSettingsForm.js
index 9f6a1836afcc67a6e355276170ac05764331cdc6..24b2a0aca5146f39c4f98a8c256dc36a64925f60 100644 (file)
@@ -160,6 +160,19 @@ const ChatSettingsForm = ({
                                        </Form.Control.Feedback>
                                : null}
                        </Form.Group>
+                       <Form.Group as={Col} md={6} controlId="chatSettings.adlib">
+                               <Form.Label>{t('twitchBot.chatAdlibChance')}</Form.Label>
+                               <Form.Control
+                                       isInvalid={!!(touched.adlib && errors.adlib)}
+                                       name="adlib"
+                                       min="0"
+                                       max="100"
+                                       onBlur={handleBlur}
+                                       onChange={handleChange}
+                                       type="number"
+                                       value={values.adlib || 1}
+                               />
+                       </Form.Group>
                </Row>
                <div className="button-bar mt-3">
                        <Button disabled={!dirty || isSubmitting} type="submit" variant="primary">
@@ -172,6 +185,7 @@ const ChatSettingsForm = ({
 ChatSettingsForm.propTypes = {
        dirty: PropTypes.bool,
        errors: PropTypes.shape({
+               adlib: PropTypes.string,
                language: PropTypes.string,
                min_age: PropTypes.string,
                respond: PropTypes.string,
@@ -186,6 +200,7 @@ ChatSettingsForm.propTypes = {
        handleSubmit: PropTypes.func,
        isSubmitting: PropTypes.bool,
        touched: PropTypes.shape({
+               adlib: PropTypes.bool,
                language: PropTypes.bool,
                min_age: PropTypes.bool,
                respond: PropTypes.bool,
@@ -196,6 +211,7 @@ ChatSettingsForm.propTypes = {
                wait_time_max: PropTypes.bool,
        }),
        values: PropTypes.shape({
+               adlib: PropTypes.number,
                language: PropTypes.string,
                min_age: PropTypes.number,
                respond: PropTypes.string,
@@ -219,6 +235,7 @@ export default withFormik({
                });
        },
        mapPropsToValues: ({ channel }) => ({
+               adlib: channel.chat_settings.adlib || 50,
                language: channel.chat_settings.language || channel.languages[0] || 'de',
                min_age: channel.chat_settings.min_age || 1,
                respond: channel.chat_settings.respond || 'yes',
@@ -231,6 +248,7 @@ export default withFormik({
                        ? formatTime({ time: channel.chat_settings.wait_time_max }) : '15:00',
        }),
        validationSchema: yup.object().shape({
+               adlib: yup.number().min(0).max(100),
                language: yup.string(),
                min_age: yup.number().min(1),
                respond: yup.string(),