fix: event type back button (#15722)
This commit is contained in:
@@ -26,7 +26,6 @@ import { HttpError } from "@calcom/lib/http-error";
|
||||
import { telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
|
||||
import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
|
||||
import type { Prisma } from "@calcom/prisma/client";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import type { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||
import { eventTypeBookingFields } from "@calcom/prisma/zod-utils";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
@@ -401,40 +400,40 @@ const EventTypePage = (props: EventTypeSetupProps & { allActiveWorkflows?: Workf
|
||||
formState: { isDirty: isFormDirty, dirtyFields },
|
||||
} = formMethods;
|
||||
|
||||
useEffect(() => {
|
||||
const handleRouteChange = (url: string) => {
|
||||
const paths = url.split("/");
|
||||
|
||||
// Check if event is managed event type - skip if there is assigned users
|
||||
const assignedUsers = eventType.children;
|
||||
const isManagedEventType = eventType.schedulingType === SchedulingType.MANAGED;
|
||||
if (eventType.assignAllTeamMembers) {
|
||||
return;
|
||||
} else if (isManagedEventType && assignedUsers.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hosts = eventType.hosts;
|
||||
if (
|
||||
!leaveWithoutAssigningHosts.current &&
|
||||
!!team &&
|
||||
(hosts.length === 0 || assignedUsers.length === 0) &&
|
||||
(url === "/event-types" || paths[1] !== "event-types")
|
||||
) {
|
||||
setIsOpenAssignmentWarnDialog(true);
|
||||
setPendingRoute(url);
|
||||
router.events.emit(
|
||||
"routeChangeError",
|
||||
new Error(`Aborted route change to ${url} because none was assigned to team event`)
|
||||
);
|
||||
throw "Aborted";
|
||||
}
|
||||
};
|
||||
router.events.on("routeChangeStart", handleRouteChange);
|
||||
return () => {
|
||||
router.events.off("routeChangeStart", handleRouteChange);
|
||||
};
|
||||
}, [router]);
|
||||
// useEffect(() => {
|
||||
// const handleRouteChange = (url: string) => {
|
||||
// const paths = url.split("/");
|
||||
//
|
||||
// // Check if event is managed event type - skip if there is assigned users
|
||||
// const assignedUsers = eventType.children;
|
||||
// const isManagedEventType = eventType.schedulingType === SchedulingType.MANAGED;
|
||||
// if (eventType.assignAllTeamMembers) {
|
||||
// return;
|
||||
// } else if (isManagedEventType && assignedUsers.length > 0) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const hosts = eventType.hosts;
|
||||
// if (
|
||||
// !leaveWithoutAssigningHosts.current &&
|
||||
// !!team &&
|
||||
// (hosts.length === 0 || assignedUsers.length === 0) &&
|
||||
// (url === "/event-types" || paths[1] !== "event-types")
|
||||
// ) {
|
||||
// setIsOpenAssignmentWarnDialog(true);
|
||||
// setPendingRoute(url);
|
||||
// router.events.emit(
|
||||
// "routeChangeError",
|
||||
// new Error(`Aborted route change to ${url} because none was assigned to team event`)
|
||||
// );
|
||||
// throw "Aborted";
|
||||
// }
|
||||
// };
|
||||
// router.events.on("routeChangeStart", handleRouteChange);
|
||||
// return () => {
|
||||
// router.events.off("routeChangeStart", handleRouteChange);
|
||||
// };
|
||||
// }, [router]);
|
||||
|
||||
const appsMetadata = formMethods.getValues("metadata")?.apps;
|
||||
const availability = formMethods.watch("availability");
|
||||
|
||||
Reference in New Issue
Block a user