diff --git a/packages/components/src/api/storyteller/twitch_event_rules/shared/TwitchEventCategory.ts b/packages/components/src/api/storyteller/twitch_event_rules/shared/TwitchEventCategory.ts index 36ef9efdb4..825413bdca 100644 --- a/packages/components/src/api/storyteller/twitch_event_rules/shared/TwitchEventCategory.ts +++ b/packages/components/src/api/storyteller/twitch_event_rules/shared/TwitchEventCategory.ts @@ -4,3 +4,9 @@ export enum TwitchEventCategory { ChannelPoints = "channel_points", ChatCommand = "chat_command", }; + +export const TWITCH_EVENT_CATEGORY_BY_STRING = new Map([ + ["bits", TwitchEventCategory.Bits], + ["channel_points", TwitchEventCategory.ChannelPoints], +]); + diff --git a/packages/storyteller/src/App.tsx b/packages/storyteller/src/App.tsx index 9829a734c2..1e101f1e7d 100644 --- a/packages/storyteller/src/App.tsx +++ b/packages/storyteller/src/App.tsx @@ -140,7 +140,7 @@ class App extends React.Component { querySessionAction={this.querySession} /> - + (TwitchEventCategory.Bits); const [ruleIsDisabled, setRuleIsDisabled] = useState(false); const [modifiedEventMatchPredicate, setModifiedEventMatchPredicate] = useState({}); const [modifiedEventResponse, setModifiedEventResponse] = useState({}); - const handleChangeTwitchEventCategory = (ev: React.FormEvent) : boolean => { - const value = (ev.target as HTMLSelectElement).value; - const newTwitchEventCategory = value as TwitchEventCategory; - setTwitchEventCategory(newTwitchEventCategory); - return true; + + let maybeTwitchEventCategory = TWITCH_EVENT_CATEGORY_BY_STRING.get(event_category); + + if (maybeTwitchEventCategory === undefined) { + history.push(indexLink); + return <>; } - + + const twitchEventCategory = maybeTwitchEventCategory; + const updateModifiedEventMatchPredicate = (predicate: EventMatchPredicate) => { // TODO setModifiedEventMatchPredicate(predicate); @@ -105,10 +105,17 @@ function TtsConfigsCreateRulePage(props: Props) { const emptyEventMatchPredicate = {}; const emptyEventResponse = {}; + const titlesByCategory = new Map([ + [TwitchEventCategory.Bits, 'Create New Bits / Cheers Rule'], + [TwitchEventCategory.ChannelPoints, 'Create New Channel Points Rule'], + ]); + + const pageTitle = titlesByCategory.get(twitchEventCategory); + return ( <>
-

Create New Rule

+

{pageTitle}


@@ -116,28 +123,6 @@ function TtsConfigsCreateRulePage(props: Props) {
-

1) Pick the type of event

- -
-
-
- -
-
-
- -
-
-