Skip to content

Commit

Permalink
refactor: also rename props on properties panel header component
Browse files Browse the repository at this point in the history
  • Loading branch information
lemald committed Oct 23, 2023
1 parent 8f60fb0 commit 768a696
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const GhostPropertiesPanel = ({
<Header
vehicle={selectedGhost}
tabMode={tabMode}
setTabMode={onChangeTabMode}
closePanel={onClosePanel}
onChangeTabMode={onChangeTabMode}
onClosePanel={onClosePanel}
/>

<TabPanels
Expand Down
10 changes: 5 additions & 5 deletions assets/src/components/propertiesPanel/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import ViewHeader from "../viewHeader"
interface Props {
vehicle: Vehicle | Ghost
tabMode: TabMode
setTabMode: Dispatch<SetStateAction<TabMode>>
closePanel: () => void
onChangeTabMode: Dispatch<SetStateAction<TabMode>>
onClosePanel: () => void
}

const ScheduleAdherenceStatusIcon = () => (
Expand Down Expand Up @@ -92,7 +92,7 @@ const ScheduleAdherence = ({
)
}

const Header = ({ vehicle, tabMode, setTabMode, closePanel }: Props) => {
const Header = ({ vehicle, tabMode, onChangeTabMode, onClosePanel }: Props) => {
const [{ routeTabs, userSettings, previousView }, dispatch] =
useContext(StateDispatchContext)
const epochNowInSeconds = useCurrentTimeSeconds()
Expand All @@ -109,7 +109,7 @@ const Header = ({ vehicle, tabMode, setTabMode, closePanel }: Props) => {
<div className="c-properties-panel__header-wrapper">
<ViewHeader
title="Vehicles"
closeView={closePanel}
closeView={onClosePanel}
backlinkToView={previousView}
followBacklink={() => dispatch(returnToPreviousView())}
/>
Expand Down Expand Up @@ -144,7 +144,7 @@ const Header = ({ vehicle, tabMode, setTabMode, closePanel }: Props) => {
</div>
</div>
{vehicleIsShuttle || (
<TabList activeTab={tabMode} setActiveTab={setTabMode} />
<TabList activeTab={tabMode} setActiveTab={onChangeTabMode} />
)}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ const VehiclePropertiesPanel = ({
<Header
vehicle={selectedVehicle}
tabMode={tabMode}
setTabMode={(newTabMode) => {
onChangeTabMode={(newTabMode) => {
if (newTabMode !== tabMode) {
fullStoryEvent("Switched tab in Vehicle Properties Panel", {
tab_str: newTabMode,
})
}
onChangeTabMode(newTabMode)
}}
closePanel={onClosePanel}
onClosePanel={onClosePanel}
/>

{isVehicleInScheduledService(selectedVehicle) ? (
Expand Down
48 changes: 24 additions & 24 deletions assets/tests/components/propertiesPanel/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ describe("Header", () => {
<Header
vehicle={vehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -110,8 +110,8 @@ describe("Header", () => {
<Header
vehicle={vehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
</RoutesProvider>
)
Expand All @@ -130,8 +130,8 @@ describe("Header", () => {
<Header
vehicle={earlyVehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -149,8 +149,8 @@ describe("Header", () => {
<Header
vehicle={earlyVehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -169,8 +169,8 @@ describe("Header", () => {
<Header
vehicle={offCourseVehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -189,8 +189,8 @@ describe("Header", () => {
<Header
vehicle={shuttleVehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand Down Expand Up @@ -223,8 +223,8 @@ describe("Header", () => {
<Header
vehicle={ghost}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -237,8 +237,8 @@ describe("Header", () => {
<Header
vehicle={{ ...vehicle, directionId: 0, routeStatus: "laying_over" }}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)
expect(result.getByTestId("vehicle-triangle")).toHaveAttribute(
Expand All @@ -252,8 +252,8 @@ describe("Header", () => {
<Header
vehicle={{ ...vehicle, directionId: 1, routeStatus: "laying_over" }}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)

Expand Down Expand Up @@ -282,8 +282,8 @@ describe("Header", () => {
<Header
vehicle={vehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
</StateDispatchProvider>
)
Expand All @@ -305,8 +305,8 @@ describe("Header", () => {
<Header
vehicle={shuttleVehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={jest.fn()}
onChangeTabMode={setTabMode}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -324,8 +324,8 @@ describe("Header", () => {
<Header
vehicle={vehicle}
tabMode={"status"}
setTabMode={setTabMode}
closePanel={mockClosePanel}
onChangeTabMode={setTabMode}
onClosePanel={mockClosePanel}
/>
)

Expand Down

0 comments on commit 768a696

Please sign in to comment.