Skip to content

Commit

Permalink
improvement: Add title to toasts on mobility wiz, saved trip.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Jan 9, 2025
1 parent 87ab384 commit d9a00f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 9 additions & 1 deletion lib/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../util/user'
import { isBlank } from '../util/ui'
import { secureFetch } from '../util/middleware'
import { toastSuccess } from '../components/util/toasts'
import { TRIPS_PATH } from '../util/constants'

import { routeTo, setLocale } from './ui'
Expand Down Expand Up @@ -500,7 +501,14 @@ export function createOrUpdateUserMonitoredTrip(

if (status === 'success' && data) {
if (!silentOnSuccess && intl) {
toast.success(
toastSuccess(
isNew
? intl.formatMessage({
id: 'components.SavedTripEditor.saveNewTrip'
})
: intl.formatMessage({
id: 'components.SavedTripEditor.editSavedTrip'
}),
intl.formatMessage({ id: 'actions.user.preferencesSaved' })
)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/user/mobility-profile/mobility-wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MobilityWizard = ({ formikProps }: WizardProps): JSX.Element => {
const intl = useIntl()

const title = intl.formatMessage({
id: 'components.MobilityProfile.title'
id: 'components.MobilityProfile.MobilityPane.header'
})

return (
Expand Down
10 changes: 7 additions & 3 deletions lib/components/user/wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { FormattedMessage, injectIntl, IntlShape } from 'react-intl'
import { push, replace } from 'connected-react-router'
import React, { Component, MouseEvent } from 'react'
import styled from 'styled-components'
import toast from 'react-hot-toast'

import * as uiActions from '../../actions/ui'
import { AppReduxState } from '../../util/state-types'
import { GREY_ON_WHITE } from '../util/colors'
import { toastSuccess } from '../util/toasts'
import PageTitle from '../util/page-title'

import { EditedUser } from './types'
Expand Down Expand Up @@ -69,7 +69,8 @@ class Wizard extends Component<Props> {
onNext,
pages,
returnTo = '/',
routeTo
routeTo,
title
} = this.props

if (activePaneIndex < pages.length - 1) {
Expand All @@ -94,7 +95,10 @@ class Wizard extends Component<Props> {
} else {
// Display a toast to acknowledge saved changes
// (although in reality, changes quietly took effect in previous screens).
toast.success(intl.formatMessage({ id: 'actions.user.preferencesSaved' }))
toastSuccess(
title,
intl.formatMessage({ id: 'actions.user.preferencesSaved' })
)
routeTo(returnTo)
}
}
Expand Down

0 comments on commit d9a00f4

Please sign in to comment.