Skip to content

Commit 4d5ef80

Browse files
Merge branch 'feat/2024updates'
2 parents 0229468 + 4e36e35 commit 4d5ef80

File tree

7 files changed

+269
-207
lines changed

7 files changed

+269
-207
lines changed
Lines changed: 105 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
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

src/components/Review.jsx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
import React from "react"
2-
3-
import Checkbox from "./inputs/Checkbox"
4-
import Freetext from "./inputs/Freetext"
5-
import Next from "./inputs/Next"
6-
import SetPanel from "./inputs/SetPanel"
7-
import Dropdown from "./inputs/Dropdown"
8-
9-
const Review = () => {
10-
return (
11-
<>
12-
<Checkbox label="Played defense" prop="defense"></Checkbox>
13-
<Checkbox
14-
label="Robot had problems / malfunction"
15-
prop="robotProblems"
16-
></Checkbox>
17-
<Checkbox
18-
label="Scouting data accidents / problems"
19-
prop="scoutProblems"
20-
></Checkbox>
21-
{/* <div className="TextLine Divider">Pickup</div> */}
22-
23-
<Freetext label="Comments?" prop="comments"></Freetext>
24-
<SetPanel label="Edit Data" panelName="EditScoutData" width = "wide"></SetPanel>
25-
<Next width = "wide"></Next>
26-
</>
27-
)
28-
}
29-
30-
export default Review
1+
import React from "react"
2+
3+
import Checkbox from "./inputs/Checkbox"
4+
import Freetext from "./inputs/Freetext"
5+
import Next from "./inputs/Next"
6+
import SetPanel from "./inputs/SetPanel"
7+
import Dropdown from "./inputs/Dropdown"
8+
9+
const Review = () => {
10+
return (
11+
<>
12+
<Checkbox label="Played defense" prop="defense"></Checkbox>
13+
<Checkbox
14+
label="Robot had problems / malfunction"
15+
prop="robotProblems"
16+
></Checkbox>
17+
<Checkbox
18+
label="Scouting data accidents / problems"
19+
prop="scoutProblems"
20+
></Checkbox>
21+
{/* <div className="TextLine Divider">Pickup</div> */}
22+
23+
<Freetext label="Comments?" prop="comments"></Freetext>
24+
{/* In 2024, we didn't want to edit data, untested anyways */}
25+
{/* <SetPanel label="Edit Data" panelName="EditScoutData" width = "wide"></SetPanel> */}
26+
<Next width = "wide"></Next>
27+
</>
28+
)
29+
}
30+
31+
export default Review

src/components/Scout.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Tabs from "./inputs/Tabs"
77
import Undo from "./inputs/Undo"
88
import Info from "./inputs/Info"
99
import Bool from "./inputs/Bool"
10+
import Toggle from "./inputs/Toggle"
1011
import Numbers from "./inputs/Numbers"
1112
import Dropdown from "./inputs/Dropdown"
1213

@@ -172,9 +173,9 @@ const Scout = () => {
172173
case "endgame":
173174
return (
174175
<>
175-
<Bool prop="scoreTrap" phase label="Score Trap" trueLabel = "Scored Trap" color="green" width="fiveTwelfths" height="twoHigh"></Bool>
176-
<Bool prop="harmonize" phase label="Harmonize" trueLabel = "Harmonized" color="green" width={"fiveTwelfths"} height="twoHigh"></Bool>
177-
<Bool prop="park" phase label="Park" trueLabel = "Parked" color="green" width={"fiveTwelfths"} height="twoHigh"></Bool>
176+
<Toggle prop="scoreTrap" phase label="Score Trap" trueLabel = "Scored Trap" color="green" width="fiveTwelfths" height="twoHigh"></Toggle>
177+
<Toggle prop="harmonize" phase label="Harmonize" trueLabel = "Harmonized" color="yellow" width={"fiveTwelfths"} height="twoHigh"></Toggle>
178+
<Toggle prop="park" phase label="Park" trueLabel = "Parked" color="purple" width={"fiveTwelfths"} height="twoHigh"></Toggle>
178179
<Numbers label="Climb Time of start (secs)" idealLength = {2} prop="climbTimeOfStart" width = "fiveTwelfths" twoLines={false} height = "twoHigh"></Numbers>
179180
<Undo width = "fiveTwelfths" height = "twoHigh"></Undo>
180181

src/components/inputs/FieldInput.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const FieldInput = ({prop, phase, renderChildren, popupInfo}) => {
106106
const height = imgHeight / 14;
107107
const width = height;
108108

109-
const displayStyle = displayPopup ? "none" : ""
109+
const displayStyle = displayPopup ? "none" : "flex"
110110

111111
for(const actionString of currentActions) {
112112
const action = JSON.parse(actionString)
@@ -122,11 +122,24 @@ const FieldInput = ({prop, phase, renderChildren, popupInfo}) => {
122122
display: displayStyle,
123123
backgroundColor: "hsl(354, 100%, 85%, 0.75)",
124124
textAlign: "center",
125+
// wordBreak: "break-all",
126+
fontSize: "0.72rem",
127+
justifyContent: "center",
128+
alignItems: "center",
125129
}
126130

131+
// Splits action at uppercase, so they're separate words
132+
const formatted = action.action.split(/(?=[A-Z])/);
133+
134+
// Capitalizes the first letter in the action (not uppercase, cause camelcase)
135+
formatted[0] = formatted[0].charAt(0).toUpperCase() + formatted[0].slice(1);
136+
137+
// Adds them together, with a space separator
138+
const combinedString = formatted.reduce((prev, current) => prev + " " + current)
139+
127140
dots.push(<div
128141
style = {styles}
129-
onClick = {e => handleClick(e)}>{action.action}</div>)
142+
onClick = {e => handleClick(e)}>{combinedString}</div>)
130143

131144
}
132145

src/components/inputs/Tabs.jsx

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
import React, { useContext } from "react"
2-
import { Context } from "../../state"
3-
4-
import "./inputs.scss"
5-
import "./Tabs.scss"
6-
7-
const Tabs = () => {
8-
const [state, dispatch] = useContext(Context)
9-
10-
// In general, should be auto, teleop, endgame, but in 2023, endgame wasn't necessary
11-
const TabArray = ["auto", "teleop", "endgame"].map((label) => (
12-
<button
13-
className="Tab"
14-
disabled={label === state.phase}
15-
onClick={() => {
16-
dispatch({ type: "set_phase", phase: label })
17-
}}
18-
key={label}
19-
>
20-
<span>{label}</span>
21-
22-
</button>
23-
))
24-
25-
return <div className="Tabs veryTall sixth evenFlex">{TabArray}</div>
26-
}
27-
28-
export default Tabs
1+
import React, { useContext } from "react"
2+
import { Context } from "../../state"
3+
4+
import "./inputs.scss"
5+
import "./Tabs.scss"
6+
7+
const Tabs = () => {
8+
const [state, dispatch] = useContext(Context)
9+
10+
const TabArray = ["auto", "teleop", "endgame"].map((label) => (
11+
<button
12+
className="Tab"
13+
disabled={label === state.phase}
14+
onClick={() => {
15+
dispatch({ type: "set_phase", phase: label })
16+
}}
17+
key={label}
18+
>
19+
<span>{label}</span>
20+
21+
</button>
22+
))
23+
24+
return <div className="Tabs veryTall sixth evenFlex">{TabArray}</div>
25+
}
26+
27+
export default Tabs

0 commit comments

Comments
 (0)