type switch bug fix

This commit is contained in:
Brandon Thomas committed 2022-02-25 04:14:38 -05:00
1 parent ace042e9e6
commit c503e158b4
2 files changed
+12 -37

No files matched your search

@@ -39,7 +39,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
// New, and remove everything else:
const [cheerState, setCheerState] = useState<CheerState>({});
// 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
<h2 className="title is-4">1) Pick what to match on</h2>
<div className="field">
{/*<label className="label">Rule Type</label>*/}
<div className="control">
<div className="select is-medium is-fullwidth">
{ruleTypeSelect}
@@ -376,7 +358,6 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
<h2 className="title is-4">2) Configure the matching</h2>
{matchingRulesForm}
</>
)
}
@@ -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);