fix: Booker atom modal not rendering for mobile devices (#14278)

* make sure modal always appears

* separate event form wrappers into two components

* platform hook to fetch event type by id

* testing useGetEventTypeById hook

* add useGetEventTypeById to monorepo exports

* use platform hook for event type by id
This commit is contained in:
Rajiv Sahal authored and GitHub committed 2024-04-02 20:41:28 +03:00
1 parent b202c4e79f
commit aca552c9f7
5 files changed
+78 -15

No files matched your search

@@ -0,0 +1,27 @@
import { useQuery } from "@tanstack/react-query";
import { BASE_URL, API_VERSION, V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
import type { EventType as AtomEventType } from "@calcom/platform-libraries";
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
import http from "../../lib/http";
export const QUERY_KEY = "get-event-by-id";
export const useGetEventTypeById = (id: number | null) => {
const endpoint = new URL(BASE_URL);
endpoint.pathname = `api/${API_VERSION}/${V2_ENDPOINTS.eventTypes}/${id}`;
endpoint.searchParams.set("for", "atom");
return useQuery({
queryKey: [QUERY_KEY, id],
queryFn: () => {
return http?.get<ApiResponse<AtomEventType>>(endpoint.toString()).then((res) => {
if (res.data.status === SUCCESS_STATUS) {
return (res.data as ApiSuccessResponse<AtomEventType>).data;
}
throw new Error(res.data.error.message);
});
},
});
};
+1
View File
@@ -6,6 +6,7 @@ export { useIsPlatform } from "./hooks/useIsPlatform";
export { useAtomsContext } from "./hooks/useAtomsContext";
export { useConnectedCalendars } from "./hooks/useConnectedCalendars";
export { useEventTypesPublic } from "./hooks/event-types/useEventTypesPublic";
export { useGetEventTypeById } from "./hooks/event-types/useGetEventTypeById";
export { useCancelBooking } from "./hooks/useCancelBooking";
export { useGetBooking } from "./hooks/useGetBooking";
export { useGetBookings } from "./hooks/useGetBookings";
+1
View File
@@ -3,6 +3,7 @@ export { WebAvailabilitySettingsWrapper as AvailabilitySettings } from "./availa
export { CalProvider } from "./cal-provider/CalProvider";
export { useIsPlatform } from "./hooks/useIsPlatform";
export { useAtomsContext } from "./hooks/useAtomsContext";
export { useGetEventTypeById } from "./hooks/event-types/useGetEventTypeById";
export { useHandleBookEvent } from "./hooks/useHandleBookEvent";
export * as Dialog from "./src/components/ui/dialog";
export { Timezone } from "./timezone";