-
Notifications
You must be signed in to change notification settings - Fork 53
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
Support one-time trips #1186
Support one-time trips #1186
Conversation
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.
Most of the new code looks good, just one small nit about the UI for the new feature
<Checkbox checked={isOneTime} onChange={this._handleOneTimeTrip}> | ||
<FormattedMessage | ||
id="components.TripBasicsPane.onlyOnDate" | ||
values={{ date: itinerary.startTime }} | ||
/> | ||
</Checkbox> |
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.
Should this maybe be a radio button instead? I'm thinking of having a big toggle switch between "monitor once" and "monitor regularly" and that way we can hide the calendar view if we have to
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.
…itialize days with itin existen
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 enough for now!
export default function pastTripRenderer( | ||
monitoredTrip: MonitoredTrip | ||
): MonitoredTripRenderData { | ||
const data = baseRenderer(monitoredTrip) as unknown as MonitoredTripRenderData |
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.
Yikes, what's going on with the type here?
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.
If I just write as MonitoredTripRenderData
, TypeScript doesn't believe me...
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.
Ah I see, the file it's in isn't typescripted.
<FormattedMessage id="components.TripBasicsPane.recurringEachWeek" /> | ||
</Radio> | ||
{!isOneTime ? ( | ||
<> |
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.
Would it be possible to move each side of this ternary into a component so that it's easier to read? I had trouble finding the else part of the ternary, it's a lot of open and close brackets. It's fine if the components are inside this one so there are no props.
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.
The map
in there is also a lot to parse. Feels like a bit too much to tuck inline.
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.
Oh I just understood that this ternary is being used to just hide this when isOneTime is true. Could it just be !isOneTime &&
in that case?
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.
The
map
in there is also a lot to parse. Feels like a bit too much to tuck inline.
There is a redesign of this portion upcoming, so we will address that at that time.
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.
Could it just be
!isOneTime &&
in that case?
Refactored in 655454c.
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.
This looks good, pending some kind of correction to the current behavior which breaks if the middleware is unable to validate a trip exists.
…hecking existence.
@daniel-heppner-ibigroup Let me know what you think of this fix 655454c. |
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.
Looks great! Thank you! @binh-dam-ibigroup
Description
Works with ibi-group/otp-middleware#224
This PR adds support for saving/monitoring trips that will be taken only once.
Behaviors of note:
<date>
" checkbox will uncheck other monitored days. Checking a monitored day will uncheck "Only on<date>
".PR Checklist