-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(skate/detours/turn-by-turn): add turn-by-turn directions to deto…
…urs page (#2367) * feat(ex/api/ors+ts/superstruct): add directions to API response * feat(ex/open_route_service_api): filter out errors and goals * fix:test(ex/controllers/detour_route_controller): add segments json element * feat:test(ex/controllers/detour_route_controller): add tests for return value shape * fix(ts/components/dummyDetourPage): remove `l-page` div * feat(ts/components/diversionPage): add directions to detour page * refactor:test(ex/controllers/detour_route_controller): replace `directions_json` with `Skate.Factory` --------- Co-authored-by: Josh Larson <[email protected]>
- Loading branch information
1 parent
305065d
commit 836a2f8
Showing
13 changed files
with
309 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
import React, { useEffect, useState } from "react" | ||
import { fetchShapeForRoute } from "../api" | ||
import { Shape } from "../schedule" | ||
import { fetchRoutePatterns } from "../api" | ||
import { RoutePattern } from "../schedule" | ||
import { DiversionPage } from "./detours/diversionPage" | ||
import { useRoute } from "../contexts/routesContext" | ||
|
||
export const DummyDetourPage = () => { | ||
const [routeShape, setRouteShape] = useState<Shape | null>(null) | ||
const [routePattern, setRoutePattern] = useState<RoutePattern | null>(null) | ||
|
||
const routeNumber = "66" | ||
|
||
useEffect(() => { | ||
fetchShapeForRoute("39").then((shapes) => { | ||
setRouteShape(shapes[0]) | ||
fetchRoutePatterns(routeNumber).then((routePatterns) => { | ||
setRoutePattern(routePatterns[0]) | ||
}) | ||
}, []) | ||
const route = useRoute(routePattern?.routeId) | ||
|
||
return ( | ||
<div className="l-page"> | ||
{routeShape && ( | ||
<> | ||
{routePattern && routePattern.shape && ( | ||
<DiversionPage | ||
shape={routeShape} | ||
routeName="39" | ||
routeDescription="Forest Hills" | ||
routeOrigin="from Back Bay" | ||
routeDirection="Outbound" | ||
shape={routePattern.shape} | ||
routeName={routePattern.routeId} | ||
routeDescription={routePattern.headsign || "?"} | ||
routeOrigin={routePattern.name} | ||
routeDirection={ | ||
route?.directionNames[routePattern.directionId] || "?" | ||
} | ||
/> | ||
)} | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Factory } from "fishery" | ||
import { DetourShape } from "../../src/detour" | ||
import { shapePointFactory } from "./shapePointFactory" | ||
|
||
export const directionsFactory = Factory.define<DetourShape["directions"][0]>( | ||
({ sequence }) => { | ||
return { | ||
instruction: `directionInstruction${sequence}`, | ||
} | ||
} | ||
) | ||
|
||
export const detourShapeFactory = Factory.define<DetourShape>(() => ({ | ||
coordinates: shapePointFactory.buildList(3), | ||
directions: directionsFactory.buildList(3), | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Factory } from "fishery" | ||
import { localGeoCoordinateFactory } from "./geoCoordinate" | ||
import { ShapePoint } from "../../src/schedule" | ||
|
||
/** | ||
* Wrapper around {@link localGeoCoordinateFactory} until {@link ShapePoint} is | ||
* updated to a global shared coordinate object | ||
*/ | ||
export const shapePointFactory = Factory.define<ShapePoint>(() => { | ||
const { latitude, longitude } = localGeoCoordinateFactory.build() | ||
return { lat: latitude, lon: longitude } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.