Skip to content

Commit

Permalink
Merge branch 'feat/2024updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonTheBusyBeaver117 committed Mar 1, 2024
2 parents 0229468 + 4e36e35 commit 4d5ef80
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 207 deletions.
210 changes: 105 additions & 105 deletions src/components/ConfigureQualitative.jsx
Original file line number Diff line number Diff line change
@@ -1,105 +1,105 @@
import React, { useContext } from "react"

import { useSettings, Context } from "../state"

import Dropdown from "./inputs/Dropdown"
import Next from "./inputs/Next"
import Numbers from "./inputs/Numbers"

import TripleTeamSelector from "./inputs/TripleTeamSelector"
import TextLine from "./inputs/TextLine"

const ConfigureQualitative = () => {

const [state] = useContext(Context)

const compareTwoTeamNums = (team1, team2) => {
// If one of the teams is left blank, then we shouldn't compare them and we just return true
// This is because sometimes, a team is missing from the match and don't show up
if (!team1 || !team2) return true

// Then actually checking to make sure the two numbers are not equivalent
if (team1 !== team2) return true

return false
}

let [team1Num, team2Num, team3Num] = [
state.team1.number,
state.team2.number,
state.team3.number,
]

// Checks to make sure that at least one of the teams has been actually been filled out
const teamFilledOut = team1Num && team2Num && team3Num

// Comparing all the teams
const teamNumsUnequal =
compareTwoTeamNums(team1Num, team2Num) &&
compareTwoTeamNums(team1Num, team3Num) &&
compareTwoTeamNums(team2Num, team3Num)

// Checks if we're ready to move on
const ready = state.matchNum && teamFilledOut && teamNumsUnequal && state.scoutName

// Creating the disabled message
const disabledMessage = (() => {
if (!teamFilledOut && !state.matchNum)
return "Provide all 3 team numbers and a match number"

if (!teamFilledOut) return "Provide all 3 team numbers"

if (!teamNumsUnequal) return "You cannot have multiple of the same team"

if (state.matchNum == undefined) return "Provide a match number"

if(!state.scoutName) return "Input your name"
return ""
})()

return (
<>
<TripleTeamSelector
label="Alliance Teams"
prop="number"
idealLength={4}
width="halfWide"
height = "twoHigh"
/>
<Numbers
label="Match #"
prop="matchNum"
idealLength={2}
width="halfWide"
></Numbers>
<Dropdown
width = "halfWide"
prop="matchType"
options={[
{ label: "Practice", value: "practice" },
{ label: "Qualification", value: "qm" },
{ label: "Semifinals", value: "sf" },
{ label: "Finals", value: "f" },
]}
></Dropdown>
{/* {!isIOS && <SetPanel width = "halfWide" label="Scanner" panelName="Scanner"></SetPanel>} */}

<TextLine
width="halfWide"
label="Scouter Name:"
explanation="Scouter Name: "
capitalize={false}
prop="scoutName"
/>

<Next
width="halfWide"
qualitative
isDisabled={false && !ready}
disabledText={disabledMessage}
></Next>
</>
)
}

export default ConfigureQualitative
import React, { useContext } from "react"

import { useSettings, Context } from "../state"

import Dropdown from "./inputs/Dropdown"
import Next from "./inputs/Next"
import Numbers from "./inputs/Numbers"

import TripleTeamSelector from "./inputs/TripleTeamSelector"
import TextLine from "./inputs/TextLine"

const ConfigureQualitative = () => {

const [state] = useContext(Context)

const compareTwoTeamNums = (team1, team2) => {
// If one of the teams is left blank, then we shouldn't compare them and we just return true
// This is because sometimes, a team is missing from the match and don't show up
if (!team1 || !team2) return true

// Then actually checking to make sure the two numbers are not equivalent
if (team1 !== team2) return true

return false
}

let [team1Num, team2Num, team3Num] = [
state.team1.number,
state.team2.number,
state.team3.number,
]

// Checks to make sure that at least one of the teams has been actually been filled out
const teamFilledOut = team1Num && team2Num && team3Num

// Comparing all the teams
const teamNumsUnequal =
compareTwoTeamNums(team1Num, team2Num) &&
compareTwoTeamNums(team1Num, team3Num) &&
compareTwoTeamNums(team2Num, team3Num)

// Checks if we're ready to move on
const ready = state.matchNum && teamFilledOut && teamNumsUnequal && state.scoutName

// Creating the disabled message
const disabledMessage = (() => {
if (!teamFilledOut && !state.matchNum)
return "Provide all 3 team numbers and a match number"

if (!teamFilledOut) return "Provide all 3 team numbers"

if (!teamNumsUnequal) return "You cannot have multiple of the same team"

if (state.matchNum == undefined) return "Provide a match number"

if(!state.scoutName) return "Input your name"
return ""
})()

return (
<>
<TripleTeamSelector
label="Alliance Teams"
prop="number"
idealLength={4}
width="halfWide"
height = "twoHigh"
/>
<Numbers
label="Match #"
prop="matchNum"
idealLength={2}
width="halfWide"
></Numbers>
<Dropdown
width = "halfWide"
prop="matchType"
options={[
{ label: "Practice", value: "practice" },
{ label: "Qualification", value: "qm" },
{ label: "Semifinals", value: "sf" },
{ label: "Finals", value: "f" },
]}
></Dropdown>
{/* {!isIOS && <SetPanel width = "halfWide" label="Scanner" panelName="Scanner"></SetPanel>} */}

<TextLine
width="halfWide"
label="Scouter Name:"
explanation="Scouter Name: "
capitalize={false}
prop="scoutName"
/>

<Next
width="halfWide"
qualitative
isDisabled={!ready}
disabledText={disabledMessage}
></Next>
</>
)
}

