-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
chore: app router - /event-types pages #18181
Draft
hbjORbj
wants to merge
18
commits into
main
Choose a base branch
from
chore/event-type-app-router
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
aef1705
refactor event type web wrapper
hbjORbj 3a72d31
finish migration
hbjORbj 09f9833
move event-types folder out of future
hbjORbj 01568aa
remove vars
hbjORbj 8efb797
remove pages router
hbjORbj 2721da4
fix
hbjORbj 5a73373
fix
hbjORbj d8a0fd6
merge origin/main
hbjORbj a4b7f35
fix test
hbjORbj d033bd8
remove test tag
hbjORbj 80aca22
refactor
hbjORbj 76287f1
remove completely
hbjORbj fd3fecf
Merge remote-tracking branch 'origin/main' into chore/event-type-app-…
hbjORbj 0c28ff2
add withoutSeo prop for event type web page
hbjORbj 4e5cdf3
remove HeadSeo usage from event types listing view
hbjORbj 4d083f5
make onboarding e2e test faster
hbjORbj ef08a5a
Merge branch 'main' into chore/event-type-app-router
hbjORbj 4a44961
Merge branch 'main' into chore/event-type-app-router
hbjORbj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
"use client"; | ||
|
||
import type { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime"; | ||
import dynamic from "next/dynamic"; | ||
import { usePathname, useRouter as useAppRouter } from "next/navigation"; | ||
// eslint-disable-next-line @calcom/eslint/deprecated-imports-next-router | ||
import { useRouter as usePageRouter } from "next/router"; | ||
// eslint-disable-next-line @calcom/eslint/deprecated-imports-next-router | ||
import type { NextRouter as NextPageRouter } from "next/router"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { z } from "zod"; | ||
|
||
|
@@ -89,74 +84,21 @@ const EventAITab = dynamic(() => | |
|
||
export type EventTypeWebWrapperProps = { | ||
id: number; | ||
isAppDir?: boolean; | ||
}; | ||
|
||
// discriminative factor: isAppDir | ||
type EventTypeAppComponentProp = { | ||
id: number; | ||
isAppDir: true; | ||
pathname: string; | ||
pageRouter: null; | ||
appRouter: AppRouterInstance; | ||
}; | ||
|
||
// discriminative factor: isAppDir | ||
type EventTypePageComponentProp = { | ||
id: number; | ||
isAppDir: false; | ||
pageRouter: NextPageRouter; | ||
pathname: null; | ||
appRouter: null; | ||
}; | ||
|
||
type EventTypeAppPageComponentProp = EventTypeAppComponentProp | EventTypePageComponentProp; | ||
|
||
export const EventTypeWebWrapper = ({ id, isAppDir }: EventTypeWebWrapperProps & { isAppDir?: boolean }) => { | ||
export const EventTypeWebWrapper = ({ id }: EventTypeWebWrapperProps) => { | ||
const { data: eventTypeQueryData } = trpc.viewer.eventTypes.get.useQuery({ id }); | ||
|
||
if (!eventTypeQueryData) return null; | ||
|
||
return isAppDir ? ( | ||
<EventTypeAppWrapper {...eventTypeQueryData} id={id} /> | ||
) : ( | ||
<EventTypePageWrapper {...eventTypeQueryData} id={id} /> | ||
); | ||
}; | ||
|
||
const EventTypePageWrapper = ({ id, ...rest }: EventTypeSetupProps & { id: number }) => { | ||
const router = usePageRouter(); | ||
return ( | ||
<EventTypeWeb {...rest} id={id} isAppDir={false} pageRouter={router} pathname={null} appRouter={null} /> | ||
); | ||
return <EventTypeWeb {...eventTypeQueryData} id={id} />; | ||
}; | ||
|
||
const EventTypeAppWrapper = ({ id, ...rest }: EventTypeSetupProps & { id: number }) => { | ||
const pathname = usePathname(); | ||
const router = useAppRouter(); | ||
return ( | ||
<EventTypeWeb | ||
{...rest} | ||
id={id} | ||
isAppDir={true} | ||
pathname={pathname ?? ""} | ||
pageRouter={null} | ||
appRouter={router} | ||
/> | ||
); | ||
}; | ||
|
||
const EventTypeWeb = ({ | ||
id, | ||
isAppDir, | ||
pageRouter, | ||
appRouter, | ||
pathname, | ||
...rest | ||
}: EventTypeSetupProps & EventTypeAppPageComponentProp) => { | ||
const EventTypeWeb = ({ id, ...rest }: EventTypeSetupProps & { id: number }) => { | ||
const { t } = useLocale(); | ||
const utils = trpc.useUtils(); | ||
|
||
const pathname = usePathname(); | ||
const appRouter = useAppRouter(); | ||
const { data: user, isPending: isLoggedInUserPending } = useMeQuery(); | ||
const isTeamEventTypeDeleted = useRef(false); | ||
const leaveWithoutAssigningHosts = useRef(false); | ||
|
@@ -281,7 +223,7 @@ const EventTypeWeb = ({ | |
} as const; | ||
|
||
useHandleRouteChange({ | ||
watchTrigger: isAppDir ? pageRouter : pathname, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like we used an opposite conditional here |
||
watchTrigger: pathname, | ||
isTeamEventTypeDeleted: isTeamEventTypeDeleted.current, | ||
isleavingWithoutAssigningHosts: leaveWithoutAssigningHosts.current, | ||
isTeamEventType: !!team, | ||
|
@@ -292,22 +234,10 @@ const EventTypeWeb = ({ | |
onError: (url) => { | ||
setIsOpenAssignmentWarnDialog(true); | ||
setPendingRoute(url); | ||
if (!isAppDir) { | ||
pageRouter.events.emit( | ||
"routeChangeError", | ||
new Error(`Aborted route change to ${url} because none was assigned to team event`) | ||
); | ||
throw "Aborted"; | ||
} | ||
|
||
if (isAppDir) throw new Error(`Aborted route change to ${url} because none was assigned to team event`); | ||
throw new Error(`Aborted route change to ${url} because none was assigned to team event`); | ||
}, | ||
onStart: (handleRouteChange) => { | ||
!isAppDir && pageRouter.events.on("routeChangeStart", handleRouteChange); | ||
isAppDir && handleRouteChange(pathname || ""); | ||
}, | ||
onEnd: (handleRouteChange) => { | ||
!isAppDir && pageRouter.events.off("routeChangeStart", handleRouteChange); | ||
handleRouteChange(pathname || ""); | ||
}, | ||
}); | ||
|
||
|
@@ -370,7 +300,7 @@ const EventTypeWeb = ({ | |
await utils.viewer.eventTypes.invalidate(); | ||
showToast(t("event_type_deleted_successfully"), "success"); | ||
isTeamEventTypeDeleted.current = true; | ||
isAppDir ? appRouter.push("/event-types") : pageRouter.push("/event-types"); | ||
appRouter.push("/event-types"); | ||
setSlugExistsChildrenDialogOpen([]); | ||
setIsOpenAssignmentWarnDialog(false); | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
await page.waitForLoadState("networkidle");
is likely to never resolve in App Router because there are constantly likely to be network activities in App Router (e.g., streaming server components)