|
1 |
| -import React, { useContext } from "react" |
2 |
| - |
3 |
| -import { useSettings, Context } from "../state" |
4 |
| - |
5 |
| -import Dropdown from "./inputs/Dropdown" |
6 |
| -import Next from "./inputs/Next" |
7 |
| -import Numbers from "./inputs/Numbers" |
8 |
| - |
9 |
| -import TripleTeamSelector from "./inputs/TripleTeamSelector" |
10 |
| -import TextLine from "./inputs/TextLine" |
11 |
| - |
12 |
| -const ConfigureQualitative = () => { |
13 |
| - |
14 |
| - const [state] = useContext(Context) |
15 |
| - |
16 |
| - const compareTwoTeamNums = (team1, team2) => { |
17 |
| - // If one of the teams is left blank, then we shouldn't compare them and we just return true |
18 |
| - // This is because sometimes, a team is missing from the match and don't show up |
19 |
| - if (!team1 || !team2) return true |
20 |
| - |
21 |
| - // Then actually checking to make sure the two numbers are not equivalent |
22 |
| - if (team1 !== team2) return true |
23 |
| - |
24 |
| - return false |
25 |
| - } |
26 |
| - |
27 |
| - let [team1Num, team2Num, team3Num] = [ |
28 |
| - state.team1.number, |
29 |
| - state.team2.number, |
30 |
| - state.team3.number, |
31 |
| - ] |
32 |
| - |
33 |
| - // Checks to make sure that at least one of the teams has been actually been filled out |
34 |
| - const teamFilledOut = team1Num && team2Num && team3Num |
35 |
| - |
36 |
| - // Comparing all the teams |
37 |
| - const teamNumsUnequal = |
38 |
| - compareTwoTeamNums(team1Num, team2Num) && |
39 |
| - compareTwoTeamNums(team1Num, team3Num) && |
40 |
| - compareTwoTeamNums(team2Num, team3Num) |
41 |
| - |
42 |
| - // Checks if we're ready to move on |
43 |
| - const ready = state.matchNum && teamFilledOut && teamNumsUnequal && state.scoutName |
44 |
| - |
45 |
| - // Creating the disabled message |
46 |
| - const disabledMessage = (() => { |
47 |
| - if (!teamFilledOut && !state.matchNum) |
48 |
| - return "Provide all 3 team numbers and a match number" |
49 |
| - |
50 |
| - if (!teamFilledOut) return "Provide all 3 team numbers" |
51 |
| - |
52 |
| - if (!teamNumsUnequal) return "You cannot have multiple of the same team" |
53 |
| - |
54 |
| - if (state.matchNum == undefined) return "Provide a match number" |
55 |
| - |
56 |
| - if(!state.scoutName) return "Input your name" |
57 |
| - return "" |
58 |
| - })() |
59 |
| - |
60 |
| - return ( |
61 |
| - <> |
62 |
| - <TripleTeamSelector |
63 |
| - label="Alliance Teams" |
64 |
| - prop="number" |
65 |
| - idealLength={4} |
66 |
| - width="halfWide" |
67 |
| - height = "twoHigh" |
68 |
| - /> |
69 |
| - <Numbers |
70 |
| - label="Match #" |
71 |
| - prop="matchNum" |
72 |
| - idealLength={2} |
73 |
| - width="halfWide" |
74 |
| - ></Numbers> |
75 |
| - <Dropdown |
76 |
| - width = "halfWide" |
77 |
| - prop="matchType" |
78 |
| - options={[ |
79 |
| - { label: "Practice", value: "practice" }, |
80 |
| - { label: "Qualification", value: "qm" }, |
81 |
| - { label: "Semifinals", value: "sf" }, |
82 |
| - { label: "Finals", value: "f" }, |
83 |
| - ]} |
84 |
| - ></Dropdown> |
85 |
| - {/* {!isIOS && <SetPanel width = "halfWide" label="Scanner" panelName="Scanner"></SetPanel>} */} |
86 |
| - |
87 |
| - <TextLine |
88 |
| - width="halfWide" |
89 |
| - label="Scouter Name:" |
90 |
| - explanation="Scouter Name: " |
91 |
| - capitalize={false} |
92 |
| - prop="scoutName" |
93 |
| - /> |
94 |
| - |
95 |
| - <Next |
96 |
| - width="halfWide" |
97 |
| - qualitative |
98 |
| - isDisabled={false && !ready} |
99 |
| - disabledText={disabledMessage} |
100 |
| - ></Next> |
101 |
| - </> |
102 |
| - ) |
103 |
| -} |
104 |
| - |
105 |
| -export default ConfigureQualitative |
| 1 | +import React, { useContext } from "react" |
| 2 | + |
| 3 | +import { useSettings, Context } from "../state" |
| 4 | + |
| 5 | +import Dropdown from "./inputs/Dropdown" |
| 6 | +import Next from "./inputs/Next" |
| 7 | +import Numbers from "./inputs/Numbers" |
| 8 | + |
| 9 | +import TripleTeamSelector from "./inputs/TripleTeamSelector" |
| 10 | +import TextLine from "./inputs/TextLine" |
| 11 | + |
| 12 | +const ConfigureQualitative = () => { |
| 13 | + |
| 14 | + const [state] = useContext(Context) |
| 15 | + |
| 16 | + const compareTwoTeamNums = (team1, team2) => { |
| 17 | + // If one of the teams is left blank, then we shouldn't compare them and we just return true |
| 18 | + // This is because sometimes, a team is missing from the match and don't show up |
| 19 | + if (!team1 || !team2) return true |
| 20 | + |
| 21 | + // Then actually checking to make sure the two numbers are not equivalent |
| 22 | + if (team1 !== team2) return true |
| 23 | + |
| 24 | + return false |
| 25 | + } |
| 26 | + |
| 27 | + let [team1Num, team2Num, team3Num] = [ |
| 28 | + state.team1.number, |
| 29 | + state.team2.number, |
| 30 | + state.team3.number, |
| 31 | + ] |
| 32 | + |
| 33 | + // Checks to make sure that at least one of the teams has been actually been filled out |
| 34 | + const teamFilledOut = team1Num && team2Num && team3Num |
| 35 | + |
| 36 | + // Comparing all the teams |
| 37 | + const teamNumsUnequal = |
| 38 | + compareTwoTeamNums(team1Num, team2Num) && |
| 39 | + compareTwoTeamNums(team1Num, team3Num) && |
| 40 | + compareTwoTeamNums(team2Num, team3Num) |
| 41 | + |
| 42 | + // Checks if we're ready to move on |
| 43 | + const ready = state.matchNum && teamFilledOut && teamNumsUnequal && state.scoutName |
| 44 | + |
| 45 | + // Creating the disabled message |
| 46 | + const disabledMessage = (() => { |
| 47 | + if (!teamFilledOut && !state.matchNum) |
| 48 | + return "Provide all 3 team numbers and a match number" |
| 49 | + |
| 50 | + if (!teamFilledOut) return "Provide all 3 team numbers" |
| 51 | + |
| 52 | + if (!teamNumsUnequal) return "You cannot have multiple of the same team" |
| 53 | + |
| 54 | + if (state.matchNum == undefined) return "Provide a match number" |
| 55 | + |
| 56 | + if(!state.scoutName) return "Input your name" |
| 57 | + return "" |
| 58 | + })() |
| 59 | + |
| 60 | + return ( |
| 61 | + <> |
| 62 | + <TripleTeamSelector |
| 63 | + label="Alliance Teams" |
| 64 | + prop="number" |
| 65 | + idealLength={4} |
| 66 | + width="halfWide" |
| 67 | + height = "twoHigh" |
| 68 | + /> |
| 69 | + <Numbers |
| 70 | + label="Match #" |
| 71 | + prop="matchNum" |
| 72 | + idealLength={2} |
| 73 | + width="halfWide" |
| 74 | + ></Numbers> |
| 75 | + <Dropdown |
| 76 | + width = "halfWide" |
| 77 | + prop="matchType" |
| 78 | + options={[ |
| 79 | + { label: "Practice", value: "practice" }, |
| 80 | + { label: "Qualification", value: "qm" }, |
| 81 | + { label: "Semifinals", value: "sf" }, |
| 82 | + { label: "Finals", value: "f" }, |
| 83 | + ]} |
| 84 | + ></Dropdown> |
| 85 | + {/* {!isIOS && <SetPanel width = "halfWide" label="Scanner" panelName="Scanner"></SetPanel>} */} |
| 86 | + |
| 87 | + <TextLine |
| 88 | + width="halfWide" |
| 89 | + label="Scouter Name:" |
| 90 | + explanation="Scouter Name: " |
| 91 | + capitalize={false} |
| 92 | + prop="scoutName" |
| 93 | + /> |
| 94 | + |
| 95 | + <Next |
| 96 | + width="halfWide" |
| 97 | + qualitative |
| 98 | + isDisabled={!ready} |
| 99 | + disabledText={disabledMessage} |
| 100 | + ></Next> |
| 101 | + </> |
| 102 | + ) |
| 103 | +} |
| 104 | + |
| 105 | +export default ConfigureQualitative |
0 commit comments