export default ConfigureQualitative
61 changes: 31 additions & 30 deletions src/components/Review.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import React from "react"

import Checkbox from "./inputs/Checkbox"
import Freetext from "./inputs/Freetext"
import Next from "./inputs/Next"
import SetPanel from "./inputs/SetPanel"
import Dropdown from "./inputs/Dropdown"

const Review = () => {
return (
<>
<Checkbox label="Played defense" prop="defense"></Checkbox>
<Checkbox
label="Robot had problems / malfunction"
prop="robotProblems"
></Checkbox>
<Checkbox
label="Scouting data accidents / problems"
prop="scoutProblems"
></Checkbox>
{/* <div className="TextLine Divider">Pickup</div> */}

<Freetext label="Comments?" prop="comments"></Freetext>
<SetPanel label="Edit Data" panelName="EditScoutData" width = "wide"></SetPanel>
<Next width = "wide"></Next>
</>
)
}

export default Review
import React from "react"

import Checkbox from "./inputs/Checkbox"
import Freetext from "./inputs/Freetext"
import Next from "./inputs/Next"
import SetPanel from "./inputs/SetPanel"
import Dropdown from "./inputs/Dropdown"

const Review = () => {
return (
<>
<Checkbox label="Played defense" prop="defense"></Checkbox>
<Checkbox
label="Robot had problems / malfunction"
prop="robotProblems"
></Checkbox>
<Checkbox
label="Scouting data accidents / problems"
prop="scoutProblems"
></Checkbox>
{/* <div className="TextLine Divider">Pickup</div> */}

<Freetext label="Comments?" prop="comments"></Freetext>
{/* In 2024, we didn't want to edit data, untested anyways */}
{/* <SetPanel label="Edit Data" panelName="EditScoutData" width = "wide"></SetPanel> */}
<Next width = "wide"></Next>
</>
)
}

export default Review
7 changes: 4 additions & 3 deletions src/components/Scout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Tabs from "./inputs/Tabs"
import Undo from "./inputs/Undo"
import Info from "./inputs/Info"
import Bool from "./inputs/Bool"
import Toggle from "./inputs/Toggle"
import Numbers from "./inputs/Numbers"
import Dropdown from "./inputs/Dropdown"

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

Expand Down
17 changes: 15 additions & 2 deletions src/components/inputs/FieldInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const FieldInput = ({prop, phase, renderChildren, popupInfo}) => {
const height = imgHeight / 14;
const width = height;

const displayStyle = displayPopup ? "none" : ""
const displayStyle = displayPopup ? "none" : "flex"

for(const actionString of currentActions) {
const action = JSON.parse(actionString)
Expand All @@ -122,11 +122,24 @@ const FieldInput = ({prop, phase, renderChildren, popupInfo}) => {
display: displayStyle,
backgroundColor: "hsl(354, 100%, 85%, 0.75)",
textAlign: "center",
// wordBreak: "break-all",
fontSize: "0.72rem",
justifyContent: "center",
alignItems: "center",
}

// Splits action at uppercase, so they're separate words
const formatted = action.action.split(/(?=[A-Z])/);

// Capitalizes the first letter in the action (not uppercase, cause camelcase)
formatted[0] = formatted[0].charAt(0).toUpperCase() + formatted[0].slice(1);

// Adds them together, with a space separator
const combinedString = formatted.reduce((prev, current) => prev + " " + current)

dots.push(<div
style = {styles}
onClick = {e => handleClick(e)}>{action.action}</div>)
onClick = {e => handleClick(e)}>{combinedString}</div>)

}

Expand Down
55 changes: 27 additions & 28 deletions src/components/inputs/Tabs.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import React, { useContext } from "react"
import { Context } from "../../state"

import "./inputs.scss"
import "./Tabs.scss"

const Tabs = () => {
const [state, dispatch] = useContext(Context)

// In general, should be auto, teleop, endgame, but in 2023, endgame wasn't necessary
const TabArray = ["auto", "teleop", "endgame"].map((label) => (
<button
className="Tab"
disabled={label === state.phase}
onClick={() => {
dispatch({ type: "set_phase", phase: label })
}}
key={label}
>
<span>{label}</span>

</button>
))

return <div className="Tabs veryTall sixth evenFlex">{TabArray}</div>
}

export default Tabs
import React, { useContext } from "react"
import { Context } from "../../state"

import "./inputs.scss"
import "./Tabs.scss"

const Tabs = () => {
const [state, dispatch] = useContext(Context)

const TabArray = ["auto", "teleop", "endgame"].map((label) => (
<button
className="Tab"
disabled={label === state.phase}
onClick={() => {
dispatch({ type: "set_phase", phase: label })
}}
key={label}
>
<span>{label}</span>

</button>
))

return <div className="Tabs veryTall sixth evenFlex">{TabArray}</div>
}

export default Tabs
Loading

0 comments on commit 4d5ef80

Please sign in to comment.