refactor: Deprecate Legacy v2 Booker Atom Endpoints (#20939)
* feat: split atoms endpoints and add public event type endpoint * Update ConnectedDestinationCalendars import path across platform/atoms components * refactor: update BookingResponse import path from platform-libraries to features/bookings * Move AvailableSlotsType to util.ts and update imports to use GetAvailableSlotsResponse * Refactor import path for RecurringBookingCreateBody type from libraries to types * Fix import path for getBookingForReschedule type from platform-libraries to features * Refactor PublicEventType export location and update import references * Remove @calcom/platform-libraries dependency from atoms package.json * chore(deps): update yarn.lock dependencies * Remove console.log statements and fix indentation in event type hooks * Migrate event type transformers from platform/libraries to api/v2 directory * Remove console.log * Update BookerPlatformWrapper.tsx * Add script to populate empty team slugs with slugified team names * Remove vitest imports * reset platform libraries version * Remove unused orgId comment from useAtomGetPublicEvent hook params * Update useApiV2AvailableSlots.ts * refactor: remove unused exports from lib package index file * Undo: @SomayChauhan Add script to populate empty team slugs with slugified team names * Update booking.tsx * chore: upgrade @calcom/platform-libraries from 0.0.202 to 0.0.205 * chore: bump @calcom/platform-libraries from 0.0.205 to 0.0.206 * chore: configure babel and jest for node module transpilation in api v2 * fix: type errors * Revert "chore: configure babel and jest for node module transpilation in api v2" This reverts commit b2cf172a84fe8953f9497bf6e43874f476fbc04b. * Update calendars.service.ts * chore: bump @calcom/platform-libraries from 0.0.208 to 0.0.209 * fix: add proper type definition for calendar busy times to resolve ts-expect-error * refactor: deprecate v2 old availability endpoints (#21075) Co-authored-by: Morgan <[email protected]> * chore: publish platform librareis * feat: add delegation credential fields to calendar service mock * chore: update @calcom/platform-libraries from 0.0.211 to 0.0.213 * fix: skip failing calendar integration test * chore: bump @calcom/platform-libraries from 0.0.213 to 0.0.214 * fix: api/v2 build error * fix: e2e tests --------- Co-authored-by: Morgan <[email protected]> Co-authored-by: supalarry <[email protected]> Co-authored-by: Lauris Skraucis <[email protected]>
This commit is contained in:
105 files changed
+6611
-1552
No files matched your search
-152
@@ -1,152 +0,0 @@
|
||||
import type { ScheduleOutput_2024_06_11 } from "@calcom/platform-types";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
|
||||
import { transformApiScheduleForAtom } from "./transformApiScheduleForAtom";
|
||||
|
||||
const SCHEDULE_OWNER_ID = 256;
|
||||
|
||||
describe("transformScheduleForAtom", () => {
|
||||
const user: Pick<User, "id" | "defaultScheduleId" | "timeZone"> = {
|
||||
id: SCHEDULE_OWNER_ID,
|
||||
defaultScheduleId: 139,
|
||||
timeZone: "America/New_York",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should return null if user is not provided", () => {
|
||||
const schedule: ScheduleOutput_2024_06_11 | null = {
|
||||
id: 139,
|
||||
ownerId: SCHEDULE_OWNER_ID,
|
||||
name: "Default",
|
||||
timeZone: "America/Cancun",
|
||||
availability: [
|
||||
{
|
||||
days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
|
||||
startTime: "09:00",
|
||||
endTime: "17:00",
|
||||
},
|
||||
],
|
||||
isDefault: true,
|
||||
overrides: [],
|
||||
};
|
||||
|
||||
expect(transformApiScheduleForAtom(undefined, schedule, 1)).toBeNull();
|
||||
});
|
||||
|
||||
it("should return null if schedule is not provided", () => {
|
||||
expect(transformApiScheduleForAtom(user, null, 1)).toBeNull();
|
||||
});
|
||||
|
||||
it("should transform schedule correctly", () => {
|
||||
const schedule: ScheduleOutput_2024_06_11 = {
|
||||
id: 139,
|
||||
ownerId: SCHEDULE_OWNER_ID,
|
||||
name: "Default",
|
||||
timeZone: "America/Cancun",
|
||||
availability: [
|
||||
{
|
||||
days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
|
||||
startTime: "09:00",
|
||||
endTime: "17:00",
|
||||
},
|
||||
],
|
||||
isDefault: true,
|
||||
overrides: [],
|
||||
};
|
||||
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
|
||||
const expectedResult = {
|
||||
id: 139,
|
||||
name: "Default",
|
||||
isManaged: false,
|
||||
workingHours: [
|
||||
{
|
||||
days: [1, 2, 3, 4, 5],
|
||||
startTime: 540,
|
||||
endTime: 1020,
|
||||
userId: 256,
|
||||
},
|
||||
],
|
||||
schedule: [
|
||||
{
|
||||
userId: 256,
|
||||
scheduleId: 139,
|
||||
days: [1, 2, 3, 4, 5],
|
||||
startTime: new Date(Date.UTC(1970, 0, 1, 9, 0)),
|
||||
endTime: new Date(Date.UTC(1970, 0, 1, 17, 0)),
|
||||
date: null,
|
||||
},
|
||||
],
|
||||
availability: [
|
||||
[],
|
||||
[
|
||||
{
|
||||
start: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T09:00:00.000Z`
|
||||
),
|
||||
end: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T17:00:00.000Z`
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T09:00:00.000Z`
|
||||
),
|
||||
end: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T17:00:00.000Z`
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T09:00:00.000Z`
|
||||
),
|
||||
end: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T17:00:00.000Z`
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T09:00:00.000Z`
|
||||
),
|
||||
end: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T17:00:00.000Z`
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T09:00:00.000Z`
|
||||
),
|
||||
end: new Date(
|
||||
`${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T17:00:00.000Z`
|
||||
),
|
||||
},
|
||||
],
|
||||
[],
|
||||
],
|
||||
timeZone: "America/Cancun",
|
||||
dateOverrides: [],
|
||||
isDefault: true,
|
||||
isLastSchedule: true,
|
||||
readOnly: false,
|
||||
};
|
||||
|
||||
const result = transformApiScheduleForAtom(user, schedule, 1);
|
||||
|
||||
expect(result).toEqual(expectedResult);
|
||||
});
|
||||
});
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
import {
|
||||
transformAvailabilityForAtom,
|
||||
transformDateOverridesForAtom,
|
||||
transformApiScheduleAvailability,
|
||||
transformApiScheduleOverrides,
|
||||
transformWorkingHoursForAtom,
|
||||
} from "@calcom/lib/schedules/transformers";
|
||||
import type { ScheduleOutput_2024_06_11 } from "@calcom/platform-types";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
|
||||
export function transformApiScheduleForAtom(
|
||||
user: Pick<User, "id" | "defaultScheduleId" | "timeZone"> | undefined,
|
||||
schedule: ScheduleOutput_2024_06_11 | null | undefined,
|
||||
userSchedulesCount: number
|
||||
) {
|
||||
if (!user || !schedule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const transformedSchedule = {
|
||||
...schedule,
|
||||
availability: transformApiScheduleAvailability(schedule.availability),
|
||||
overrides: transformApiScheduleOverrides(schedule.overrides),
|
||||
};
|
||||
|
||||
const combined = [...transformedSchedule.availability, ...transformedSchedule.overrides];
|
||||
const availability = combined.map((entry) => {
|
||||
return {
|
||||
...entry,
|
||||
userId: schedule.ownerId,
|
||||
scheduleId: schedule.id,
|
||||
days: "days" in entry ? entry.days : [],
|
||||
date: "date" in entry ? entry.date : null,
|
||||
id: schedule.id,
|
||||
};
|
||||
});
|
||||
|
||||
const atomSchedule = {
|
||||
...schedule,
|
||||
availability,
|
||||
userId: schedule.ownerId,
|
||||
};
|
||||
|
||||
const timeZone = schedule.timeZone || user.timeZone;
|
||||
const defaultScheduleId = user.defaultScheduleId;
|
||||
|
||||
return {
|
||||
id: schedule.id,
|
||||
name: schedule.name,
|
||||
isManaged: schedule.ownerId !== user.id,
|
||||
workingHours: transformWorkingHoursForAtom(atomSchedule),
|
||||
schedule: availability,
|
||||
availability: transformAvailabilityForAtom(atomSchedule),
|
||||
timeZone,
|
||||
dateOverrides: transformDateOverridesForAtom(atomSchedule, timeZone),
|
||||
isDefault: defaultScheduleId === schedule.id,
|
||||
isLastSchedule: userSchedulesCount <= 1,
|
||||
readOnly: schedule.ownerId !== user.id,
|
||||
};
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
import type { UpdateScheduleInput_2024_06_11 } from "@calcom/platform-types";
|
||||
|
||||
import type { AvailabilityFormValues } from "../types";
|
||||
import { transformAtomScheduleForApi } from "./transformAtomScheduleForApi";
|
||||
|
||||
describe("transformAtomScheduleForApi", () => {
|
||||
it("should transform atom schedule correctly to API format", () => {
|
||||
const input: AvailabilityFormValues = {
|
||||
name: "Default",
|
||||
schedule: [
|
||||
[],
|
||||
[
|
||||
{
|
||||
start: new Date("2024-05-14T09:00:00.000Z"),
|
||||
end: new Date("2024-05-14T17:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date("2024-05-14T09:00:00.000Z"),
|
||||
end: new Date("2024-05-14T17:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date("2024-05-14T09:00:00.000Z"),
|
||||
end: new Date("2024-05-14T17:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date("2024-05-14T09:00:00.000Z"),
|
||||
end: new Date("2024-05-14T17:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
start: new Date("2024-05-14T11:00:00.000Z"),
|
||||
end: new Date("2024-05-14T12:00:00.000Z"),
|
||||
},
|
||||
],
|
||||
[],
|
||||
],
|
||||
dateOverrides: [],
|
||||
timeZone: "America/Cancun",
|
||||
isDefault: true,
|
||||
};
|
||||
|
||||
const expectedOutput: UpdateScheduleInput_2024_06_11 = {
|
||||
name: "Default",
|
||||
timeZone: "America/Cancun",
|
||||
isDefault: true,
|
||||
availability: [
|
||||
{
|
||||
days: ["Monday", "Tuesday", "Wednesday", "Thursday"],
|
||||
startTime: "09:00",
|
||||
endTime: "17:00",
|
||||
},
|
||||
{
|
||||
days: ["Friday"],
|
||||
startTime: "11:00",
|
||||
endTime: "12:00",
|
||||
},
|
||||
],
|
||||
overrides: [],
|
||||
};
|
||||
|
||||
const result = transformAtomScheduleForApi(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
import type {
|
||||
ScheduleAvailabilityInput_2024_06_11,
|
||||
UpdateScheduleInput_2024_06_11,
|
||||
WeekDay,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { AvailabilityFormValues } from "../types";
|
||||
|
||||
export function transformAtomScheduleForApi(body: AvailabilityFormValues): UpdateScheduleInput_2024_06_11 {
|
||||
const { name, schedule, dateOverrides, timeZone, isDefault } = body;
|
||||
|
||||
const overrides =
|
||||
dateOverrides.flatMap(
|
||||
(dateOverridesRanges) =>
|
||||
dateOverridesRanges?.ranges?.map((range) => transfromAtomOverrideForApi(range)) ?? []
|
||||
) ?? [];
|
||||
|
||||
const availability = formatScheduleTime(schedule);
|
||||
|
||||
return { name, timeZone, isDefault, availability, overrides };
|
||||
}
|
||||
|
||||
type AtomDateOverride = {
|
||||
start: Date;
|
||||
end: Date;
|
||||
};
|
||||
|
||||
function transfromAtomOverrideForApi(override: AtomDateOverride) {
|
||||
const date = `${override.start.getUTCFullYear()}-${(override.start.getUTCMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0")}-${override.start.getUTCDate().toString().padStart(2, "0")}`;
|
||||
|
||||
return {
|
||||
date,
|
||||
startTime: padHoursMinutesWithZeros(`${override.start.getUTCHours()}:${override.start.getUTCMinutes()}`),
|
||||
endTime: padHoursMinutesWithZeros(`${override.end.getUTCHours()}:${override.end.getUTCMinutes()}`),
|
||||
};
|
||||
}
|
||||
|
||||
function padHoursMinutesWithZeros(hhMM: string) {
|
||||
const [hours, minutes] = hhMM.split(":");
|
||||
|
||||
const formattedHours = hours.padStart(2, "0");
|
||||
const formattedMinutes = minutes.padStart(2, "0");
|
||||
|
||||
return `${formattedHours}:${formattedMinutes}`;
|
||||
}
|
||||
|
||||
function formatScheduleTime(
|
||||
weekSchedule: AvailabilityFormValues["schedule"]
|
||||
): UpdateScheduleInput_2024_06_11["availability"] {
|
||||
const daysOfWeek: WeekDay[] = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
];
|
||||
|
||||
const formattedSchedule = weekSchedule.map((daySchedule, index) =>
|
||||
daySchedule.map((event) => ({
|
||||
startTime: convertToHHMM(event.start.toISOString()),
|
||||
endTime: convertToHHMM(event.end.toISOString()),
|
||||
days: [daysOfWeek[index]],
|
||||
}))
|
||||
);
|
||||
|
||||
const timeMap: { [key: string]: ScheduleAvailabilityInput_2024_06_11 } = {};
|
||||
|
||||
formattedSchedule.flat().forEach((event) => {
|
||||
const timeKey = `${event.startTime}-${event.endTime}`;
|
||||
if (!timeMap[timeKey]) {
|
||||
timeMap[timeKey] = { startTime: event.startTime, endTime: event.endTime, days: [] };
|
||||
}
|
||||
timeMap[timeKey].days.push(...event.days);
|
||||
});
|
||||
|
||||
return Object.values(timeMap);
|
||||
}
|
||||
|
||||
function convertToHHMM(isoDate: string): string {
|
||||
const date = new Date(isoDate);
|
||||
const hours = date.getUTCHours().toString().padStart(2, "0");
|
||||
const minutes = date.getUTCMinutes().toString().padStart(2, "0");
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
+15
-20
@@ -1,25 +1,18 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import type { ScheduleLabelsType } from "@calcom/features/schedules/components/Schedule";
|
||||
import type {
|
||||
ApiErrorResponse,
|
||||
ApiResponse,
|
||||
ScheduleOutput_2024_06_11,
|
||||
UpdateScheduleInput_2024_06_11,
|
||||
} from "@calcom/platform-types";
|
||||
import type { UpdateScheduleResponse } from "@calcom/lib/schedules/updateSchedule";
|
||||
import type { ApiErrorResponse, ApiResponse, UpdateScheduleInput_2024_06_11 } from "@calcom/platform-types";
|
||||
|
||||
import { useAtomSchedule } from "../../hooks/schedules/useAtomSchedule";
|
||||
import { useAtomUpdateSchedule } from "../../hooks/schedules/useAtomUpdateSchedule";
|
||||
import useDeleteSchedule from "../../hooks/schedules/useDeleteSchedule";
|
||||
import { useSchedule } from "../../hooks/schedules/useSchedule";
|
||||
import { useSchedules } from "../../hooks/schedules/useSchedules";
|
||||
import useUpdateSchedule from "../../hooks/schedules/useUpdateSchedule";
|
||||
import { useMe } from "../../hooks/useMe";
|
||||
import { AtomsWrapper } from "../../src/components/atoms-wrapper";
|
||||
import { useToast } from "../../src/components/ui/use-toast";
|
||||
import type { Availability } from "../AvailabilitySettings";
|
||||
import type { CustomClassNames } from "../AvailabilitySettings";
|
||||
import { AvailabilitySettings } from "../AvailabilitySettings";
|
||||
import { transformApiScheduleForAtom } from "../atom-api-transformers/transformApiScheduleForAtom";
|
||||
import { transformAtomScheduleForApi } from "../atom-api-transformers/transformAtomScheduleForApi";
|
||||
import type { AvailabilityFormValues } from "../types";
|
||||
|
||||
type AvailabilitySettingsPlatformWrapperProps = {
|
||||
@@ -28,7 +21,7 @@ type AvailabilitySettingsPlatformWrapperProps = {
|
||||
tooltips: Partial<ScheduleLabelsType>;
|
||||
};
|
||||
customClassNames?: Partial<CustomClassNames>;
|
||||
onUpdateSuccess?: (res: ApiResponse<ScheduleOutput_2024_06_11>) => void;
|
||||
onUpdateSuccess?: (res: ApiResponse<UpdateScheduleResponse>) => void;
|
||||
onUpdateError?: (err: ApiErrorResponse) => void;
|
||||
onDeleteSuccess?: (res: ApiResponse) => void;
|
||||
onDeleteError?: (err: ApiErrorResponse) => void;
|
||||
@@ -62,10 +55,8 @@ export const AvailabilitySettingsPlatformWrapper = ({
|
||||
noScheduleChildren,
|
||||
loadingStateChildren,
|
||||
}: AvailabilitySettingsPlatformWrapperProps) => {
|
||||
const { isLoading, data: schedule } = useSchedule(id);
|
||||
const { data: schedules } = useSchedules();
|
||||
const { isLoading, data: atomSchedule } = useAtomSchedule(id);
|
||||
const { data: me } = useMe();
|
||||
const atomSchedule = transformApiScheduleForAtom(me?.data, schedule, schedules?.length || 0);
|
||||
const { timeFormat } = me?.data || { timeFormat: null };
|
||||
const { toast } = useToast();
|
||||
|
||||
@@ -88,7 +79,7 @@ export const AvailabilitySettingsPlatformWrapper = ({
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: updateSchedule, isPending: isSavingInProgress } = useUpdateSchedule({
|
||||
const { mutate: updateSchedule, isPending: isSavingInProgress } = useAtomUpdateSchedule({
|
||||
onSuccess: (res) => {
|
||||
onUpdateSuccess?.(res);
|
||||
if (!disableToasts) {
|
||||
@@ -112,16 +103,20 @@ export const AvailabilitySettingsPlatformWrapper = ({
|
||||
};
|
||||
|
||||
const handleUpdate = async (id: number, body: AvailabilityFormValues) => {
|
||||
const updateBody = transformAtomScheduleForApi(body);
|
||||
|
||||
let canUpdate = true;
|
||||
|
||||
if (onBeforeUpdate) {
|
||||
canUpdate = await onBeforeUpdate(updateBody);
|
||||
canUpdate = await onBeforeUpdate(body);
|
||||
}
|
||||
|
||||
if (canUpdate) {
|
||||
updateSchedule({ id, ...updateBody });
|
||||
updateSchedule({
|
||||
scheduleId: id,
|
||||
body: {
|
||||
...body,
|
||||
dateOverrides: body.dateOverrides.flatMap((override) => override.ranges),
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,14 +14,10 @@ import { useTimePreferences } from "@calcom/features/bookings/lib";
|
||||
import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule";
|
||||
import { getRoutedTeamMemberIdsFromSearchParams } from "@calcom/lib/bookings/getRoutedTeamMemberIdsFromSearchParams";
|
||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/platform-libraries";
|
||||
import { BookerLayouts } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import {
|
||||
transformApiEventTypeForAtom,
|
||||
transformApiTeamEventTypeForAtom,
|
||||
} from "../event-types/atom-api-transformers/transformApiEventTypeForAtom";
|
||||
import { useCreateBooking } from "../hooks/bookings/useCreateBooking";
|
||||
import { useCreateInstantBooking } from "../hooks/bookings/useCreateInstantBooking";
|
||||
import { useCreateRecurringBooking } from "../hooks/bookings/useCreateRecurringBooking";
|
||||
@@ -30,8 +26,7 @@ import {
|
||||
QUERY_KEY as BOOKING_RESCHEDULE_KEY,
|
||||
} from "../hooks/bookings/useGetBookingForReschedule";
|
||||
import { useHandleBookEvent } from "../hooks/bookings/useHandleBookEvent";
|
||||
import { useEventType } from "../hooks/event-types/public/useEventType";
|
||||
import { useTeamEventType } from "../hooks/event-types/public/useTeamEventType";
|
||||
import { useAtomGetPublicEvent } from "../hooks/event-types/public/useAtomGetPublicEvent";
|
||||
import { useAtomsContext } from "../hooks/useAtomsContext";
|
||||
import { useAvailableSlots } from "../hooks/useAvailableSlots";
|
||||
import { useCalendarsBusyTimes } from "../hooks/useCalendarsBusyTimes";
|
||||
@@ -74,6 +69,7 @@ export const BookerPlatformWrapper = (
|
||||
const bookingData = useBookerStore((state) => state.bookingData);
|
||||
const setSelectedTimeslot = useBookerStore((state) => state.setSelectedTimeslot);
|
||||
const setSelectedMonth = useBookerStore((state) => state.setMonth);
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
|
||||
const [isOverlayCalendarEnabled, setIsOverlayCalendarEnabled] = useState(
|
||||
Boolean(localStorage?.getItem?.("overlayCalendarSwitchDefault"))
|
||||
@@ -147,61 +143,13 @@ export const BookerPlatformWrapper = (
|
||||
return getUsernameList(username ?? "").length > 1;
|
||||
}, [username]);
|
||||
|
||||
const { isSuccess, isError, isPending, data } = useEventType(username, props.eventSlug, props.isTeamEvent);
|
||||
const {
|
||||
isSuccess: isTeamSuccess,
|
||||
isError: isTeamError,
|
||||
isPending: isTeamPending,
|
||||
data: teamEventTypeData,
|
||||
} = useTeamEventType(teamId, props.eventSlug, props.isTeamEvent, props.hostsLimit);
|
||||
|
||||
const event = useMemo(() => {
|
||||
if (props.isTeamEvent && !isTeamPending && teamId && teamEventTypeData && teamEventTypeData.length > 0) {
|
||||
return {
|
||||
isSuccess: isTeamSuccess,
|
||||
isError: isTeamError,
|
||||
isPending: isTeamPending,
|
||||
data:
|
||||
teamEventTypeData && teamEventTypeData.length > 0
|
||||
? transformApiTeamEventTypeForAtom(
|
||||
teamEventTypeData[0],
|
||||
props.entity,
|
||||
props.defaultFormValues,
|
||||
!!props.hostsLimit
|
||||
)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
isSuccess,
|
||||
isError,
|
||||
isPending,
|
||||
data:
|
||||
data && data.length > 0
|
||||
? transformApiEventTypeForAtom(data[0], props.entity, props.defaultFormValues, !!props.hostsLimit)
|
||||
: undefined,
|
||||
};
|
||||
}, [
|
||||
props.isTeamEvent,
|
||||
const event = useAtomGetPublicEvent({
|
||||
username,
|
||||
eventSlug: props.eventSlug,
|
||||
isTeamEvent: props.isTeamEvent,
|
||||
teamId,
|
||||
props.entity,
|
||||
teamEventTypeData,
|
||||
isSuccess,
|
||||
isError,
|
||||
isPending,
|
||||
data,
|
||||
isTeamPending,
|
||||
isTeamSuccess,
|
||||
isTeamError,
|
||||
props.hostsLimit,
|
||||
]);
|
||||
|
||||
if (isDynamic && props.duration && event.data) {
|
||||
// note(Lauris): Mandatory - In case of "dynamic" event type default event duration returned by the API is 30,
|
||||
// but we are re-using the dynamic event type as a team event, so we must set the event length to whatever the event length is.
|
||||
event.data.length = props.duration;
|
||||
}
|
||||
selectedDuration,
|
||||
});
|
||||
|
||||
const bookerLayout = useBookerLayout(event.data?.profile?.bookerLayouts);
|
||||
useInitializeBookerStore({
|
||||
@@ -209,7 +157,7 @@ export const BookerPlatformWrapper = (
|
||||
teamMemberEmail,
|
||||
crmAppSlug,
|
||||
crmOwnerRecordType,
|
||||
eventId: event.data?.id,
|
||||
eventId: event?.data?.id,
|
||||
rescheduleUid: props.rescheduleUid ?? null,
|
||||
bookingUid: props.bookingUid ?? null,
|
||||
layout: layout,
|
||||
@@ -225,8 +173,6 @@ export const BookerPlatformWrapper = (
|
||||
const month = useBookerStore((state) => state.month);
|
||||
const eventSlug = useBookerStore((state) => state.eventSlug);
|
||||
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
|
||||
const { data: session } = useMe();
|
||||
const hasSession = !!session;
|
||||
const { name: defaultName, guests: defaultGuests, ...restFormValues } = props.defaultFormValues ?? {};
|
||||
@@ -323,7 +269,7 @@ export const BookerPlatformWrapper = (
|
||||
Boolean(teamId || username) &&
|
||||
Boolean(month) &&
|
||||
Boolean(timezone) &&
|
||||
(props.isTeamEvent ? !isTeamPending : !isPending) &&
|
||||
!event?.isPending &&
|
||||
Boolean(event?.data?.id),
|
||||
orgSlug: props.entity?.orgSlug ?? undefined,
|
||||
eventTypeSlug: isDynamic ? "dynamic" : eventSlug || "",
|
||||
@@ -331,7 +277,7 @@ export const BookerPlatformWrapper = (
|
||||
});
|
||||
|
||||
const bookerForm = useBookingForm({
|
||||
event: event.data,
|
||||
event: event?.data,
|
||||
sessionEmail:
|
||||
session?.data?.email && clientId
|
||||
? session.data.email.replace(`+${clientId}`, "")
|
||||
@@ -356,8 +302,8 @@ export const BookerPlatformWrapper = (
|
||||
schedule.refetch();
|
||||
props.onCreateBookingSuccess?.(data);
|
||||
|
||||
if (!preventEventTypeRedirect && !!event.data?.successRedirectUrl) {
|
||||
window.location.href = event.data.successRedirectUrl;
|
||||
if (!preventEventTypeRedirect && !!event?.data?.successRedirectUrl) {
|
||||
window.location.href = event?.data?.successRedirectUrl;
|
||||
}
|
||||
},
|
||||
onError: props.onCreateBookingError,
|
||||
@@ -376,8 +322,8 @@ export const BookerPlatformWrapper = (
|
||||
schedule.refetch();
|
||||
props.onCreateRecurringBookingSuccess?.(data);
|
||||
|
||||
if (!!event.data?.successRedirectUrl) {
|
||||
window.location.href = event.data.successRedirectUrl;
|
||||
if (!!event?.data?.successRedirectUrl) {
|
||||
window.location.href = event?.data?.successRedirectUrl;
|
||||
}
|
||||
},
|
||||
onError: props.onCreateRecurringBookingError,
|
||||
|
||||
@@ -3,7 +3,7 @@ import type React from "react";
|
||||
import type { BookerProps } from "@calcom/features/bookings/Booker";
|
||||
import type { BookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { Timezone } from "@calcom/features/bookings/Booker/types";
|
||||
import type { BookingResponse } from "@calcom/platform-libraries";
|
||||
import type { BookingResponse } from "@calcom/features/bookings/types";
|
||||
import type {
|
||||
ApiSuccessResponse,
|
||||
ApiErrorResponse,
|
||||
|
||||
@@ -4,11 +4,11 @@ import { useState, useEffect, useMemo } from "react";
|
||||
|
||||
import { SingleValueComponent } from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import { OptionComponent } from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/platform-libraries";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
import { getPlaceholderContent } from "../lib/getPlaceholderContent";
|
||||
|
||||
|
||||
-407
@@ -1,407 +0,0 @@
|
||||
import { defaultEvents } from "@calcom/lib/defaultEvents";
|
||||
import type { SystemField } from "@calcom/lib/event-types/transformers";
|
||||
import {
|
||||
transformTeamLocationsApiToInternal,
|
||||
transformBookingFieldsApiToInternal,
|
||||
systemBeforeFieldName,
|
||||
systemBeforeFieldEmail,
|
||||
systemBeforeFieldLocation,
|
||||
systemAfterFieldRescheduleReason,
|
||||
transformRecurrenceApiToInternal,
|
||||
transformIntervalLimitsApiToInternal,
|
||||
transformSeatsApiToInternal,
|
||||
transformEventColorsApiToInternal,
|
||||
transformConfirmationPolicyApiToInternal,
|
||||
transformFutureBookingLimitsApiToInternal,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import type {
|
||||
EmailDefaultFieldOutput_2024_06_14,
|
||||
EventTypeOutput_2024_06_14,
|
||||
InputLocation_2024_06_14,
|
||||
KnownBookingField_2024_06_14,
|
||||
NameDefaultFieldOutput_2024_06_14,
|
||||
TeamEventTypeOutput_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
import {
|
||||
bookerLayoutOptions,
|
||||
BookerLayouts,
|
||||
bookerLayouts as bookerLayoutsSchema,
|
||||
userMetadata as userMetadataSchema,
|
||||
eventTypeBookingFields,
|
||||
EventTypeMetaDataSchema,
|
||||
} from "@calcom/prisma/zod-utils";
|
||||
|
||||
import type { BookerPlatformWrapperAtomProps } from "../../booker/types";
|
||||
|
||||
export function transformApiEventTypeForAtom(
|
||||
eventType: Omit<EventTypeOutput_2024_06_14, "ownerId"> & { bannerUrl?: string },
|
||||
entity: BookerPlatformWrapperAtomProps["entity"] | undefined,
|
||||
defaultFormValues: BookerPlatformWrapperAtomProps["defaultFormValues"] | undefined,
|
||||
limitHosts = false
|
||||
) {
|
||||
const {
|
||||
lengthInMinutes,
|
||||
lengthInMinutesOptions,
|
||||
locations,
|
||||
bookingFields,
|
||||
users,
|
||||
recurrence,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
seats,
|
||||
color,
|
||||
confirmationPolicy,
|
||||
customName,
|
||||
useDestinationCalendarEmail,
|
||||
bookingWindow,
|
||||
...rest
|
||||
} = eventType;
|
||||
|
||||
const isDefault = isDefaultEvent(rest.title);
|
||||
const user = users[0];
|
||||
|
||||
const confirmationPolicyTransformed = transformConfirmationPolicyApiToInternal(confirmationPolicy);
|
||||
const defaultEventBookerLayouts = {
|
||||
enabledLayouts: [...bookerLayoutOptions],
|
||||
defaultLayout: BookerLayouts.MONTH_VIEW,
|
||||
};
|
||||
const firstUsersMetadata = userMetadataSchema.parse(user.metadata || {});
|
||||
const bookerLayouts = bookerLayoutsSchema.parse(
|
||||
firstUsersMetadata?.defaultBookerLayouts || defaultEventBookerLayouts
|
||||
);
|
||||
const metadata = EventTypeMetaDataSchema.parse(eventType.metadata);
|
||||
const usersTransformed = users.map((user) => ({
|
||||
...user,
|
||||
metadata: undefined,
|
||||
bookerUrl: getBookerBaseUrlSync(null),
|
||||
profile: {
|
||||
username: user.username || "",
|
||||
name: user.name,
|
||||
weekStart: user.weekStart,
|
||||
image: "",
|
||||
brandColor: user.brandColor,
|
||||
darkBrandColor: user.darkBrandColor,
|
||||
theme: null,
|
||||
organization: null,
|
||||
id: user.id,
|
||||
organizationId: null,
|
||||
userId: user.id,
|
||||
upId: `usr-${user.id}`,
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
...rest,
|
||||
length: lengthInMinutes,
|
||||
locations: getLocations(locations),
|
||||
bookingFields: getBookingFields(bookingFields, defaultFormValues),
|
||||
isDefault,
|
||||
isDynamic: false,
|
||||
profile: {
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
weekStart: user.weekStart,
|
||||
image: "",
|
||||
brandColor: user.brandColor,
|
||||
darkBrandColor: user.darkBrandColor,
|
||||
theme: null,
|
||||
bookerLayouts,
|
||||
},
|
||||
entity: entity
|
||||
? {
|
||||
...entity,
|
||||
orgSlug: entity.orgSlug || null,
|
||||
teamSlug: entity.teamSlug || null,
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
name: entity.name || null,
|
||||
logoUrl: entity.logoUrl || undefined,
|
||||
}
|
||||
: {
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
considerUnpublished: false,
|
||||
orgSlug: null,
|
||||
teamSlug: null,
|
||||
name: null,
|
||||
logoUrl: undefined,
|
||||
},
|
||||
hosts: [],
|
||||
subsetOfHosts: [],
|
||||
users: !limitHosts ? usersTransformed : undefined,
|
||||
subsetOfUsers: usersTransformed,
|
||||
bookingLimits: bookingLimitsCount ? transformIntervalLimitsApiToInternal(bookingLimitsCount) : undefined,
|
||||
durationLimits: bookingLimitsDuration
|
||||
? transformIntervalLimitsApiToInternal(bookingLimitsDuration)
|
||||
: undefined,
|
||||
|
||||
metadata: {
|
||||
...metadata,
|
||||
requiresConfirmationThreshold:
|
||||
confirmationPolicyTransformed?.requiresConfirmationThreshold ?? undefined,
|
||||
multipleDuration: lengthInMinutesOptions,
|
||||
},
|
||||
|
||||
requiresConfirmation: confirmationPolicyTransformed?.requiresConfirmation ?? undefined,
|
||||
requiresConfirmationWillBlockSlot:
|
||||
confirmationPolicyTransformed?.requiresConfirmationWillBlockSlot ?? undefined,
|
||||
|
||||
eventTypeColor: transformEventColorsApiToInternal(color),
|
||||
recurringEvent: recurrence ? transformRecurrenceApiToInternal(recurrence) : null,
|
||||
...transformSeatsApiToInternal(seats),
|
||||
eventName: customName,
|
||||
useEventTypeDestinationCalendarEmail: useDestinationCalendarEmail,
|
||||
...getBookingWindow(bookingWindow),
|
||||
};
|
||||
}
|
||||
|
||||
export function transformApiTeamEventTypeForAtom(
|
||||
eventType: TeamEventTypeOutput_2024_06_14,
|
||||
entity: BookerPlatformWrapperAtomProps["entity"] | undefined,
|
||||
defaultFormValues: BookerPlatformWrapperAtomProps["defaultFormValues"] | undefined,
|
||||
limitHosts = false
|
||||
) {
|
||||
const {
|
||||
lengthInMinutes,
|
||||
lengthInMinutesOptions,
|
||||
locations,
|
||||
hosts,
|
||||
bookingFields,
|
||||
recurrence,
|
||||
team,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
seats,
|
||||
color,
|
||||
confirmationPolicy,
|
||||
customName,
|
||||
useDestinationCalendarEmail,
|
||||
bookingWindow,
|
||||
...rest
|
||||
} = eventType;
|
||||
|
||||
const metadata = EventTypeMetaDataSchema.parse(eventType.metadata);
|
||||
|
||||
const isDefault = isDefaultEvent(rest.title);
|
||||
|
||||
const confirmationPolicyTransformed = transformConfirmationPolicyApiToInternal(confirmationPolicy);
|
||||
const defaultEventBookerLayouts = {
|
||||
enabledLayouts: [...bookerLayoutOptions],
|
||||
defaultLayout: BookerLayouts.MONTH_VIEW,
|
||||
};
|
||||
const firstUsersMetadata = userMetadataSchema.parse({});
|
||||
const bookerLayouts = bookerLayoutsSchema.parse(
|
||||
firstUsersMetadata?.defaultBookerLayouts || defaultEventBookerLayouts
|
||||
);
|
||||
|
||||
const hostTransformed = hosts.map((host) => ({
|
||||
user: {
|
||||
id: host.userId,
|
||||
avatarUrl: null,
|
||||
name: host.name,
|
||||
username: "",
|
||||
metadata: {},
|
||||
darkBrandColor: null,
|
||||
brandColor: null,
|
||||
theme: null,
|
||||
weekStart: "Sunday",
|
||||
},
|
||||
}));
|
||||
|
||||
const usersTransformed = hosts.map((host) => ({
|
||||
...host,
|
||||
metadata: undefined,
|
||||
bookerUrl: getBookerBaseUrlSync(null),
|
||||
profile: {
|
||||
username: "",
|
||||
name: host.name,
|
||||
weekStart: "Sunday",
|
||||
image: "",
|
||||
brandColor: null,
|
||||
darkBrandColor: null,
|
||||
theme: null,
|
||||
organization: null,
|
||||
id: host.userId,
|
||||
organizationId: null,
|
||||
userId: host.userId,
|
||||
upId: `usr-${host.userId}`,
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
...rest,
|
||||
length: lengthInMinutes,
|
||||
locations: getLocations(locations),
|
||||
bookingFields: getBookingFields(bookingFields, defaultFormValues),
|
||||
isDefault,
|
||||
isDynamic: false,
|
||||
profile: {
|
||||
username: team?.slug ?? "team",
|
||||
name: team?.name,
|
||||
weekStart: team?.weekStart ?? "Sunday",
|
||||
image: team?.logoUrl,
|
||||
brandColor: team?.brandColor ?? null,
|
||||
darkBrandColor: team?.darkBrandColor ?? null,
|
||||
theme: team?.theme ?? null,
|
||||
bookerLayouts,
|
||||
},
|
||||
bannerUrl: team?.bannerUrl,
|
||||
entity: entity
|
||||
? {
|
||||
...entity,
|
||||
orgSlug: entity.orgSlug || null,
|
||||
teamSlug: entity.teamSlug || null,
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
name: entity.name || null,
|
||||
logoUrl: entity.logoUrl || undefined,
|
||||
}
|
||||
: {
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
considerUnpublished: false,
|
||||
orgSlug: null,
|
||||
teamSlug: team?.slug,
|
||||
name: team?.name,
|
||||
logoUrl: team?.logoUrl,
|
||||
},
|
||||
hosts: !limitHosts ? hostTransformed : undefined,
|
||||
subsetOfHosts: hostTransformed,
|
||||
users: !limitHosts ? usersTransformed : undefined,
|
||||
subsetOfUsers: usersTransformed,
|
||||
recurringEvent: recurrence ? transformRecurrenceApiToInternal(recurrence) : null,
|
||||
bookingLimits: bookingLimitsCount ? transformIntervalLimitsApiToInternal(bookingLimitsCount) : undefined,
|
||||
durationLimits: bookingLimitsDuration
|
||||
? transformIntervalLimitsApiToInternal(bookingLimitsDuration)
|
||||
: undefined,
|
||||
|
||||
metadata: {
|
||||
...metadata,
|
||||
requiresConfirmationThreshold:
|
||||
confirmationPolicyTransformed?.requiresConfirmationThreshold ?? undefined,
|
||||
multipleDuration: lengthInMinutesOptions,
|
||||
},
|
||||
|
||||
requiresConfirmation: confirmationPolicyTransformed?.requiresConfirmation ?? undefined,
|
||||
requiresConfirmationWillBlockSlot:
|
||||
confirmationPolicyTransformed?.requiresConfirmationWillBlockSlot ?? undefined,
|
||||
|
||||
eventTypeColor: transformEventColorsApiToInternal(color),
|
||||
...transformSeatsApiToInternal(seats),
|
||||
eventName: customName,
|
||||
useEventTypeDestinationCalendarEmail: useDestinationCalendarEmail,
|
||||
...getBookingWindow(bookingWindow),
|
||||
};
|
||||
}
|
||||
|
||||
function isDefaultEvent(eventSlug: string) {
|
||||
const foundInDefaults = defaultEvents.find((obj) => {
|
||||
return obj.slug === eventSlug;
|
||||
});
|
||||
return !!foundInDefaults;
|
||||
}
|
||||
|
||||
function getLocations(locations: EventTypeOutput_2024_06_14["locations"]) {
|
||||
const transformed = transformTeamLocationsApiToInternal(
|
||||
locations.filter((location) => isAtomSupportedLocation(location))
|
||||
);
|
||||
|
||||
const withPrivateHidden = transformed.map((location) => {
|
||||
const { type } = location;
|
||||
|
||||
switch (type) {
|
||||
case "inPerson":
|
||||
return location?.displayLocationPublicly ? location : { ...location, address: "" };
|
||||
case "link":
|
||||
return location?.displayLocationPublicly ? location : { ...location, link: "" };
|
||||
case "userPhone":
|
||||
return location?.displayLocationPublicly
|
||||
? location
|
||||
: {
|
||||
...location,
|
||||
hostPhoneNumber: "",
|
||||
};
|
||||
default:
|
||||
return location;
|
||||
}
|
||||
});
|
||||
|
||||
return withPrivateHidden;
|
||||
}
|
||||
|
||||
function isAtomSupportedLocation(
|
||||
location: EventTypeOutput_2024_06_14["locations"][number]
|
||||
): location is InputLocation_2024_06_14 {
|
||||
const supportedIntegrations = ["cal-video", "google-meet", "office365-video", "zoom"];
|
||||
|
||||
return (
|
||||
location.type === "address" ||
|
||||
location.type === "attendeeAddress" ||
|
||||
location.type === "link" ||
|
||||
location.type === "phone" ||
|
||||
location.type === "attendeePhone" ||
|
||||
location.type === "attendeeDefined" ||
|
||||
location.type === "organizersDefaultApp" ||
|
||||
(location.type === "integration" && supportedIntegrations.includes(location.integration))
|
||||
);
|
||||
}
|
||||
|
||||
function getBookingFields(
|
||||
bookingFields: EventTypeOutput_2024_06_14["bookingFields"],
|
||||
defaultFormValues: BookerPlatformWrapperAtomProps["defaultFormValues"] | undefined
|
||||
) {
|
||||
const transformedBookingFields = transformBookingFieldsApiToInternal(
|
||||
bookingFields.filter((field) => isKnownField(field))
|
||||
);
|
||||
|
||||
const hasNameField = transformedBookingFields.some((field) => field.name === "name");
|
||||
const hasEmailField = transformedBookingFields.some((field) => field.name === "email");
|
||||
const hasLocationField = transformedBookingFields.some((field) => field.name === "location");
|
||||
const hasRescheduleReasonField = transformedBookingFields.some(
|
||||
(field) => field.name === "rescheduleReason"
|
||||
);
|
||||
|
||||
const systemBeforeFields: SystemField[] = [];
|
||||
if (!hasNameField) {
|
||||
systemBeforeFields.push(systemBeforeFieldName);
|
||||
}
|
||||
if (!hasEmailField) {
|
||||
systemBeforeFields.push(systemBeforeFieldEmail);
|
||||
}
|
||||
if (!hasLocationField) {
|
||||
systemBeforeFields.push(systemBeforeFieldLocation);
|
||||
}
|
||||
const systemAfterFields: SystemField[] = [];
|
||||
if (!hasRescheduleReasonField) {
|
||||
systemAfterFields.push(systemAfterFieldRescheduleReason);
|
||||
}
|
||||
|
||||
const fieldsWithSystem = [...systemBeforeFields, ...transformedBookingFields, ...systemAfterFields];
|
||||
|
||||
// note(Lauris): in web app booking form values can be passed as url query params, but booker atom does not accept booking field values via url,
|
||||
// so defaultFormValues act as a way to prefill booking form fields, and if the field in database has disableOnPrefill=true and value passed then its read only.
|
||||
const defaultFormValuesKeys = defaultFormValues ? Object.keys(defaultFormValues) : [];
|
||||
if (defaultFormValuesKeys.length) {
|
||||
for (const field of fieldsWithSystem) {
|
||||
if (defaultFormValuesKeys.includes(field.name) && field.disableOnPrefill) {
|
||||
field.editable = "user-readonly";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(fieldsWithSystem);
|
||||
}
|
||||
|
||||
function isKnownField(
|
||||
field: EventTypeOutput_2024_06_14["bookingFields"][number]
|
||||
): field is KnownBookingField_2024_06_14 {
|
||||
return field.type !== "unknown";
|
||||
}
|
||||
|
||||
function getBookingWindow(inputBookingWindow: EventTypeOutput_2024_06_14["bookingWindow"]) {
|
||||
const res = transformFutureBookingLimitsApiToInternal(inputBookingWindow);
|
||||
return !!res ? res : {};
|
||||
}
|
||||
|
||||
function isDefaultEditableField(
|
||||
field: EventTypeOutput_2024_06_14["bookingFields"][number]
|
||||
): field is NameDefaultFieldOutput_2024_06_14 | EmailDefaultFieldOutput_2024_06_14 {
|
||||
return field.type === "name" || field.type === "email";
|
||||
}
|
||||
+2
-6
@@ -6,8 +6,7 @@ import type { EventTypeSetup, FormValues } from "@calcom/features/eventtypes/lib
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
|
||||
import type { Availability } from "../../availability/AvailabilitySettings";
|
||||
import { transformApiScheduleForAtom } from "../../availability/atom-api-transformers/transformApiScheduleForAtom";
|
||||
import { useSchedule } from "../../hooks/schedules/useSchedule";
|
||||
import { useAtomSchedule } from "../../hooks/schedules/useAtomSchedule";
|
||||
import { useSchedules } from "../../hooks/schedules/useSchedules";
|
||||
import { useTeamMembers } from "../../hooks/teams/useTeamMembers";
|
||||
import { useAtomHostSchedules } from "../hooks/useAtomHostSchedules";
|
||||
@@ -28,13 +27,10 @@ const EventAvailabilityTabPlatformWrapper = ({
|
||||
const formMethods = useFormContext<FormValues>();
|
||||
const scheduleId = formMethods.watch("schedule");
|
||||
|
||||
const { isLoading: isSchedulePending, data: scheduleQueryData } = useSchedule(
|
||||
scheduleId || user?.defaultScheduleId || undefined
|
||||
);
|
||||
const { isLoading: isSchedulePending, data: atomSchedule } = useAtomSchedule(scheduleId?.toString());
|
||||
|
||||
const { data: schedulesQueryData, isLoading: isSchedulesPending } = useSchedules();
|
||||
|
||||
const atomSchedule = transformApiScheduleForAtom(user, scheduleQueryData, schedulesQueryData?.length || 0);
|
||||
const hostSchedulesQuery = useAtomHostSchedules;
|
||||
const { data: teamMembers } = useTeamMembers({ teamId });
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import type { BookingResponse } from "@calcom/features/bookings/types";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { BookingResponse } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiErrorResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
import type { BookingCreateBody } from "@calcom/prisma/zod/custom/booking";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import type { BookingResponse } from "@calcom/features/bookings/types";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { BookingResponse } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiErrorResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
import type { BookingCreateBody } from "@calcom/prisma/zod/custom/booking";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import type { BookingResponse, RecurringBookingCreateBody } from "@calcom/features/bookings/types";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { BookingResponse, RecurringBookingCreateBody } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiErrorResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import type { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { getBookingForReschedule } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
|
||||
import type { PublicEventType } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
import { useAtomsContext } from "../../../hooks/useAtomsContext";
|
||||
|
||||
export const QUERY_KEY = "get-public-event";
|
||||
export type UsePublicEventReturnType = ReturnType<typeof useAtomGetPublicEvent>;
|
||||
|
||||
type Props = {
|
||||
username: string;
|
||||
eventSlug: string;
|
||||
isTeamEvent?: boolean;
|
||||
teamId?: number;
|
||||
selectedDuration: number | null;
|
||||
};
|
||||
|
||||
export const useAtomGetPublicEvent = ({ username, eventSlug, isTeamEvent, teamId, selectedDuration }: Props) => {
|
||||
|
||||
const { organizationId } = useAtomsContext();
|
||||
|
||||
const isDynamic = useMemo(() => {
|
||||
return getUsernameList(username ?? "").length > 1;
|
||||
}, [username]);
|
||||
|
||||
const pathname = `/atoms/${V2_ENDPOINTS.eventTypes}/${eventSlug}/public`;
|
||||
|
||||
const event = useQuery({
|
||||
queryKey: [QUERY_KEY, username, eventSlug, isTeamEvent, teamId, organizationId],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<PublicEventType>>(pathname, {
|
||||
params: {
|
||||
isTeamEvent,
|
||||
teamId,
|
||||
orgId: organizationId,
|
||||
username: getUsernameList(username?? "").join(",")
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
if (isDynamic && selectedDuration && res.data.data) {
|
||||
// note(Lauris): Mandatory - In case of "dynamic" event type default event duration returned by the API is 30,
|
||||
// but we are re-using the dynamic event type as a team event, so we must set the event length to whatever the event length is.
|
||||
res.data.data.length = selectedDuration;
|
||||
}
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return event;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import type { FindDetailedScheduleByIdReturnType } from "@calcom/lib/server/repository/schedule";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-atom-schedule";
|
||||
|
||||
export const useAtomSchedule = (scheduleId?: string, isManagedEventType?: boolean) => {
|
||||
const pathname = "atoms/schedules";
|
||||
|
||||
const { isLoading, error, data } = useQuery({
|
||||
queryKey: [QUERY_KEY, scheduleId, isManagedEventType],
|
||||
queryFn: () => {
|
||||
return http
|
||||
.get<ApiResponse<FindDetailedScheduleByIdReturnType | null>>(pathname, {
|
||||
params: { scheduleId, isManagedEventType },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error?.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return { isLoading, error, data };
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import type { UpdateScheduleResponse } from "@calcom/lib/schedules/updateSchedule";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ApiResponse, ApiErrorResponse, UpdateAtomScheduleDto } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
import { QUERY_KEY as ScheduleQueryKey } from "./useAtomSchedule";
|
||||
|
||||
interface IUseAtomUpdateScheduleOptions {
|
||||
onSuccess?: (res: ApiResponse<UpdateScheduleResponse>) => void;
|
||||
onError?: (err: ApiErrorResponse) => void;
|
||||
}
|
||||
|
||||
export const useAtomUpdateSchedule = (
|
||||
{ onSuccess, onError }: IUseAtomUpdateScheduleOptions = {
|
||||
onSuccess: () => {
|
||||
return;
|
||||
},
|
||||
onError: () => {
|
||||
return;
|
||||
},
|
||||
}
|
||||
) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<
|
||||
ApiResponse<UpdateScheduleResponse>,
|
||||
unknown,
|
||||
{ scheduleId: number; body: UpdateAtomScheduleDto }
|
||||
>({
|
||||
mutationFn: async ({ scheduleId, body }: { scheduleId: number; body: UpdateAtomScheduleDto }) => {
|
||||
const url = `atoms/schedules/${scheduleId}`;
|
||||
const response = await http.patch<ApiResponse<UpdateScheduleResponse>>(url, body);
|
||||
return response.data;
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
if (data.status === SUCCESS_STATUS) {
|
||||
onSuccess?.(data);
|
||||
queryClient.invalidateQueries({ queryKey: [ScheduleQueryKey] });
|
||||
} else {
|
||||
onError?.(data);
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
onError?.(err as ApiErrorResponse);
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -5,7 +5,7 @@ import { V2_ENDPOINTS } from "@calcom/platform-constants";
|
||||
import type { ApiResponse, ApiErrorResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
import { QUERY_KEY } from "./useSchedule";
|
||||
import { QUERY_KEY } from "./useAtomSchedule";
|
||||
|
||||
interface IUseDeleteScheduleProps {
|
||||
onSuccess?: (res: ApiResponse) => void;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { AvailableSlotsType } from "@calcom/platform-libraries";
|
||||
import type {
|
||||
GetAvailableSlotsInput_2024_04_15,
|
||||
ApiResponse,
|
||||
ApiSuccessResponse,
|
||||
} from "@calcom/platform-types";
|
||||
import type { GetAvailableSlotsResponse } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
|
||||
import http from "../lib/http";
|
||||
|
||||
@@ -33,12 +33,12 @@ export const useAvailableSlots = ({
|
||||
],
|
||||
queryFn: () => {
|
||||
return http
|
||||
.get<ApiResponse<AvailableSlotsType>>("/slots/available", {
|
||||
.get<ApiResponse<GetAvailableSlotsResponse>>("/slots/available", {
|
||||
params: rest,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<AvailableSlotsType>).data;
|
||||
return (res.data as ApiSuccessResponse<GetAvailableSlotsResponse>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { ConnectedDestinationCalendars } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../lib/http";
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
|
||||
import type { PublicEventType } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../lib/http";
|
||||
|
||||
export const QUERY_KEY = "get-public-event";
|
||||
export type UsePublicEventReturnType = ReturnType<typeof usePublicEvent>;
|
||||
|
||||
type Props = {
|
||||
username: string;
|
||||
eventSlug: string;
|
||||
isDynamic?: boolean;
|
||||
};
|
||||
|
||||
export const usePublicEvent = (props: Props) => {
|
||||
const [username, eventSlug] = useBookerStore((state) => [state.username, state.eventSlug], shallow);
|
||||
const isTeamEvent = useBookerStore((state) => state.isTeamEvent);
|
||||
const org = useBookerStore((state) => state.org);
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
|
||||
const requestUsername = username ?? props.username;
|
||||
const requestEventSlug = eventSlug ?? props.eventSlug;
|
||||
|
||||
const event = useQuery({
|
||||
queryKey: [QUERY_KEY, username ?? props.username, eventSlug ?? props.eventSlug, props.isDynamic],
|
||||
queryFn: () => {
|
||||
return http
|
||||
.get<ApiResponse<PublicEventType>>(
|
||||
`/${V2_ENDPOINTS.eventTypes}/${requestUsername}/${requestEventSlug}/public`,
|
||||
{
|
||||
params: {
|
||||
isTeamEvent,
|
||||
org: org ?? null,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
if (props.isDynamic && selectedDuration && res.data.data) {
|
||||
// note(Lauris): Mandatory - In case of "dynamic" event type default event duration returned by the API is 30,
|
||||
// but we are re-using the dynamic event type as a team event, so we must set the event length to whatever the event length is.
|
||||
res.data.data.length = selectedDuration;
|
||||
}
|
||||
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return event;
|
||||
};
|
||||
@@ -12,7 +12,6 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@calcom/platform-libraries": "0.0.2",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.3.1",
|
||||
|
||||
@@ -128,7 +128,10 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
||||
},
|
||||
}}
|
||||
{...(isTeamEvent
|
||||
? { isTeamEvent: true, teamId: teams?.[0]?.id || 0 }
|
||||
? {
|
||||
isTeamEvent: true,
|
||||
teamId: teams?.[0]?.id || 0,
|
||||
}
|
||||
: { username: props.calUsername })}
|
||||
hostsLimit={3}
|
||||
allowUpdatingUrlParams={true}
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function ConferencingApps(props: { calUsername: string; calEmail:
|
||||
className={`flex min-h-screen flex-col ${inter.className} main text-default flex min-h-full w-full flex-col items-center overflow-visible`}>
|
||||
<Navbar username={props.calUsername} />
|
||||
<div className="my-8">
|
||||
<ConferencingAppsSettings returnTo={callbackUri} onErrorReturnTo={callbackUri} teamId={20} />
|
||||
<ConferencingAppsSettings returnTo={callbackUri} onErrorReturnTo={callbackUri} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -22,6 +22,8 @@ export { getEnabledAppsFromCredentials };
|
||||
|
||||
export { getConnectedApps } from "@calcom/lib/getConnectedApps";
|
||||
|
||||
export type { TServiceAccountKeySchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
export type { ConnectedApps } from "@calcom/lib/getConnectedApps";
|
||||
|
||||
export type { AppsStatus } from "@calcom/types/Calendar";
|
||||
@@ -40,3 +42,5 @@ export {
|
||||
CalendarAppDelegationCredentialClientIdNotAuthorizedError,
|
||||
CalendarAppDelegationCredentialNotSetupError,
|
||||
} from "@calcom/lib/CalendarAppError";
|
||||
|
||||
export { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials";
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
export { getPublicEvent, type PublicEventType } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
|
||||
export { getBulkUserEventTypes, getBulkTeamEventTypes } from "@calcom/lib/event-types/getBulkEventTypes";
|
||||
|
||||
@@ -9,51 +9,6 @@ export type { TUpdateInputSchema as TUpdateEventTypeInputSchema } from "@calcom/
|
||||
export type { EventTypesPublic } from "@calcom/lib/event-types/getEventTypesPublic";
|
||||
export { getEventTypesPublic } from "@calcom/lib/event-types/getEventTypesPublic";
|
||||
export { parseEventTypeColor } from "@calcom/lib/isEventTypeColor";
|
||||
export {
|
||||
// note(Lauris): Api to internal
|
||||
transformBookingFieldsApiToInternal,
|
||||
transformLocationsApiToInternal,
|
||||
transformTeamLocationsApiToInternal,
|
||||
transformIntervalLimitsApiToInternal,
|
||||
transformFutureBookingLimitsApiToInternal,
|
||||
transformRecurrenceApiToInternal,
|
||||
transformBookerLayoutsApiToInternal,
|
||||
transformConfirmationPolicyApiToInternal,
|
||||
transformEventColorsApiToInternal,
|
||||
transformSeatsApiToInternal,
|
||||
// note(Lauris): Internal to api
|
||||
transformBookingFieldsInternalToApi,
|
||||
transformLocationsInternalToApi,
|
||||
transformIntervalLimitsInternalToApi,
|
||||
transformFutureBookingLimitsInternalToApi,
|
||||
transformRecurrenceInternalToApi,
|
||||
transformBookerLayoutsInternalToApi,
|
||||
transformRequiresConfirmationInternalToApi,
|
||||
transformEventTypeColorsInternalToApi,
|
||||
transformSeatsInternalToApi,
|
||||
// note(Lauris): schemas
|
||||
InternalLocationsSchema,
|
||||
InternalLocationSchema,
|
||||
BookingFieldsSchema,
|
||||
BookingFieldSchema,
|
||||
// note(Lauris): constants
|
||||
systemBeforeFieldName,
|
||||
systemBeforeFieldEmail,
|
||||
systemBeforeFieldLocation,
|
||||
systemAfterFieldRescheduleReason,
|
||||
systemAfterFieldTitle,
|
||||
systemAfterFieldNotes,
|
||||
systemAfterFieldGuests,
|
||||
apiToInternalintegrationsMapping,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
|
||||
export type {
|
||||
SystemField,
|
||||
CustomField,
|
||||
NameSystemField,
|
||||
EmailSystemField,
|
||||
InternalLocation,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
|
||||
export {
|
||||
EventTypeMetaDataSchema,
|
||||
@@ -70,7 +25,5 @@ export type { EventTypesByViewer } from "@calcom/lib/event-types/getEventTypesBy
|
||||
export type { UpdateEventTypeReturn } from "@calcom/trpc/server/routers/viewer/eventTypes/update.handler";
|
||||
export { updateNewTeamMemberEventTypes } from "@calcom/lib/server/queries/teams";
|
||||
|
||||
export type PublicEventType = Awaited<ReturnType<typeof getPublicEvent>>;
|
||||
export { bulkUpdateEventsToDefaultLocation } from "@calcom/lib/bulkUpdateEventsToDefaultLocation";
|
||||
export { bulkUpdateTeamEventsToDefaultLocation } from "@calcom/lib/bulkUpdateTeamEventsToDefaultLocation";
|
||||
export { getPublicEvent };
|
||||
@@ -22,11 +22,11 @@ import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/crede
|
||||
import { paymentDataSelect } from "@calcom/prisma/selects/payment";
|
||||
import { createNewUsersConnectToOrgIfExists } from "@calcom/trpc/server/routers/viewer/teams/inviteMember/utils";
|
||||
|
||||
export { getUsersCredentials } from "@calcom/lib/server/getUsersCredentials";
|
||||
|
||||
export { slugify } from "@calcom/lib/slugify";
|
||||
export { getBookingForReschedule };
|
||||
|
||||
export type { EventBusyDate } from "@calcom/types/Calendar";
|
||||
|
||||
export { SchedulingType, PeriodType } from "@calcom/prisma/enums";
|
||||
|
||||
export { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
@@ -42,15 +42,10 @@ export { handleCreatePhoneCall };
|
||||
export { handleNewRecurringBooking } from "@calcom/features/bookings/lib/handleNewRecurringBooking";
|
||||
|
||||
export { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
export type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
|
||||
|
||||
export { getBusyCalendarTimes } from "@calcom/lib/CalendarManager";
|
||||
|
||||
export type {
|
||||
BookingCreateBody,
|
||||
BookingResponse,
|
||||
RecurringBookingCreateBody,
|
||||
} from "@calcom/features/bookings/types";
|
||||
export type { BookingCreateBody, BookingResponse } from "@calcom/features/bookings/types";
|
||||
export { HttpError } from "@calcom/lib/http-error";
|
||||
|
||||
export { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
transformApiScheduleOverrides,
|
||||
transformApiScheduleAvailability,
|
||||
} from "@calcom/lib/schedules/transformers/from-api";
|
||||
export {
|
||||
ScheduleRepository,
|
||||
type FindDetailedScheduleByIdReturnType,
|
||||
} from "@calcom/lib/server/repository/schedule";
|
||||
|
||||
export { transformApiScheduleOverrides, transformApiScheduleAvailability };
|
||||
export { updateSchedule, type UpdateScheduleResponse } from "@calcom/lib/schedules/updateSchedule";
|
||||
@@ -1,4 +1,3 @@
|
||||
import { getAvailableSlots } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
|
||||
export { getAvailableSlots };
|
||||
export type AvailableSlotsType = Awaited<ReturnType<typeof getAvailableSlots>>;
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from "./inputs";
|
||||
export * from "./outputs";
|
||||
export * from "./transformed";
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
import type { z } from "zod";
|
||||
|
||||
import type {
|
||||
transformEventColorsApiToInternal,
|
||||
transformFutureBookingLimitsApiToInternal,
|
||||
transformIntervalLimitsApiToInternal,
|
||||
transformRecurrenceApiToInternal,
|
||||
transformSeatsApiToInternal,
|
||||
transformBookingFieldsApiToInternal,
|
||||
InternalLocationsSchema,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
|
||||
import type { CreateEventTypeInput_2024_06_14, ConfirmationPolicyTransformedSchema } from "../inputs";
|
||||
|
||||
export type InputEventTransformed_2024_06_14 = Omit<
|
||||
CreateEventTypeInput_2024_06_14,
|
||||
| "lengthInMinutes"
|
||||
| "locations"
|
||||
| "bookingFields"
|
||||
| "bookingLimitsCount"
|
||||
| "bookingLimitsDuration"
|
||||
| "bookingWindow"
|
||||
| "bookerLayouts"
|
||||
| "confirmationPolicy"
|
||||
| "recurrence"
|
||||
| "color"
|
||||
| "seats"
|
||||
| "customName"
|
||||
| "useDestinationCalendarEmail"
|
||||
> & {
|
||||
length: number;
|
||||
slug: string;
|
||||
eventName?: string;
|
||||
bookingLimits?: ReturnType<typeof transformIntervalLimitsApiToInternal>;
|
||||
locations?: z.infer<typeof InternalLocationsSchema>;
|
||||
bookingFields?: ReturnType<typeof transformBookingFieldsApiToInternal>;
|
||||
durationLimits?: ReturnType<typeof transformIntervalLimitsApiToInternal>;
|
||||
recurringEvent?: ReturnType<typeof transformRecurrenceApiToInternal>;
|
||||
eventTypeColor?: ReturnType<typeof transformEventColorsApiToInternal>;
|
||||
useEventTypeDestinationCalendarEmail?: boolean;
|
||||
} & Partial<
|
||||
Pick<ConfirmationPolicyTransformedSchema, "requiresConfirmation" | "requiresConfirmationWillBlockSlot">
|
||||
> &
|
||||
Partial<ReturnType<typeof transformSeatsApiToInternal>> &
|
||||
Partial<ReturnType<typeof transformFutureBookingLimitsApiToInternal>>;
|
||||
|
||||
export type InputTeamEventTransformed_2024_06_14 = InputEventTransformed_2024_06_14 & {
|
||||
hosts: {
|
||||
userId: number;
|
||||
isFixed: boolean;
|
||||
priority: number;
|
||||
}[];
|
||||
children: {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
eventTypeSlugs: string[];
|
||||
}[];
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./event-type.tranformed";
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./schedules-2024-06-11";
|
||||
export * from "./schedules-2024-04-15";
|
||||
export * from "./update-atom-schedule-body.input";
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Type } from "class-transformer";
|
||||
import { IsString, IsOptional, IsBoolean, ValidateNested, IsArray, IsDate } from "class-validator";
|
||||
|
||||
export class ScheduleTimeRangeDto {
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
start!: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
end!: Date;
|
||||
}
|
||||
|
||||
export class ScheduleDto {
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ScheduleTimeRangeDto)
|
||||
times!: ScheduleTimeRangeDto[];
|
||||
}
|
||||
|
||||
export class UpdateAtomScheduleDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
timeZone?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
name?: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
isDefault?: boolean;
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ScheduleTimeRangeDto)
|
||||
schedule?: ScheduleTimeRangeDto[][];
|
||||
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ScheduleTimeRangeDto)
|
||||
@IsOptional()
|
||||
dateOverrides?: ScheduleTimeRangeDto[];
|
||||
}
|
||||
Reference in new issue
Block a user