import { CheckIcon } from '@radix-ui/react-icons'; import React from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; import { useModule, useStatus } from '../../lib/react-utils'; import apiReducer, { modules } from '../../store/api/reducer'; import DefinitionTable from '../components/DefinitionTable'; import SaveButton from '../components/utils/SaveButton'; import { Checkbox, CheckboxIndicator, Field, FieldNote, FlexRow, InputBox, Label, PageContainer, PageHeader, PageTitle, SectionHeader, styled, TabButton, TabContainer, TabContent, TabList, TextBlock, } from '../theme'; const StepList = styled('ul', { lineHeight: '1.5', listStyleType: 'none', listStylePosition: 'outside', }); const Step = styled('li', { marginBottom: '0.5rem', paddingLeft: '1rem', '&::marker': { color: '$teal11', content: '▧', display: 'inline-block', marginLeft: '-0.5rem', }, }); function TwitchBotSettings() { const [botConfig, setBotConfig, loadStatus] = useModule( modules.twitchBotConfig, ); const [twitchConfig, setTwitchConfig] = useModule(modules.twitchConfig); const status = useStatus(loadStatus.save); const dispatch = useDispatch(); const { t } = useTranslation(); const active = twitchConfig?.enable_bot ?? false; return (
{ dispatch(setTwitchConfig(twitchConfig)); dispatch(setBotConfig(botConfig)); ev.preventDefault(); }} > {t('pages.twitch-settings.bot-settings-copy')} dispatch( apiReducer.actions.twitchConfigChanged({ ...twitchConfig, enable_bot: !!ev, }), ) } id="enable-bot" > {active && } dispatch( apiReducer.actions.twitchBotConfigChanged({ ...botConfig, channel: ev.target.value, }), ) } /> {t('pages.twitch-settings.bot-info-header')} dispatch( apiReducer.actions.twitchBotConfigChanged({ ...botConfig, username: ev.target.value, }), ) } /> dispatch( apiReducer.actions.twitchBotConfigChanged({ ...botConfig, oauth: ev.target.value, }), ) } /> {' '} https://twitchapps.com/tmi/ {t('pages.twitch-settings.bot-chat-header')} {t('pages.twitch-settings.bot-chat-history-desc')} dispatch( apiReducer.actions.twitchBotConfigChanged({ ...botConfig, chat_keys: !!ev, }), ) } id="bot-chat-keys" > {active && } dispatch( apiReducer.actions.twitchBotConfigChanged({ ...botConfig, chat_history: ev.target.value, }), ) } /> {t('pages.twitch-settings.bot-chat-history-suffix')} ); } function TwitchAPISettings() { const { t } = useTranslation(); const [httpConfig] = useModule(modules.httpConfig); const [twitchConfig, setTwitchConfig, loadStatus] = useModule( modules.twitchConfig, ); const status = useStatus(loadStatus.save); const dispatch = useDispatch(); return (
{ dispatch(setTwitchConfig(twitchConfig)); ev.preventDefault(); }} > {t('pages.twitch-settings.api-subheader')} {t('pages.twitch-settings.apiguide-1')} {' '} https://dev.twitch.tv/console/apps/create {t('pages.twitch-settings.apiguide-3')} 0 ? httpConfig.bind : `localhost${httpConfig?.bind ?? ':4337'}` }/oauth`, Category: 'Broadcasting Suite', }} /> {'str1 '} str2 dispatch( apiReducer.actions.twitchConfigChanged({ ...twitchConfig, api_client_id: ev.target.value, }), ) } /> dispatch( apiReducer.actions.twitchConfigChanged({ ...twitchConfig, api_client_secret: ev.target.value, }), ) } /> ); } export default function TwitchSettingsPage(): React.ReactElement { const { t } = useTranslation(); const [twitchConfig, setTwitchConfig] = useModule(modules.twitchConfig); const dispatch = useDispatch(); const active = twitchConfig?.enabled ?? false; return ( {t('pages.twitch-settings.title')} {t('pages.twitch-settings.subtitle')} dispatch( setTwitchConfig({ ...twitchConfig, enabled: !!ev, }), ) } id="enable" > {active && }
{t('pages.twitch-settings.api-configuration')} {t('pages.twitch-settings.bot-settings')}
); }