-
Notifications
You must be signed in to change notification settings - Fork 59
Check itinerary existence #242
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
Conversation
| async componentDidMount () { | ||
| // Check itinerary existence for all days. | ||
| const { accessToken, config, setFieldValue, values } = this.props | ||
|
|
||
| const itineraryCheckResult = await checkItinerary( | ||
| config.persistence.otp_middleware, | ||
| accessToken, | ||
| values | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this check occurs every time the component mounts, it might be possible that an itinerary becomes impossible for an existing itinerary that was possible before. Is there a way to have this run only when creating a monitored trip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial thought and It is possible from the UI, but it will currently fail on the backend (the preUpdateHook method will trigger an error if the trip does not exist for one of the monitored days). Should the backend be changed to accommodate that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably think about this a little more in depth. At some point this UI should also show when an itinerary is no longer possible which means updating things in the backend and then communicating that somehow to the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and remove the trip existence enforcement when saving existing trips in ibi-group/otp-middleware@78e31e7. With commit aeb519f, the UI will still perform the check and highlight the days an existing trip is not possible, however it will let the user save that trip. Trip existence continues to be enforced for new trips.
evansiroky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we figure out how to communicate that a Monitored Trip is no longer possible on a particular day of the week, we should have this itinerary existence check run only upon the creation of a new Monitored Trip.
@evansiroky Did you mean also not enforcing that in the backend? |
evansiroky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good
… for itin checks.
lib/actions/user.js
Outdated
| const setLastPhoneSmsRequest = createAction('SET_LAST_PHONE_SMS_REQUEST') | ||
| export const setPathBeforeSignIn = createAction('SET_PATH_BEFORE_SIGNIN') | ||
| export const clearItineraryExistence = createAction('CLEAR_ITINERARY_AVAILABILITY') | ||
| const setitineraryExistence = createAction('SET_ITINERARY_AVAILABILITY') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I think the action string should match the action name i.e., replace AVAILABILITY with EXISTENCE.
Also setitineraryExistence has a typo (the first i should be capitalized).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 846892a.
lib/actions/user.js
Outdated
| export function checkItineraryExistence (trip) { | ||
| return async function (dispatch, getState) { | ||
| const { accessToken, apiBaseUrl, apiKey } = getMiddlewareVariables(getState()) | ||
| const requestUrl = `${apiBaseUrl}${API_MONITORED_TRIP_PATH}${API_MONITORED_TRIP_CHECK_SUBPATH}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think API_MONITORED_TRIP_CHECK_SUBPATH needs to be in a constant if it's only used one time. Having constants far away from the place they're used can make things hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Updated in 846892a
| const mapStateToProps = (state, ownProps) => { | ||
| const { accessToken, itineraryExistence } = state.user | ||
| return { | ||
| accessToken, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is accessToken needed still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find. Updated in 846892a.
| * @returns true if there is a trip matching for the specified availability/existence check. | ||
| */ | ||
| function itineraryExists (dayCheck) { | ||
| return dayCheck && dayCheck.valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this method is needed any longer, is it? We should be guaranteed to have an entry for each day in the ItineraryExistence response, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it is not. Updated in 846892a.
| <FormGroup validationState={monitoredDaysValidationState}> | ||
| <ControlLabel>What days do you take this trip?</ControlLabel> | ||
| <div> | ||
| {allDays.map(({ name, fullText, text }, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit redundant to have allDays and ALL_DAYS, which effectively contain the same info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 846892a.
landonreed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nitpicks. Otherwise, looks great!
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR depends on #239 and requires changes from
ibi-group/otp-middleware#77ibi-group/otp-middleware#90.It causes the trip settings UI to