@@ -2,12 +2,14 @@ import { useQuery } from "@tanstack/react-query";
22import { useMemo } from "react" ;
33
44import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents" ;
5+ import { getAbsoluteAvatarUrl } from "@calcom/lib/getAvatarUrl" ;
56import { SUCCESS_STATUS , V2_ENDPOINTS } from "@calcom/platform-constants" ;
67import type { PublicEventType } from "@calcom/features/eventtypes/lib/getPublicEvent" ;
78import type { ApiResponse } from "@calcom/platform-types" ;
89
910import http from "../../../lib/http" ;
1011import { useAtomsContext } from "../../../hooks/useAtomsContext" ;
12+ import { useIsPlatformBookerEmbed } from "../../../hooks/useIsPlatformBookerEmbed" ;
1113
1214export const QUERY_KEY = "get-public-event" ;
1315export type UsePublicEventReturnType = ReturnType < typeof useAtomGetPublicEvent > ;
@@ -20,9 +22,15 @@ type Props = {
2022 selectedDuration : number | null ;
2123} ;
2224
23- export const useAtomGetPublicEvent = ( { username, eventSlug, isTeamEvent, teamId, selectedDuration } : Props ) => {
24-
25+ export const useAtomGetPublicEvent = ( {
26+ username,
27+ eventSlug,
28+ isTeamEvent,
29+ teamId,
30+ selectedDuration,
31+ } : Props ) => {
2532 const { organizationId } = useAtomsContext ( ) ;
33+ const isPlatformBookerEmbed = useIsPlatformBookerEmbed ( ) ;
2634
2735 const isDynamic = useMemo ( ( ) => {
2836 return getUsernameList ( username ?? "" ) . length > 1 ;
@@ -31,29 +39,49 @@ export const useAtomGetPublicEvent = ({ username, eventSlug, isTeamEvent, teamId
3139 const pathname = `/atoms/${ V2_ENDPOINTS . eventTypes } /${ eventSlug } /public` ;
3240
3341 const event = useQuery ( {
34- queryKey : [ QUERY_KEY , username , eventSlug , isTeamEvent , teamId , organizationId ] ,
42+ queryKey : [
43+ QUERY_KEY ,
44+ username ,
45+ eventSlug ,
46+ isTeamEvent ,
47+ teamId ,
48+ organizationId ,
49+ ] ,
3550 queryFn : ( ) => {
3651 const params : Record < string , any > = {
3752 isTeamEvent,
3853 teamId,
39- username : getUsernameList ( username ?? "" ) . join ( "+" )
54+ username : getUsernameList ( username ?? "" ) . join ( "+" ) ,
4055 } ;
41-
56+
4257 // Only include orgId if it's not 0
4358 if ( organizationId !== 0 ) {
4459 params . orgId = organizationId ;
4560 }
46-
47- return http ?. get < ApiResponse < PublicEventType > > ( pathname , {
48- params,
49- } )
61+
62+ return http
63+ ?. get < ApiResponse < PublicEventType > > ( pathname , {
64+ params,
65+ } )
5066 . then ( ( res ) => {
5167 if ( res . data . status === SUCCESS_STATUS ) {
5268 if ( isDynamic && selectedDuration && res . data . data ) {
5369 // note(Lauris): Mandatory - In case of "dynamic" event type default event duration returned by the API is 30,
5470 // 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.
5571 res . data . data . length = selectedDuration ;
5672 }
73+ if ( isPlatformBookerEmbed && res . data . data ) {
74+ if ( res . data . data . profile ?. image ) {
75+ res . data . data . profile . image = getAbsoluteAvatarUrl (
76+ res . data . data . profile . image
77+ ) ;
78+ }
79+ if ( res . data . data . entity ?. logoUrl ) {
80+ res . data . data . entity . logoUrl = getAbsoluteAvatarUrl (
81+ res . data . data . entity . logoUrl
82+ ) ;
83+ }
84+ }
5785 return res . data . data ;
5886 }
5987 throw new Error ( res . data . error . message ) ;
0 commit comments