diff --git a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/EventMatchPredicateBuilderComponent.tsx b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/EventMatchPredicateBuilderComponent.tsx index d57c9007a5..5aaf3e663e 100644 --- a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/EventMatchPredicateBuilderComponent.tsx +++ b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/EventMatchPredicateBuilderComponent.tsx @@ -39,7 +39,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo // New, and remove everything else: const [cheerState, setCheerState] = useState({}); - // Used in: // BitsCheermoteNameExactMatch // BitsCheermotePrefixSpendThreshold @@ -122,29 +121,15 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo const value = (ev.target as HTMLSelectElement).value; const newRuleType = value as BitsRuleType; - let predicate : EventMatchPredicate = {}; + let predicate = cheerStateToPredicate(cheerState, newRuleType); + + console.log('\n\n======== handleChangedBitsRuleType() ======='); + console.log('cheerState', cheerState); + console.table(predicate) + console.log('\n\n'); - switch (newRuleType) { - case BitsRuleType.BitsCheermoteNameExactMatch: - predicate.bits_cheermote_name_exact_match = { - cheermote_name: cheerNameOrPrefix, - } - break; - case BitsRuleType.BitsCheermotePrefixSpendThreshold: - predicate.bits_cheermote_prefix_spend_threshold = { - cheermote_prefix: cheerNameOrPrefix, - minimum_bits_spent: bitsValue, - } - break; - case BitsRuleType.BitsSpendThreshold: - predicate.bits_spend_threshold = { - minimum_bits_spent: bitsValue, - } - break; - } - - props.updateModifiedEventMatchPredicate(predicate); setBitsRuleType(newRuleType); + props.updateModifiedEventMatchPredicate(predicate); return true; } @@ -266,10 +251,8 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo } } - let predicate = cheerStateToPredicate(newCheerState, bitsRuleType); - console.log('\n\n======== handleChangedMinimumBitsSpend() ======='); console.log('cheerState', newCheerState); console.table(predicate) @@ -362,7 +345,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo

1) Pick what to match on

- {/**/}
{ruleTypeSelect} @@ -376,7 +358,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo

2) Configure the matching

{matchingRulesForm} - ) } diff --git a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermotePrefixSpendThresholdForm.tsx b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermotePrefixSpendThresholdForm.tsx index 0940aec516..54d759b75e 100644 --- a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermotePrefixSpendThresholdForm.tsx +++ b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermotePrefixSpendThresholdForm.tsx @@ -29,24 +29,18 @@ function BitsCheermotePrefixSpendThresholdForm(props: BitsCheermotePrefixSpendTh let newBits = 1; let newCustomBits = 1; + if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { + newBits = props.cheerState.bits; + newCustomBits = props.cheerState.bits; + } + if (CheerStateIsOfficial(props.cheerState)) { if (!!props.cheerState.cheerPrefix) { newPrefix = CHEER_PREFIX_TO_STRING_MAP.get((props.cheerState.cheerPrefix)) || ''; newCustomPrefix = CHEER_PREFIX_TO_STRING_MAP.get((props.cheerState.cheerPrefix)) || ''; } - - if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { - newBits = props.cheerState.bits; - newCustomBits = props.cheerState.bits; - } - } else if (CheerStateIsCustom(props.cheerState)) { newCustomPrefix = props.cheerState.cheerFull || ''; - - if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { - newBits = props.cheerState.bits; - newCustomBits = props.cheerState.bits; - } } setCheerPrefix(newPrefix);