little cleanup

This commit is contained in:
Brandon Thomas committed 2022-02-24 01:59:41 -05:00
1 parent 42f4f82ccd
commit b24dd25b57
3 files changed
+57 -16

No files matched your search

@@ -356,6 +356,9 @@ function TtsConfigsEditRulePage(props: Props) {
/>
<br />
<br />
<EventResponseComponent
allTtsModels={props.allTtsModels}
allTtsModelsByToken={props.allTtsModelsByToken}
@@ -8,6 +8,7 @@ import { BitsCheermoteNameExactMatchForm } from './subforms/BitsCheermoteNameExa
import { BitsCheermotePrefixSpendThresholdForm } from './subforms/BitsCheermotePrefixSpendThresholdForm';
import { BitsSpendThresholdForm } from './subforms/BitsSpendThresholdForm';
import { ChannelPointsRewardNameExactMatchForm } from './subforms/ChannelPointsRewardNameExactMatchForm';
import { ChannelPointsRuleType } from './types/ChannelPointsRuleType';
interface EventMatchPredicateBuilderComponentProps {
// CANNOT BE CHANGED AFTER CREATION
@@ -24,7 +25,7 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
// ========== Core UI flow ==========
const [bitsRuleType, setBitsRuleType] = useState<BitsRuleType>(BitsRuleType.BitsCheermoteNameExactMatch);
const [channelPointsRuleType, setChannelPointsRuleType] = useState<ChannelPointsRuleType>(ChannelPointsRuleType.ChannelPointsRewardNameExactMatch);
// ========== Cached Values for Editing ==========
@@ -46,7 +47,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
// TtsSingleVoice
const [ttsModelToken, setTtsModelToken] = useState('');
const handleChangedBitsRuleType = (ev: React.FormEvent<HTMLSelectElement>) : boolean => {
const value = (ev.target as HTMLSelectElement).value;
const ruleType = value as BitsRuleType;
@@ -80,6 +80,17 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
return true;
}
const handleChangedChannelPointsRuleType = (ev: React.FormEvent<HTMLSelectElement>) : boolean => {
const value = (ev.target as HTMLSelectElement).value;
const ruleType = value as ChannelPointsRuleType;
// TODO:
let predicate : EventMatchPredicate = {};
setChannelPointsRuleType(ruleType);
return true;
}
const updateCheerNameOrPrefix = (nameOrPrefix: string) => {
let predicate : EventMatchPredicate = {};
@@ -139,18 +150,37 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
}
let ruleTypeForm = <></>
let ruleTypeSelect = <></>
let matchingRulesForm = <></>
if (props.twitchEventCategory === TwitchEventCategory.Bits) {
ruleTypeSelect = (
<>
<select
value={bitsRuleType}
onChange={handleChangedBitsRuleType}>
<option
value={BitsRuleType.BitsSpendThreshold}
>Bits Spend Threshold</option>
<option
value={BitsRuleType.BitsCheermoteNameExactMatch}
>Cheermote Name (Exact Match)</option>
<option
value={BitsRuleType.BitsCheermotePrefixSpendThreshold}
>Cheermote Prefix and Bits Spend Threshold</option>
</select>
</>
);
switch (bitsRuleType) {
case BitsRuleType.BitsCheermoteNameExactMatch:
ruleTypeForm = <BitsCheermoteNameExactMatchForm
matchingRulesForm = <BitsCheermoteNameExactMatchForm
cheerName={cheerNameOrPrefix}
updateCheerNameOrPrefix={updateCheerNameOrPrefix}
/>;
break;
case BitsRuleType.BitsCheermotePrefixSpendThreshold:
ruleTypeForm = <BitsCheermotePrefixSpendThresholdForm
matchingRulesForm = <BitsCheermotePrefixSpendThresholdForm
cheerPrefix={cheerNameOrPrefix}
updateCheerNameOrPrefix={updateCheerNameOrPrefix}
minimumBitsSpent={minimumBitsSpent}
@@ -158,7 +188,7 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
/>
break;
case BitsRuleType.BitsSpendThreshold:
ruleTypeForm = <BitsSpendThresholdForm
matchingRulesForm = <BitsSpendThresholdForm
minimumBitsSpent={minimumBitsSpent}
updateMinimumBitsSpent={updateMinimumBitsSpent}
/>;
@@ -166,12 +196,26 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
}
} else if (props.twitchEventCategory === TwitchEventCategory.ChannelPoints) {
ruleTypeForm = <ChannelPointsRewardNameExactMatchForm
ruleTypeSelect = (
<>
<select
value={channelPointsRuleType}
onChange={handleChangedChannelPointsRuleType}>
<option
value={ChannelPointsRuleType.ChannelPointsRewardNameExactMatch}
>Channel Points Reward Name (exact match)</option>
</select>
</>
);
matchingRulesForm = <ChannelPointsRewardNameExactMatchForm
rewardName={rewardName}
updateRewardName={updateRewardName}
/>;
}
console.log(matchingRulesForm);
return (
<>
<h2 className="title is-4">1) Pick what to match on</h2>
@@ -180,13 +224,7 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
<label className="label">Rule Type</label>
<div className="control">
<div className="select is-medium is-fullwidth">
<select
value={bitsRuleType}
onChange={handleChangedBitsRuleType}>
<option value={BitsRuleType.BitsSpendThreshold}>Bits Spend Threshold</option>
<option value={BitsRuleType.BitsCheermoteNameExactMatch}>Cheermote Name (Exact Match)</option>
<option value={BitsRuleType.BitsCheermotePrefixSpendThreshold}>Cheermote Prefix and Bits Spend Threshold</option>
</select>
{ruleTypeSelect}
</div>
</div>
</div>
@@ -196,7 +234,7 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
<h2 className="title is-4">2) Configure the matching</h2>
{ruleTypeForm}
{matchingRulesForm}
</>
@@ -1,5 +1,5 @@
// For channel points
export enum ChannelPointsRuleType {
ChannelPointsRewardNameExactMatch,
ChannelPointsRewardNameExactMatch = 'channel_points_reward_name_exact_match',
}