From 0a993f856b93eefbb6f5ce8bbbc5f9030f8a0d34 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 23 Dec 2022 21:33:57 -0800 Subject: [PATCH] Fix AX validity checking for good hopefully --- components/AxSelect/index.tsx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/components/AxSelect/index.tsx b/components/AxSelect/index.tsx index c49472b1..28ee96f6 100644 --- a/components/AxSelect/index.tsx +++ b/components/AxSelect/index.tsx @@ -91,39 +91,54 @@ const AXSelect = (props: Props) => { props.currentSkills && props.currentSkills[0].modifier != null && props.currentSkills[0].modifier >= 0 - ) + ) { setPrimaryAxModifier(props.currentSkills[0].modifier) - else setPrimaryAxModifier(-1) + setPrimaryAxValue(props.currentSkills[0].strength) + } else setPrimaryAxModifier(-1) }, [props.currentSkills, setPrimaryAxModifier]) useEffect(() => { if (props.currentSkills && props.currentSkills[1].modifier) { setSecondaryAxModifier(props.currentSkills[1].modifier) + setSecondaryAxValue(props.currentSkills[1].strength) } else { setSecondaryAxModifier(-1) } }, [props.currentSkills, setSecondaryAxModifier]) useEffect(() => { + console.log( + primaryAxModifier, + primaryAxValue, + secondaryAxModifier, + secondaryAxValue + ) + let noErrors = false if (errors.axValue1 === '' && errors.axValue2 === '') { - if (primaryAxModifier === -1 && secondaryAxModifier === -1) { + if (primaryAxModifier === -1 && secondaryAxModifier === -1) noErrors = true - } else if ( + else if ( primaryAxModifier >= 0 && primaryAxValue > 0 && secondaryAxModifier === -1 - ) { + ) noErrors = true - } else if ( + else if ( primaryAxModifier >= 0 && primaryAxValue > 0 && secondaryAxModifier >= 0 && secondaryAxValue > 0 - ) { + ) noErrors = true - } + else + console.log( + primaryAxModifier >= 0, + primaryAxValue > 0, + secondaryAxModifier >= 0, + secondaryAxValue > 0 + ) } props.sendValidity(noErrors)