mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
this form sucks
This commit is contained in:
1 parent
b7b22a276d
commit
22703ffa1f
2 files changed
+11
-3
No files matched your search
+4
-2
@@ -9,6 +9,9 @@ import { BitsSpendThresholdForm } from './subforms/BitsSpendThresholdForm';
|
||||
import { ChannelPointsRewardNameExactMatchForm } from './subforms/ChannelPointsRewardNameExactMatchForm';
|
||||
import { ChannelPointsRuleType } from './types/ChannelPointsRuleType';
|
||||
|
||||
// TODO: Don't duplicate
|
||||
const CHEER_REGEX = /^([A-Za-z]+)(\d+)?$/;
|
||||
|
||||
interface EventMatchPredicateBuilderComponentProps {
|
||||
// CANNOT BE CHANGED AFTER CREATION
|
||||
twitchEventCategory: TwitchEventCategory,
|
||||
@@ -207,14 +210,13 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
|
||||
switch (bitsRuleType) {
|
||||
case BitsRuleType.BitsCheermoteNameExactMatch:
|
||||
matchingRulesForm = <BitsCheermoteNameExactMatchForm
|
||||
//cheerName={currentNameOrPrefix}
|
||||
cheerName={cheerNameOrPrefix}
|
||||
updateCheerNameOrPrefix={handleChangedCheerNameOrPrefix}
|
||||
updateMinimumBitsSpent={handleChangedMinimumBitsSpent} // NB: Technically not a field, but we can parse it out!
|
||||
/>;
|
||||
break;
|
||||
case BitsRuleType.BitsCheermotePrefixSpendThreshold:
|
||||
matchingRulesForm = <BitsCheermotePrefixSpendThresholdForm
|
||||
//cheerPrefix={currentNameOrPrefix}
|
||||
cheerPrefix={cheerNameOrPrefix}
|
||||
updateCheerNameOrPrefix={handleChangedCheerNameOrPrefix}
|
||||
minimumBitsSpent={minimumBitsSpent}
|
||||
|
||||
+7
-1
@@ -9,6 +9,7 @@ const CHEER_REGEX = /^([A-Za-z]+)(\d+)?$/;
|
||||
interface BitsCheermoteNameExactMatchProps {
|
||||
cheerName: string,
|
||||
updateCheerNameOrPrefix: (cheerNameOrPrefix: string) => void,
|
||||
updateMinimumBitsSpent: (minimumSpent: number) => void, // NB: Technically not a field, but we can parse it out!
|
||||
};
|
||||
|
||||
function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps) {
|
||||
@@ -65,7 +66,11 @@ function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps
|
||||
setCheerPrefix(matches[1]); // First match group
|
||||
if (matches.length == 3 && matches[2] !== undefined) {
|
||||
// NB: Second match group can be 'undefined' if no number is present. (Zero-width matching?)
|
||||
setBitsValue(parseInt(matches[2])); // Second match group
|
||||
const maybeBits = parseInt(matches[2]);
|
||||
if (!isNaN(maybeBits)) {
|
||||
setBitsValue(maybeBits); // Second match group
|
||||
props.updateMinimumBitsSpent(maybeBits); // NB: Technically not in this form, but helps when switching
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +87,7 @@ function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps
|
||||
const cheerValue = `${prefix}${bits}`;
|
||||
setManualCheerValue(cheerValue);
|
||||
props.updateCheerNameOrPrefix(cheerValue);
|
||||
props.updateMinimumBitsSpent(bits); // NB: Technically not in this form, but helps when switching
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user