Skip to content

Commit 33aedba

Browse files
fix: booker embed (#22898)
* fix: make organizationId optional number type in BookerEmbed * feat: dont call useMe for embeds * useOAuthClient hook should re-run when url is set * feat: Remove `?orgId=0` from /public event query params --------- Co-authored-by: Rajiv Sahal <[email protected]>
1 parent d3fbc73 commit 33aedba

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

packages/platform/atoms/booker-embed/BookerEmbed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const BookerEmbed = (
2929
preventEventTypeRedirect?: BookerPlatformWrapperAtomPropsForTeam["preventEventTypeRedirect"];
3030
}
3131
| (BookerPlatformWrapperAtomPropsForIndividual & {
32-
organizationId?: undefined;
32+
organizationId?: number;
3333
routingFormUrl?: undefined;
3434
})
3535
| (BookerPlatformWrapperAtomPropsForTeam & { organizationId?: number; routingFormUrl?: undefined })

packages/platform/atoms/cal-provider/BaseCalProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function BaseCalProvider({
6060
const [error, setError] = useState<string>("");
6161
const [stateOrgId, setOrganizationId] = useState<number>(0);
6262

63-
const { data: me } = useMe();
63+
const { data: me } = useMe(isEmbed);
6464

6565
const { mutateAsync } = useUpdateUserTimezone();
6666

packages/platform/atoms/hooks/event-types/public/useAtomGetPublicEvent.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ export const useAtomGetPublicEvent = ({ username, eventSlug, isTeamEvent, teamId
3333
const event = useQuery({
3434
queryKey: [QUERY_KEY, username, eventSlug, isTeamEvent, teamId, organizationId],
3535
queryFn: () => {
36+
const params: Record<string, any> = {
37+
isTeamEvent,
38+
teamId,
39+
username: getUsernameList(username ?? "").join(",")
40+
};
41+
42+
// Only include orgId if it's not 0
43+
if (organizationId !== 0) {
44+
params.orgId = organizationId;
45+
}
46+
3647
return http?.get<ApiResponse<PublicEventType>>(pathname, {
37-
params: {
38-
isTeamEvent,
39-
teamId,
40-
orgId: organizationId,
41-
username: getUsernameList(username?? "").join(",")
42-
},
48+
params,
4349
})
4450
.then((res) => {
4551
if (res.data.status === SUCCESS_STATUS) {

packages/platform/atoms/hooks/useMe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const QUERY_KEY = "get-me";
1111
* Access Token must be provided to CalProvider in order to use this hook
1212
* @returns The result of the query containing the user's profile.
1313
*/
14-
export const useMe = () => {
14+
export const useMe = (isEmbed: boolean = false) => {
1515
const pathname = `/${V2_ENDPOINTS.me}`;
1616
const me = useQuery({
1717
queryKey: [QUERY_KEY],
@@ -23,7 +23,7 @@ export const useMe = () => {
2323
throw new Error(res.data.error.message);
2424
});
2525
},
26-
enabled: Boolean(http.getAuthorizationHeader()),
26+
enabled: Boolean(http.getAuthorizationHeader()) && !isEmbed,
2727
});
2828

2929
return me;

packages/platform/atoms/hooks/useOAuthClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const useOAuthClient = ({
5555
console.error(err);
5656
}
5757
}
58-
}, [isEmbed, clientId, onError, prevClientId, onSuccess]);
58+
}, [isEmbed, clientId, onError, prevClientId, onSuccess, http.getUrl()]);
5959

6060
return { isInit };
6161
};

0 commit comments

Comments
 (0)