Skip to content

Commit

Permalink
improvement(connected-endpoints-overlay): Add intl support for rememb…
Browse files Browse the repository at this point in the history
…erPlace.
  • Loading branch information
binh-dam-ibigroup committed Sep 7, 2023
1 parent 6938b8f commit 7830b5d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ actions:
emailVerificationResent: The email verification message has been resent.
genericError: "An error was encountered: {err}"
itineraryExistenceCheckFailed: Error checking whether your selected trip is possible.
placeRemembered: Your {placeType} has been set to {address}.
preferencesSaved: Your preferences have been saved.
smsInvalidCode: The code you entered is invalid. Please try again.
smsResendThrottled: >-
Expand Down
19 changes: 17 additions & 2 deletions lib/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,21 @@ export function saveUserPlace(placeToSave, placeIndex, intl) {
}

dispatch(createOrUpdateUser(loggedInUser, true, intl))
if (intl) {
toast.success(
intl.formatMessage(
{
id: 'actions.user.placeRemembered'
},
{
address: placeToSave.address,
placeType: intl.formatMessage({
id: `common.places.${placeToSave.type}`
})
}
)
)
}
}
}

Expand Down Expand Up @@ -738,7 +753,7 @@ export function deleteUserPlace(place, intl) {
* Remembers a place for the logged-in or local user
* according to the persistence strategy.
*/
export function rememberPlace(placeTypeLocation) {
export function rememberPlace(placeTypeLocation, intl) {
return function (dispatch, getState) {
const { otp, user } = getState()
const persistenceMode = getPersistenceMode(otp.config.persistence)
Expand All @@ -755,7 +770,7 @@ export function rememberPlace(placeTypeLocation) {
)
if (placeIndex > -1) {
// Convert to loggedInUser saved place
dispatch(saveUserPlace(convertToPlace(location), placeIndex))
dispatch(saveUserPlace(convertToPlace(location), placeIndex, intl))
}
}
} else if (persistenceMode.isLocalStorage) {
Expand Down
25 changes: 21 additions & 4 deletions lib/components/map/connected-endpoints-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,32 @@ import { getActiveSearch, getShowUserSettings } from '../../util/state'
import { getUserLocations } from '../../util/user'
import { setLocation } from '../../actions/map'

const ConnectedEndpointsOverlay = (props) => {
const ConnectedEndpointsOverlay = ({
forgetPlace,
rememberPlace,
...otherProps
}) => {
const intl = useIntl()
const _forgetPlace = useCallback(
(place) => {
props.forgetPlace(place, intl)
forgetPlace(place, intl)
},
[forgetPlace, intl]
)

const _rememberPlace = useCallback(
(placeTypeLocation) => {
rememberPlace(placeTypeLocation, intl)
},
[props, intl]
[rememberPlace, intl]
)
return (
<EndpointsOverlay
{...otherProps}
forgetPlace={_forgetPlace}
rememberPlace={_rememberPlace}
/>
)
return <EndpointsOverlay {...props} forgetPlace={_forgetPlace} />
}

// connect to the redux store
Expand Down

0 comments on commit 7830b5d

Please sign in to comment.