Fix AX validity checking for good hopefully

This commit is contained in:
Justin Edmund 2022-12-23 21:33:57 -08:00
parent 3a81675737
commit 0a993f856b

View file

@ -91,39 +91,54 @@ const AXSelect = (props: Props) => {
props.currentSkills && props.currentSkills &&
props.currentSkills[0].modifier != null && props.currentSkills[0].modifier != null &&
props.currentSkills[0].modifier >= 0 props.currentSkills[0].modifier >= 0
) ) {
setPrimaryAxModifier(props.currentSkills[0].modifier) setPrimaryAxModifier(props.currentSkills[0].modifier)
else setPrimaryAxModifier(-1) setPrimaryAxValue(props.currentSkills[0].strength)
} else setPrimaryAxModifier(-1)
}, [props.currentSkills, setPrimaryAxModifier]) }, [props.currentSkills, setPrimaryAxModifier])
useEffect(() => { useEffect(() => {
if (props.currentSkills && props.currentSkills[1].modifier) { if (props.currentSkills && props.currentSkills[1].modifier) {
setSecondaryAxModifier(props.currentSkills[1].modifier) setSecondaryAxModifier(props.currentSkills[1].modifier)
setSecondaryAxValue(props.currentSkills[1].strength)
} else { } else {
setSecondaryAxModifier(-1) setSecondaryAxModifier(-1)
} }
}, [props.currentSkills, setSecondaryAxModifier]) }, [props.currentSkills, setSecondaryAxModifier])
useEffect(() => { useEffect(() => {
console.log(
primaryAxModifier,
primaryAxValue,
secondaryAxModifier,
secondaryAxValue
)
let noErrors = false let noErrors = false
if (errors.axValue1 === '' && errors.axValue2 === '') { if (errors.axValue1 === '' && errors.axValue2 === '') {
if (primaryAxModifier === -1 && secondaryAxModifier === -1) { if (primaryAxModifier === -1 && secondaryAxModifier === -1)
noErrors = true noErrors = true
} else if ( else if (
primaryAxModifier >= 0 && primaryAxModifier >= 0 &&
primaryAxValue > 0 && primaryAxValue > 0 &&
secondaryAxModifier === -1 secondaryAxModifier === -1
) { )
noErrors = true noErrors = true
} else if ( else if (
primaryAxModifier >= 0 && primaryAxModifier >= 0 &&
primaryAxValue > 0 && primaryAxValue > 0 &&
secondaryAxModifier >= 0 && secondaryAxModifier >= 0 &&
secondaryAxValue > 0 secondaryAxValue > 0
) { )
noErrors = true noErrors = true
} else
console.log(
primaryAxModifier >= 0,
primaryAxValue > 0,
secondaryAxModifier >= 0,
secondaryAxValue > 0
)
} }
props.sendValidity(noErrors) props.sendValidity(noErrors)