Skip to content

Commit

Permalink
refactor(connected-endpoints-overlay): Convert to TypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Sep 7, 2023
1 parent 7830b5d commit 1cd733e
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
/* eslint-disable react/prop-types */
import { connect } from 'react-redux'
import { useIntl } from 'react-intl'
import { IntlShape, useIntl } from 'react-intl'
import { UserLocationAndType } from '@opentripplanner/types'
import EndpointsOverlay from '@opentripplanner/endpoints-overlay'
import React, { useCallback } from 'react'
import React, { ComponentProps, useCallback } from 'react'

import { clearLocation } from '../../actions/form'
import { forgetPlace, rememberPlace } from '../../actions/user'
import { getActiveSearch, getShowUserSettings } from '../../util/state'
import { getUserLocations } from '../../util/user'
import { setLocation } from '../../actions/map'

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

const ConnectedEndpointsOverlay = ({
forgetPlace,
rememberPlace,
...otherProps
}) => {
}: Props): JSX.Element => {
const intl = useIntl()
const _forgetPlace = useCallback(
(place) => {
Expand All @@ -39,8 +44,9 @@ const ConnectedEndpointsOverlay = ({
}

// connect to the redux store
// TODO: Add TypeScript to this section.

const mapStateToProps = (state) => {
const mapStateToProps = (state: any) => {
const { viewedRoute } = state.otp.ui
// If the route viewer is active, do not show itinerary on map.
// mainPanelContent is null whenever the trip planner is active.
Expand All @@ -53,13 +59,13 @@ const mapStateToProps = (state) => {

// Use query from active search (if a search has been made) or default to
// current query is no search is available.
const activeSearch = getActiveSearch(state)
const activeSearch: any = getActiveSearch(state)
const query = activeSearch ? activeSearch.query : state.otp.currentQuery
const showUserSettings = getShowUserSettings(state)
const { from, to } = query
// Intermediate places doesn't trigger a re-plan, so for now default to
// current query. FIXME: Determine with TriMet if this is desired behavior.
const places = state.otp.currentQuery.intermediatePlaces.filter((p) => p)
const places = state.otp.currentQuery.intermediatePlaces.filter((p: any) => p)

return {
fromLocation: from,
Expand Down

0 comments on commit 1cd733e

Please sign in to comment.