diff --git a/apps/scouting/frontend/src/scouter/pages/ScoutMatch.tsx b/apps/scouting/frontend/src/scouter/pages/ScoutMatch.tsx index 6c879c6..59253e3 100644 --- a/apps/scouting/frontend/src/scouter/pages/ScoutMatch.tsx +++ b/apps/scouting/frontend/src/scouter/pages/ScoutMatch.tsx @@ -17,7 +17,6 @@ import { ShiftTab } from "./tabs/ShiftTab"; import { useLocalStorage } from "@repo/local_storage_hook"; import { PostMatchTab } from "./tabs/PostMatchTab"; import { useNavigate } from "react-router-dom"; -import { AutoTab } from "./tabs/AutoTab"; import { ClimbTab } from "./tabs/ClimbTab"; import { PreMatchTab } from "../../PreMatchTab"; export interface TabProps { @@ -35,7 +34,10 @@ const TABS: Tab[] = [ name: "Pre", Component: PreMatchTab, }, - { name: "Auto", Component: AutoTab }, + { + name: "Auto", + Component: (props) => , + }, { name: "Climb", Component: (props) => , diff --git a/apps/scouting/frontend/src/scouter/pages/tabs/AutoTab.tsx b/apps/scouting/frontend/src/scouter/pages/tabs/AutoTab.tsx deleted file mode 100644 index 32e7679..0000000 --- a/apps/scouting/frontend/src/scouter/pages/tabs/AutoTab.tsx +++ /dev/null @@ -1,73 +0,0 @@ -// בס"ד -import { useState, type FC } from "react"; -import { ScoreMap } from "../../components/ScoreMap"; -import type { Alliance, Point } from "@repo/scouting_types"; -import Stopwatch from "../../components/stopwatch"; -import { MovementForm } from "../../components/MovementForm"; -import type { TabProps } from "../ScoutMatch"; -import { defaultPoint } from "../../components/ScoreMap"; - -export const AutoTab: FC = ({ - setForm, - alliance, - originTime, - currentForm, -}) => { - const [mapPosition, setMapPosition] = useState(); - const [mapZone, setMapZone] = useState(alliance); - - const scoreMap = ( -
- -
- ); - - return ( -
- {alliance === "red" && scoreMap} -
- { - setForm((prevForm) => { - const prevEvents = prevForm.auto.shootEvents; - prevEvents.push({ - interval: cycle, - startPosition: mapPosition ?? { ...defaultPoint }, - }); - return prevForm; - }); - }} - originTime={originTime} - disabled={mapPosition === undefined} - size="compact" - /> - { - setForm((prevForm) => ({ - ...prevForm, - auto: { - ...prevForm.auto, - movement: { ...prevForm.auto.movement, ...value }, - }, - })); - }} - currentMovement={currentForm.auto.movement} - /> - -
- {alliance === "blue" && scoreMap} -
- ); -}; diff --git a/apps/scouting/frontend/src/scouter/pages/tabs/ShiftTab.tsx b/apps/scouting/frontend/src/scouter/pages/tabs/ShiftTab.tsx index 88fa86d..f5a6a82 100644 --- a/apps/scouting/frontend/src/scouter/pages/tabs/ShiftTab.tsx +++ b/apps/scouting/frontend/src/scouter/pages/tabs/ShiftTab.tsx @@ -3,7 +3,12 @@ import { useState, type FC } from "react"; import type { TabProps } from "../ScoutMatch"; import { ScoreMap, defaultPoint } from "../../components/ScoreMap"; -import type { Alliance, Point, ShiftType } from "@repo/scouting_types"; +import type { + Alliance, + Point, + ScoutingForm, + ShiftType, +} from "@repo/scouting_types"; import { MovementForm } from "../../components/MovementForm"; import Stopwatch from "../../components/stopwatch"; @@ -23,14 +28,22 @@ export const ShiftTab: FC = ({ const [mapPosition, setMapPosition] = useState(); const [mapZone, setMapZone] = useState(alliance); + const getEvents = (form: ScoutingForm) => { + if (shiftType === "auto") { + return form.auto.shootEvents; + } + if (shiftType === "transition") { + return form.tele.transitionShift.shootEvents; + } + if (shiftType === "endgame") { + return form.tele.endgameShift.shootEvents; + } + return form.tele.shifts[tabIndex].shootEvents; + }; + const handleSetForm = (cycle: { start: number; end: number }) => { setForm((prevForm) => { - const prevEvents = - shiftType === "teleop" - ? prevForm.tele.shifts[tabIndex].shootEvents - : shiftType === "transition" - ? prevForm.tele.transitionShift.shootEvents - : prevForm.tele.endgameShift.shootEvents; + const prevEvents = getEvents(prevForm); prevEvents.push({ interval: cycle, startPosition: mapPosition ?? { ...defaultPoint }, @@ -39,6 +52,7 @@ export const ShiftTab: FC = ({ }); }; + const gamePhase = shiftType === "auto" ? "auto" : "tele"; const scoreMap = (
= ({ setMovement={(value) => { setForm((prevForm) => ({ ...prevForm, - tele: { ...prevForm.tele, movement: value }, + [gamePhase]: { + ...prevForm[gamePhase], + movement: value, + }, })); }} - currentMovement={currentForm.tele.movement} + currentMovement={currentForm[gamePhase].movement} />