Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/scouting/frontend/src/scouter/pages/ScoutMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -35,7 +34,10 @@ const TABS: Tab[] = [
name: "Pre",
Component: PreMatchTab,
},
{ name: "Auto", Component: AutoTab },
{
name: "Auto",
Component: (props) => <ShiftTab shiftType="auto" tabIndex={0} {...props} />,
},
{
name: "Climb",
Component: (props) => <ClimbTab isAuto={true} {...props} />,
Expand Down
73 changes: 0 additions & 73 deletions apps/scouting/frontend/src/scouter/pages/tabs/AutoTab.tsx

This file was deleted.

35 changes: 26 additions & 9 deletions apps/scouting/frontend/src/scouter/pages/tabs/ShiftTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -23,14 +28,22 @@ export const ShiftTab: FC<ShiftTabProps> = ({
const [mapPosition, setMapPosition] = useState<Point>();
const [mapZone, setMapZone] = useState<Alliance>(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 },
Expand All @@ -39,6 +52,7 @@ export const ShiftTab: FC<ShiftTabProps> = ({
});
};

const gamePhase = shiftType === "auto" ? "auto" : "tele";
const scoreMap = (
<div className="flex-1 min-w-0 h-full">
<ScoreMap
Expand Down Expand Up @@ -66,10 +80,13 @@ export const ShiftTab: FC<ShiftTabProps> = ({
setMovement={(value) => {
setForm((prevForm) => ({
...prevForm,
tele: { ...prevForm.tele, movement: value },
[gamePhase]: {
...prevForm[gamePhase],
movement: value,
},
}));
}}
currentMovement={currentForm.tele.movement}
currentMovement={currentForm[gamePhase].movement}
/>

<button
Expand Down