Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toast for companion updates #1331

Merged
merged 9 commits into from
Jan 9, 2025
1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ components:
errorUpdatingProfile: Error updating profile.
fieldUpdated: This setting has been updated.
fields:
add-companion-form: Travel Companions
storeTripHistory: Store trip history
updating: Updating
UserSettings:
Expand Down
1 change: 1 addition & 0 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ components:
errorUpdatingProfile: Erreur dans la mise à jour de votre profil.
fieldUpdated: Ce paramètre a été mis à jour.
fields:
add-companion-form: Accompagnateurs
storeTripHistory: Enregistrement des recherches
updating: Mise à jour
UserSettings:
Expand Down
1 change: 1 addition & 0 deletions i18n/i18n-exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"push"
],
"components.UserAccountScreen.fields.*": [
"add-companion-form",
"storeTripHistory"
],
"components.OTP2ErrorRenderer.*.body": [
Expand Down
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
4 changes: 2 additions & 2 deletions lib/components/user/common/add-email-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Field, Form, Formik } from 'formik'
import React, { ReactNode } from 'react'
import styled from 'styled-components'

import { ControlStrip, phoneFieldStyle } from '../styled'
import { phoneFieldStyle } from '../styled'
import SubmitButton from '../../util/submit-button'

interface Props {
Expand Down Expand Up @@ -64,7 +64,7 @@ const AddEmailForm = ({
<FormGroup validationState={showError ? 'error' : null}>
<ControlLabel>{label}</ControlLabel>
<Controls>
<Form id={id} noValidate />
<Form id={id} name={id} noValidate />
<Field
aria-invalid={showError}
aria-required
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
Loading