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

issue-1686/navigate event #1704

Merged
merged 3 commits into from
Dec 16, 2023
Merged

issue-1686/navigate event #1704

merged 3 commits into from
Dec 16, 2023

Conversation

kaulfield23
Copy link
Contributor

Description

This PR fixes a bug that page doesn't navigate to newly created event page.

Screenshots

My.winter.project.Mozilla.Firefox.2023-12-13.16-04-19.mp4

Changes

  • Adds listenerMiddleware

Notes to reviewer

Related issues

Resolves #1686

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the bug which is nice, but it also introduces another bug. More details in my comment below. Message me if you're not sure what I'm trying to get across in my message, because I'm struggling to explain it well. 😊

effect: (action) => {
const event = action.payload;
Router.push(
`/organize/${event.organization?.id}/projects/${event.campaign?.id}/events/${event.id}`
Copy link
Member

@richardolsson richardolsson Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks when creating an event that isn't part of a project, like this:

  1. Go to /orgs/1/projects/calendar (the global calendar)
  2. Go to week view
  3. Drag to create a block in the calendar
  4. Click "Create single event"

Expected results:
Should navigate to new event page.

Actual results:
Navigates to new event page, but then also quickly after navigates to URL where campaign ID is undefined (e.g. /organize/1/projects/undefined/events/82).

There is already code on main to redirect to a newly created event after creating it in the calendar. That code does not use this middleware approach. I'm not sure which I prefer, but regardless, there should only be one piece of code that does the same thing (right now two redirects are happening).

And regardless of where the redirect happens, it needs to account for events outside of projects. The easiest way to do that is to use the getEventUrl() utility function.

Copy link
Contributor Author

@kaulfield23 kaulfield23 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha that was why there was no middleware for eventCreated! Thank you!

@@ -20,6 +21,10 @@ export default function useCreateEvent(orgId: number): useCreateEventReturn {
eventBody
);
dispatch(eventCreated(event));
env.router.push(
`/organize/${orgId}/projects/${event.campaign?.id}/events/${event.id}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should always use the getEventUrl() utility to generate event URLs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay!

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now!

@richardolsson richardolsson merged commit ff2ada1 into main Dec 16, 2023
4 checks passed
@richardolsson richardolsson deleted the issue-1686/navigate-event branch December 16, 2023 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigating to event page after creating it
2 participants