From b4fe44760a6b2dcf911dcdabdf2b280b601270af Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 26 Feb 2022 03:33:19 -0500 Subject: [PATCH] notes, dynamic create title --- .../shared/TwitchEventCategory.ts | 6 ++ packages/storyteller/src/App.tsx | 2 +- .../tts_configs/TtsConfigsCreateRulePage.tsx | 59 +++++++------------ .../tts_configs/TtsConfigsEditRulePage.tsx | 2 +- .../EventMatchPredicateBuilderComponent.tsx | 3 + .../EventResponseComponent.tsx | 3 + 6 files changed, 36 insertions(+), 39 deletions(-) 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

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