Skip to content

Commit

Permalink
Merge pull request #1255 from opentripplanner/saved-trip-back-link
Browse files Browse the repository at this point in the history
fix(saved-trip-editor): Route back button to saved trips if editing
  • Loading branch information
miles-grant-ibigroup authored Aug 20, 2024
2 parents 21140f2 + 5d7e51c commit 95b87c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/components/user/back-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ const StyledButton = styled(Button)`
padding: 0;
`

export const BackButtonContent = () => (
<IconWithText Icon={ArrowLeft}>
<FormattedMessage id="common.forms.back" />
</IconWithText>
)

/**
* Back link that navigates to the previous location in browser history.
*/
const BackLink = () => (
<StyledButton bsStyle="link" onClick={navigateBack}>
<IconWithText Icon={ArrowLeft}>
<FormattedMessage id="common.forms.back" />
</IconWithText>
<BackButtonContent />
</StyledButton>
)

Expand Down
10 changes: 8 additions & 2 deletions lib/components/user/monitored-trip/saved-trip-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { FormattedMessage, useIntl } from 'react-intl'
import React, { ComponentType } from 'react'

import { BackButtonContent } from '../back-link'
import { MonitoredTrip } from '../types'
import BackLink from '../back-link'
import { TRIPS_PATH } from '../../../util/constants'
import DeleteForm from '../delete-form'
import Link from '../../util/link'
import PageTitle from '../../util/page-title'
import StackedPanesWithSave from '../stacked-panes-with-save'

Expand Down Expand Up @@ -52,7 +54,11 @@ const SavedTripEditor = (props: Props): JSX.Element => {
return (
<>
<PageTitle title={title} />
<BackLink />
{/* If creating, back button should return to trip planner. If not, it should return
to saved trips, just in case the user accessed this page through their email. */}
<Link to={isCreating ? '/' : TRIPS_PATH}>
<BackButtonContent />
</Link>
<StackedPanesWithSave
extraButton={
monitoredTrip.id
Expand Down

0 comments on commit 95b87c9

Please sign in to comment.