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

Add alert tag on saved trips #1081

Merged
merged 8 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ components:
tripNotFoundDescription: Sorry, the requested trip was not found.
tripNotifications: Trip notifications
SavedTripList:
alertTag: "{alert, plural, one {View one alert} other {View # alerts}}"
fromTo: From {from} to {to}
myTrips: My trips
noSavedTrips: You have no saved trips
Expand Down
1 change: 1 addition & 0 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ components:
tripNotFoundDescription: Le trajet recherché est introuvable.
tripNotifications: Notifications du trajet
SavedTripList:
alertTag: "{alert, plural, one {Afficher une alerte} other {Afficher # alertes}}"
fromTo: De {from} à {to}
myTrips: Mes trajets
noSavedTrips: Vous n'avez aucun trajet enregistré
Expand Down
29 changes: 27 additions & 2 deletions lib/components/user/monitored-trip/saved-trip-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Pause } from '@styled-icons/fa-solid/Pause'
import { PencilAlt } from '@styled-icons/fa-solid/PencilAlt'
import { Play } from '@styled-icons/fa-solid/Play'
import { Trash } from '@styled-icons/fa-solid/Trash'
import { TriangleExclamation } from '@styled-icons/fa-solid/TriangleExclamation'
import { withAuthenticationRequired } from '@auth0/auth0-react'
import React, { Component } from 'react'

Expand All @@ -17,6 +18,7 @@ import { MonitoredTrip } from '../types'
import {
PageHeading,
TripHeader,
TripPanelAlert,
TripPanelFooter,
TripPanelHeading
} from '../styled'
Expand All @@ -28,11 +30,13 @@ import BackToTripPlanner from '../back-to-trip-planner'
import PageTitle from '../../util/page-title'
import withLoggedInUserSupport from '../with-logged-in-user-support'

import getRenderData from './trip-status-rendering-strategies'
import TripSummaryPane from './trip-summary-pane'

interface ItemProps {
confirmAndDeleteUserMonitoredTrip: (id: string, intl: IntlShape) => void
intl: IntlShape
renderData: any
routeTo: (url: any) => void
togglePauseTrip: (trip: MonitoredTrip, intl: IntlShape) => void
trip: MonitoredTrip
Expand Down Expand Up @@ -92,9 +96,10 @@ class TripListItem extends Component<ItemProps, ItemState> {
}

render() {
const { trip } = this.props
const { renderData, trip } = this.props
const { itinerary } = trip
const { legs } = itinerary
const { alerts } = renderData
// Assuming the monitored itinerary has at least one leg:
// - get the 'from' location of the first leg,
// - get the 'to' location of the last leg.
Expand All @@ -103,6 +108,16 @@ class TripListItem extends Component<ItemProps, ItemState> {
return (
<Panel>
<TripPanelHeading>
{alerts && alerts.length > 0 && (
<TripPanelAlert onClick={this._handleEditTrip}>
<IconWithText Icon={TriangleExclamation}>
<FormattedMessage
id="components.SavedTripList.alertTag"
values={{ alert: alerts.length }}
/>
</IconWithText>
</TripPanelAlert>
)}
<Panel.Title>
<TripHeader>{trip.tripName}</TripHeader>
<small>
Expand Down Expand Up @@ -165,6 +180,16 @@ class TripListItem extends Component<ItemProps, ItemState> {
}

// connect to the redux store
const itemMapStateToProps = (ownProps: ItemProps) => {
const { trip } = ownProps
const renderData = getRenderData({
monitoredTrip: trip
})

return {
renderData
}
}

const itemMapDispatchToProps = {
confirmAndDeleteUserMonitoredTrip:
Expand All @@ -173,7 +198,7 @@ const itemMapDispatchToProps = {
togglePauseTrip: userActions.togglePauseTrip
}
const ConnectedTripListItem = connect(
null,
itemMapStateToProps,
itemMapDispatchToProps
)(injectIntl(TripListItem))

Expand Down
16 changes: 15 additions & 1 deletion lib/components/user/styled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Panel } from 'react-bootstrap'
import { Button, Panel } from 'react-bootstrap'
import styled, { css } from 'styled-components'

import { RED_ON_WHITE } from '../util/colors'

export const PageHeading = styled.h2`
margin: 10px 0px 45px 0px;
`
Expand Down Expand Up @@ -48,6 +50,18 @@ export const TripPanelHeading = styled(Panel.Heading)`
background-color: white !important;
`

export const TripPanelAlert = styled.a`
color: ${RED_ON_WHITE};
cursor: pointer;
float: right;
text-decoration: underline;
&:hover {
background-color: transparent;
color: ${RED_ON_WHITE};
opacity: 80%;
}
`

export const TripPanelFooter = styled(Panel.Footer)`
background-color: white !important;
padding: 0px;
Expand Down
Loading