Skip to content

Commit

Permalink
feat(connected-endpoints-overlay): Pass nearby to endpoint overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup committed Jan 6, 2025
1 parent e567ee7 commit ffec4f3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/components/map/connected-endpoints-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { connect } from 'react-redux'

Check failure on line 1 in lib/components/map/connected-endpoints-overlay.tsx

View workflow job for this annotation

GitHub Actions / test-build-release

Type '{ forgetPlace: (place: any) => void; rememberPlace: (placeTypeLocation: any) => Promise<void>; viewNearbyDestination: () => void; viewNearbyOrigin: () => void; clearLocation?: ((arg: ClearLocationArg) => void) | undefined; ... 6 more ...; toLocation?: Location | undefined; }' is not assignable to type 'IntrinsicAttributes & Props'.
import { IntlShape, useIntl } from 'react-intl'
import { UserLocationAndType } from '@opentripplanner/types'
import { Location, UserLocationAndType } from '@opentripplanner/types'
import EndpointsOverlay from '@opentripplanner/endpoints-overlay'
import React, { ComponentProps, useCallback } from 'react'

Expand All @@ -13,16 +13,19 @@ import {
} from '../../actions/user'
import { getActiveSearch, getShowUserSettings } from '../../util/state'
import { setLocation } from '../../actions/map'
import { setViewedStop } from '../../actions/ui'
import { toastOnPlaceSaved } from '../util/toasts'

type Props = ComponentProps<typeof EndpointsOverlay> & {
forgetPlace: (place: string, intl: IntlShape) => void
rememberPlace: (arg: UserLocationAndType, intl: IntlShape) => number
setViewedStop: (arg: Location) => void
}

const ConnectedEndpointsOverlay = ({
forgetPlace,
rememberPlace,
setViewedStop,
...otherProps
}: Props): JSX.Element => {
const intl = useIntl()
Expand All @@ -33,6 +36,8 @@ const ConnectedEndpointsOverlay = ({
[forgetPlace, intl]
)

const { fromLocation, toLocation } = otherProps

const _rememberPlace = useCallback(
async (placeTypeLocation) => {
const result = await rememberPlace(placeTypeLocation, intl)
Expand All @@ -47,6 +52,12 @@ const ConnectedEndpointsOverlay = ({
{...otherProps}
forgetPlace={_forgetPlace}
rememberPlace={_rememberPlace}
viewNearbyDestination={() => {
toLocation && setViewedStop(toLocation)
}}
viewNearbyOrigin={() => {
fromLocation && setViewedStop(fromLocation)
}}
/>
)
}
Expand Down Expand Up @@ -89,7 +100,8 @@ const mapDispatchToProps = {
clearLocation,
forgetPlace,
rememberPlace,
setLocation
setLocation,
setViewedStop
}

export default connect(
Expand Down

0 comments on commit ffec4f3

Please sign in to comment.