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 <sahalrajiv-extc@atharvacoe.ac.in>
This commit is contained in:
co-authored by
Rajiv Sahal
parent
d3fbc73a39
commit
33aedbae20
@@ -29,7 +29,7 @@ export const BookerEmbed = (
|
||||
preventEventTypeRedirect?: BookerPlatformWrapperAtomPropsForTeam["preventEventTypeRedirect"];
|
||||
}
|
||||
| (BookerPlatformWrapperAtomPropsForIndividual & {
|
||||
organizationId?: undefined;
|
||||
organizationId?: number;
|
||||
routingFormUrl?: undefined;
|
||||
})
|
||||
| (BookerPlatformWrapperAtomPropsForTeam & { organizationId?: number; routingFormUrl?: undefined })
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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],
|
||||
@@ -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;
|
||||
|
||||
@@ -55,7 +55,7 @@ export const useOAuthClient = ({
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}, [isEmbed, clientId, onError, prevClientId, onSuccess]);
|
||||
}, [isEmbed, clientId, onError, prevClientId, onSuccess, http.getUrl()]);
|
||||
|
||||
return { isInit };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user