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