Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/platform/atoms/booker-embed/BookerEmbed.tsx
Copy link
Contributor Author

@ibex088 ibex088 Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow organizationId for user events as well.
This is required because, with the migration to the new /atoms endpoints for the booker atom, organizationId will be necessary in certain cases for user's individual events as well

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const BookerEmbed = (
preventEventTypeRedirect?: BookerPlatformWrapperAtomPropsForTeam["preventEventTypeRedirect"];
}
| (BookerPlatformWrapperAtomPropsForIndividual & {
organizationId?: undefined;
organizationId?: number;
routingFormUrl?: undefined;
})
| (BookerPlatformWrapperAtomPropsForTeam & { organizationId?: number; routingFormUrl?: undefined })
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/atoms/cal-provider/BaseCalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function BaseCalProvider({
const [error, setError] = useState<string>("");
const [stateOrgId, setOrganizationId] = useState<number>(0);

const { data: me } = useMe();
const { data: me } = useMe(isEmbed);

const { mutateAsync } = useUpdateUserTimezone();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ export const useAtomGetPublicEvent = ({ username, eventSlug, isTeamEvent, teamId
const event = useQuery({
queryKey: [QUERY_KEY, username, eventSlug, isTeamEvent, teamId, organizationId],
queryFn: () => {
const params: Record<string, any> = {
isTeamEvent,
teamId,
username: getUsernameList(username ?? "").join(",")
};

// Only include orgId if it's not 0
if (organizationId !== 0) {
params.orgId = organizationId;
}

return http?.get<ApiResponse<PublicEventType>>(pathname, {
params: {
isTeamEvent,
teamId,
orgId: organizationId,
username: getUsernameList(username?? "").join(",")
},
params,
})
.then((res) => {
if (res.data.status === SUCCESS_STATUS) {
Expand Down
4 changes: 2 additions & 2 deletions packages/platform/atoms/hooks/useMe.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't call useMe for embeds

Copy link
Contributor Author

@ibex088 ibex088 Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes the orgId being sent for non-org members when tryint to access their personal events, @Ryukemeister showed me the other day

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const QUERY_KEY = "get-me";
* Access Token must be provided to CalProvider in order to use this hook
* @returns The result of the query containing the user's profile.
*/
export const useMe = () => {
export const useMe = (isEmbed: boolean = false) => {
const pathname = `/${V2_ENDPOINTS.me}`;
const me = useQuery({
queryKey: [QUERY_KEY],
Expand All @@ -23,7 +23,7 @@ export const useMe = () => {
throw new Error(res.data.error.message);
});
},
enabled: Boolean(http.getAuthorizationHeader()),
enabled: Boolean(http.getAuthorizationHeader()) && !isEmbed,
});

return me;
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/atoms/hooks/useOAuthClient.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-run useEffect in case the url is not set the first time

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const useOAuthClient = ({
console.error(err);
}
}
}, [isEmbed, clientId, onError, prevClientId, onSuccess]);
}, [isEmbed, clientId, onError, prevClientId, onSuccess, http.getUrl()]);

return { isInit };
};
Loading