{
- const placeIndex = ownProps.match.params.id
+ const { params, path } = ownProps.match
+ const placeIndex = params.id
return {
- isCreating: placeIndex === 'new',
+ isCreating: path.startsWith(CREATE_ACCOUNT_PLACES_PATH),
+ isNewPlace: placeIndex === 'new',
loggedInUser: state.user.loggedInUser,
placeIndex
}
diff --git a/lib/components/user/places/favorite-places-list.js b/lib/components/user/places/favorite-places-list.js
index c73a1669c..c82348bee 100644
--- a/lib/components/user/places/favorite-places-list.js
+++ b/lib/components/user/places/favorite-places-list.js
@@ -3,7 +3,7 @@ import { ControlLabel } from 'react-bootstrap'
import { connect } from 'react-redux'
import * as userActions from '../../../actions/user'
-import { PLACES_PATH } from '../../../util/constants'
+import { CREATE_ACCOUNT_PLACES_PATH, PLACES_PATH } from '../../../util/constants'
import { isHomeOrWork } from '../../../util/user'
import FavoritePlaceRow from './favorite-place-row'
@@ -11,7 +11,7 @@ import FavoritePlaceRow from './favorite-place-row'
* Renders an editable list user's favorite locations, and lets the user add a new one.
* Additions, edits, and deletions of places take effect immediately.
*/
-const FavoritePlacesList = ({ deleteUserPlace, loggedInUser }) => {
+const FavoritePlacesList = ({ deleteUserPlace, isCreating, loggedInUser }) => {
const { savedLocations } = loggedInUser
return (
@@ -22,7 +22,7 @@ const FavoritePlacesList = ({ deleteUserPlace, loggedInUser }) => {
isFixed={isHomeOrWork(place)}
key={index}
onDelete={() => deleteUserPlace(index)}
- path={`${PLACES_PATH}/${index}`}
+ path={`${isCreating ? CREATE_ACCOUNT_PLACES_PATH : PLACES_PATH}/${index}`}
place={place}
/>
)
@@ -37,7 +37,10 @@ const FavoritePlacesList = ({ deleteUserPlace, loggedInUser }) => {
// connect to the redux store
const mapStateToProps = (state, ownProps) => {
+ const path = state.router.location.pathname
+ const isCreating = path === CREATE_ACCOUNT_PLACES_PATH
return {
+ isCreating,
loggedInUser: state.user.loggedInUser
}
}
diff --git a/lib/util/constants.js b/lib/util/constants.js
index 51aaa9133..34e2b6a09 100644
--- a/lib/util/constants.js
+++ b/lib/util/constants.js
@@ -11,6 +11,7 @@ export const PLACES_PATH = `${ACCOUNT_PATH}/places`
export const CREATE_ACCOUNT_PATH = `${ACCOUNT_PATH}/create`
export const CREATE_ACCOUNT_TERMS_PATH = `${CREATE_ACCOUNT_PATH}/terms`
export const CREATE_ACCOUNT_VERIFY_PATH = `${CREATE_ACCOUNT_PATH}/verify`
+export const CREATE_ACCOUNT_PLACES_PATH = `${CREATE_ACCOUNT_PATH}/places`
export const CREATE_TRIP_PATH = `${TRIPS_PATH}/new`
// Gets the root URL, e.g. https://otp-instance.example.com:8080, computed once for all.