From d77d68b648bf9768accf3d4f899c4da6b8cea112 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 23 Feb 2022 12:22:53 -0500 Subject: [PATCH] last night --- .../tts_configs/TtsConfigsEditRulePage.tsx | 16 +++++++++ .../ChannelPointsRewardNameExactMatchForm.tsx | 36 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 packages/storyteller/src/pages/tts_configs/components/ChannelPointsRewardNameExactMatchForm.tsx diff --git a/packages/storyteller/src/pages/tts_configs/TtsConfigsEditRulePage.tsx b/packages/storyteller/src/pages/tts_configs/TtsConfigsEditRulePage.tsx index 00f6b5eda9..8cbecaa2f9 100644 --- a/packages/storyteller/src/pages/tts_configs/TtsConfigsEditRulePage.tsx +++ b/packages/storyteller/src/pages/tts_configs/TtsConfigsEditRulePage.tsx @@ -14,6 +14,7 @@ import { BitsSpendThresholdForm } from './components/BitsSpendThresholdForm'; import { BitsCheermotePrefixSpendThresholdForm } from './components/BitsCheermotePrefixSpendThresholdForm'; import { TwitchEventCategory } from '@storyteller/components/src/api/storyteller/twitch_event_rules/shared/TwitchEventCategory'; import { BitsRuleType, ChannelPointsRuleType } from './components/RuleTypes'; +import { ChannelPointsRewardNameExactMatchForm } from './components/ChannelPointsRewardNameExactMatchForm'; interface Props { sessionWrapper: SessionWrapper, @@ -50,6 +51,10 @@ function TtsConfigsEditRulePage(props: Props) { // BitsCheermotePrefixSpendThreshold const [minimumBitsSpent, setMinimumBitsSpent] = useState(1); + // Used in: + // ChannelPointsRewardNameExactMatch + const [rewardName, setRewardName] = useState(''); + // ===== Field values (final) ===== const [eventMatchPredicate, setEventMatchPredicate] = useState(undefined); @@ -81,6 +86,9 @@ function TtsConfigsEditRulePage(props: Props) { } break; case TwitchEventCategory.ChannelPoints: // NB: Only one rule type + if (!!response.twitch_event_rule.event_match_predicate.channel_points_reward_name_exact_match) { + setRewardName(response.twitch_event_rule.event_match_predicate.channel_points_reward_name_exact_match.reward_name); + } break; case TwitchEventCategory.ChatCommand: // TODO: Not yet supported default: @@ -112,6 +120,10 @@ function TtsConfigsEditRulePage(props: Props) { setMinimumBitsSpent(minimumSpent); } + const updateRewardName = (name: string) => { + setRewardName(name); + } + const handleFormSubmit = async (ev: React.FormEvent) : Promise => { ev.preventDefault(); @@ -169,6 +181,10 @@ function TtsConfigsEditRulePage(props: Props) { } } else if (twitchEventCategory === TwitchEventCategory.ChannelPoints) { + ruleTypeForm = ; } return ( diff --git a/packages/storyteller/src/pages/tts_configs/components/ChannelPointsRewardNameExactMatchForm.tsx b/packages/storyteller/src/pages/tts_configs/components/ChannelPointsRewardNameExactMatchForm.tsx new file mode 100644 index 0000000000..58223aa5b9 --- /dev/null +++ b/packages/storyteller/src/pages/tts_configs/components/ChannelPointsRewardNameExactMatchForm.tsx @@ -0,0 +1,36 @@ +import React, { useState } from 'react'; + +interface ChannelPointsRewardNameExactMatchProps { + rewardName: string, + updateRewardName: (name: string) => void, +}; + +function ChannelPointsRewardNameExactMatchForm(props: ChannelPointsRewardNameExactMatchProps) { + const [rewardName, setRewardName] = useState(props.rewardName); + + const updateRewardName = (ev: React.FormEvent) : boolean => { + const value = (ev.target as HTMLInputElement).value; + setRewardName(value); + props.updateRewardName(value); + return true; + } + console.log(rewardName, props.rewardName) + + return ( + <> +
+ +
+ +
+
+ + ) +} + +export { ChannelPointsRewardNameExactMatchForm }