chore: booker atom username / teams props enabled queries (#16514)
This commit is contained in:
1 parent
21ef1900e9
commit
105e7d3e28
12 files changed
+118
-46
No files matched your search
@@ -1,10 +1,20 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger";
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
import { IsEnum } from "class-validator";
|
import { IsEnum, IsNumber, IsString } from "class-validator";
|
||||||
|
|
||||||
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
|
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
|
||||||
|
|
||||||
|
export class ProviderVerifyClientData {
|
||||||
|
@IsString()
|
||||||
|
clientId!: string;
|
||||||
|
@IsNumber()
|
||||||
|
organizationId!: number;
|
||||||
|
@IsString()
|
||||||
|
name!: string;
|
||||||
|
}
|
||||||
export class ProviderVerifyClientOutput {
|
export class ProviderVerifyClientOutput {
|
||||||
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] })
|
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] })
|
||||||
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
|
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
|
||||||
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
|
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
|
||||||
|
|
||||||
|
data!: ProviderVerifyClientData;
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,11 @@ export class CalProviderController {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
status: SUCCESS_STATUS,
|
status: SUCCESS_STATUS,
|
||||||
|
data: {
|
||||||
|
clientId: oAuthClient.id,
|
||||||
|
organizationId: oAuthClient.organizationId,
|
||||||
|
name: oAuthClient.name,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9313,6 +9313,25 @@
|
|||||||
"status"
|
"status"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ProviderVerifyClientData": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"clientId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"clientId",
|
||||||
|
"organizationId",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ProviderVerifyClientOutput": {
|
"ProviderVerifyClientOutput": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -9323,10 +9342,14 @@
|
|||||||
"success",
|
"success",
|
||||||
"error"
|
"error"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/components/schemas/ProviderVerifyClientData"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"status"
|
"status",
|
||||||
|
"data"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ProviderVerifyAccessTokenOutput": {
|
"ProviderVerifyAccessTokenOutput": {
|
||||||
|
|||||||
@@ -45,11 +45,13 @@ import { useMe } from "../hooks/useMe";
|
|||||||
import { useSlots } from "../hooks/useSlots";
|
import { useSlots } from "../hooks/useSlots";
|
||||||
import { AtomsWrapper } from "../src/components/atoms-wrapper";
|
import { AtomsWrapper } from "../src/components/atoms-wrapper";
|
||||||
|
|
||||||
export type BookerPlatformWrapperAtomProps = Omit<BookerProps, "username" | "entity"> & {
|
export type BookerPlatformWrapperAtomProps = Omit<
|
||||||
|
BookerProps,
|
||||||
|
"username" | "entity" | "isTeamEvent" | "teamId"
|
||||||
|
> & {
|
||||||
rescheduleUid?: string;
|
rescheduleUid?: string;
|
||||||
rescheduledBy?: string;
|
rescheduledBy?: string;
|
||||||
bookingUid?: string;
|
bookingUid?: string;
|
||||||
username: string | string[] | undefined;
|
|
||||||
entity?: BookerProps["entity"];
|
entity?: BookerProps["entity"];
|
||||||
// values for the booking form and booking fields
|
// values for the booking form and booking fields
|
||||||
defaultFormValues?: {
|
defaultFormValues?: {
|
||||||
@@ -73,11 +75,24 @@ export type BookerPlatformWrapperAtomProps = Omit<BookerProps, "username" | "ent
|
|||||||
onDeleteSlotSuccess?: (data: ApiSuccessResponseWithoutData) => void;
|
onDeleteSlotSuccess?: (data: ApiSuccessResponseWithoutData) => void;
|
||||||
onDeleteSlotError?: (data: ApiErrorResponse) => void;
|
onDeleteSlotError?: (data: ApiErrorResponse) => void;
|
||||||
locationUrl?: string;
|
locationUrl?: string;
|
||||||
teamId?: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) => {
|
type BookerPlatformWrapperAtomPropsForIndividual = BookerPlatformWrapperAtomProps & {
|
||||||
|
username: string | string[];
|
||||||
|
isTeamEvent?: false;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BookerPlatformWrapperAtomPropsForTeam = BookerPlatformWrapperAtomProps & {
|
||||||
|
username?: string | string[];
|
||||||
|
isTeamEvent: true;
|
||||||
|
teamId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const BookerPlatformWrapper = (
|
||||||
|
props: BookerPlatformWrapperAtomPropsForIndividual | BookerPlatformWrapperAtomPropsForTeam
|
||||||
|
) => {
|
||||||
const { clientId } = useAtomsContext();
|
const { clientId } = useAtomsContext();
|
||||||
|
const teamId: number | undefined = props.isTeamEvent ? props.teamId : undefined;
|
||||||
const [bookerState, setBookerState] = useBookerStore((state) => [state.state, state.setState], shallow);
|
const [bookerState, setBookerState] = useBookerStore((state) => [state.state, state.setState], shallow);
|
||||||
const setSelectedDate = useBookerStore((state) => state.setSelectedDate);
|
const setSelectedDate = useBookerStore((state) => state.setSelectedDate);
|
||||||
const setSelectedDuration = useBookerStore((state) => state.setSelectedDuration);
|
const setSelectedDuration = useBookerStore((state) => state.setSelectedDuration);
|
||||||
@@ -112,18 +127,18 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
|||||||
isSuccess: isTeamSuccess,
|
isSuccess: isTeamSuccess,
|
||||||
isError: isTeamError,
|
isError: isTeamError,
|
||||||
isPending: isTeamPending,
|
isPending: isTeamPending,
|
||||||
data: teamData,
|
data: teamEventTypeData,
|
||||||
} = useTeamEventType(props.teamId, props.eventSlug, props.isTeamEvent);
|
} = useTeamEventType(teamId, props.eventSlug, props.isTeamEvent);
|
||||||
|
|
||||||
const event = useMemo(() => {
|
const event = useMemo(() => {
|
||||||
if (props.isTeamEvent) {
|
if (props.isTeamEvent && !isTeamPending && teamId && teamEventTypeData && teamEventTypeData.length > 0) {
|
||||||
return {
|
return {
|
||||||
isSuccess: isTeamSuccess,
|
isSuccess: isTeamSuccess,
|
||||||
isError: isTeamError,
|
isError: isTeamError,
|
||||||
isPending: isTeamPending,
|
isPending: isTeamPending,
|
||||||
data:
|
data:
|
||||||
teamData && teamData.length > 0
|
teamEventTypeData && teamEventTypeData.length > 0
|
||||||
? transformApiTeamEventTypeForAtom(teamData[0], props.entity)
|
? transformApiTeamEventTypeForAtom(teamEventTypeData[0], props.entity)
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -136,15 +151,16 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
|||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
props.isTeamEvent,
|
props.isTeamEvent,
|
||||||
|
teamId,
|
||||||
props.entity,
|
props.entity,
|
||||||
|
teamEventTypeData,
|
||||||
isSuccess,
|
isSuccess,
|
||||||
isError,
|
isError,
|
||||||
isPending,
|
isPending,
|
||||||
data,
|
data,
|
||||||
|
isTeamPending,
|
||||||
isTeamSuccess,
|
isTeamSuccess,
|
||||||
isTeamError,
|
isTeamError,
|
||||||
isTeamPending,
|
|
||||||
teamData,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (isDynamic && props.duration && event.data) {
|
if (isDynamic && props.duration && event.data) {
|
||||||
@@ -212,19 +228,25 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
const schedule = useAvailableSlots({
|
const schedule = useAvailableSlots({
|
||||||
usernameList: getUsernameList(username ?? ""),
|
usernameList: getUsernameList(username),
|
||||||
eventTypeId: event?.data?.id ?? 0,
|
eventTypeId: event?.data?.id ?? 0,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
timeZone: session?.data?.timeZone,
|
timeZone: session?.data?.timeZone,
|
||||||
duration: selectedDuration ?? undefined,
|
duration: selectedDuration ?? undefined,
|
||||||
rescheduleUid: props.rescheduleUid,
|
rescheduleUid: props.rescheduleUid,
|
||||||
|
...(props.isTeamEvent
|
||||||
|
? {
|
||||||
|
isTeamEvent: props.isTeamEvent,
|
||||||
|
teamId: teamId,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
enabled:
|
enabled:
|
||||||
Boolean(username) &&
|
Boolean(teamId || username) &&
|
||||||
Boolean(month) &&
|
Boolean(month) &&
|
||||||
Boolean(timezone) &&
|
Boolean(timezone) &&
|
||||||
// Should only wait for one or the other, not both.
|
(props.isTeamEvent ? !isTeamPending : !isPending) &&
|
||||||
(Boolean(eventSlug) || Boolean(event?.data?.id) || event?.data?.id === 0),
|
Boolean(event?.data?.id),
|
||||||
orgSlug: props.entity?.orgSlug ?? undefined,
|
orgSlug: props.entity?.orgSlug ?? undefined,
|
||||||
eventTypeSlug: isDynamic ? "dynamic" : eventSlug || "",
|
eventTypeSlug: isDynamic ? "dynamic" : eventSlug || "",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,9 +37,12 @@ export function BaseCalProvider({
|
|||||||
labels,
|
labels,
|
||||||
autoUpdateTimezone,
|
autoUpdateTimezone,
|
||||||
language = EN,
|
language = EN,
|
||||||
|
organizationId,
|
||||||
onTimezoneChange,
|
onTimezoneChange,
|
||||||
}: CalProviderProps) {
|
}: CalProviderProps) {
|
||||||
const [error, setError] = useState<string>("");
|
const [error, setError] = useState<string>("");
|
||||||
|
const [stateOrgId, setOrganizationId] = useState<number>(0);
|
||||||
|
|
||||||
const { data: me } = useMe();
|
const { data: me } = useMe();
|
||||||
|
|
||||||
const { mutateAsync } = useUpdateUserTimezone();
|
const { mutateAsync } = useUpdateUserTimezone();
|
||||||
@@ -64,8 +67,9 @@ export function BaseCalProvider({
|
|||||||
apiUrl: options.apiUrl,
|
apiUrl: options.apiUrl,
|
||||||
refreshUrl: options.refreshUrl,
|
refreshUrl: options.refreshUrl,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
setError("");
|
setError("");
|
||||||
|
setOrganizationId(data.organizationId);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -120,7 +124,7 @@ export function BaseCalProvider({
|
|||||||
isInit: isInit,
|
isInit: isInit,
|
||||||
isValidClient: Boolean(!error && clientId && isInit),
|
isValidClient: Boolean(!error && clientId && isInit),
|
||||||
isAuth: Boolean(isInit && !error && clientId && currentAccessToken && http.getAuthorizationHeader()),
|
isAuth: Boolean(isInit && !error && clientId && currentAccessToken && http.getAuthorizationHeader()),
|
||||||
organizationId: me?.data.organizationId || 0,
|
organizationId: organizationId || stateOrgId || me?.data.organizationId || 0,
|
||||||
...translations,
|
...translations,
|
||||||
}}>
|
}}>
|
||||||
<TooltipProvider>{children}</TooltipProvider>
|
<TooltipProvider>{children}</TooltipProvider>
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export type CalProviderProps = {
|
|||||||
autoUpdateTimezone?: boolean;
|
autoUpdateTimezone?: boolean;
|
||||||
onTimezoneChange?: () => void;
|
onTimezoneChange?: () => void;
|
||||||
version?: API_VERSIONS_ENUM;
|
version?: API_VERSIONS_ENUM;
|
||||||
|
organizationId?: number;
|
||||||
} & i18nProps;
|
} & i18nProps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +98,7 @@ export function CalProvider({
|
|||||||
language = "en",
|
language = "en",
|
||||||
onTimezoneChange,
|
onTimezoneChange,
|
||||||
version = VERSION_2024_06_14,
|
version = VERSION_2024_06_14,
|
||||||
|
organizationId,
|
||||||
}: CalProviderProps) {
|
}: CalProviderProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
http.setVersionHeader(version);
|
http.setVersionHeader(version);
|
||||||
@@ -118,7 +120,8 @@ export function CalProvider({
|
|||||||
options={options}
|
options={options}
|
||||||
version={version}
|
version={version}
|
||||||
labels={labels as Record<translationKeys, string>}
|
labels={labels as Record<translationKeys, string>}
|
||||||
language={language}>
|
language={language}
|
||||||
|
organizationId={organizationId}>
|
||||||
{children}
|
{children}
|
||||||
</BaseCalProvider>
|
</BaseCalProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { shallow } from "zustand/shallow";
|
|
||||||
|
|
||||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
|
||||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||||
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
|
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
|
||||||
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||||
@@ -14,20 +12,17 @@ export const QUERY_KEY = "use-event-type";
|
|||||||
export type UsePublicEventReturnType = ReturnType<typeof useEventType>;
|
export type UsePublicEventReturnType = ReturnType<typeof useEventType>;
|
||||||
|
|
||||||
export const useEventType = (username: string, eventSlug: string, isTeamEvent: boolean | undefined) => {
|
export const useEventType = (username: string, eventSlug: string, isTeamEvent: boolean | undefined) => {
|
||||||
const [stateUsername, stateEventSlug] = useBookerStore(
|
|
||||||
(state) => [state.username, state.eventSlug],
|
|
||||||
shallow
|
|
||||||
);
|
|
||||||
|
|
||||||
const requestUsername = stateUsername ?? username;
|
|
||||||
const requestEventSlug = stateEventSlug ?? eventSlug;
|
const requestUsername = username;
|
||||||
|
const requestEventSlug = eventSlug;
|
||||||
|
|
||||||
const isDynamic = useMemo(() => {
|
const isDynamic = useMemo(() => {
|
||||||
return getUsernameList(requestUsername ?? "").length > 1;
|
return getUsernameList(requestUsername ?? "").length > 1;
|
||||||
}, [requestUsername]);
|
}, [requestUsername]);
|
||||||
|
|
||||||
const event = useQuery({
|
const event = useQuery({
|
||||||
queryKey: [QUERY_KEY, stateUsername ?? username, stateEventSlug ?? eventSlug],
|
queryKey: [QUERY_KEY, username, eventSlug],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (isTeamEvent) {
|
if (isTeamEvent) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { shallow } from "zustand/shallow";
|
|
||||||
|
|
||||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
|
||||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||||
import type { ApiSuccessResponse, TeamEventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
import type { ApiSuccessResponse, TeamEventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||||
import type { ApiResponse } from "@calcom/platform-types";
|
import type { ApiResponse } from "@calcom/platform-types";
|
||||||
@@ -14,12 +12,8 @@ export const QUERY_KEY = "use-team-event-type";
|
|||||||
export const useTeamEventType = (teamId: number | undefined, eventSlug: string, isTeamEvent: boolean | undefined) => {
|
export const useTeamEventType = (teamId: number | undefined, eventSlug: string, isTeamEvent: boolean | undefined) => {
|
||||||
const { organizationId } = useAtomsContext();
|
const { organizationId } = useAtomsContext();
|
||||||
|
|
||||||
const [stateEventSlug] = useBookerStore(
|
|
||||||
(state) => [state.eventSlug],
|
|
||||||
shallow
|
|
||||||
);
|
|
||||||
|
|
||||||
const requestEventSlug = stateEventSlug ?? eventSlug;
|
const requestEventSlug = eventSlug;
|
||||||
|
|
||||||
const pathname = `/organizations/${organizationId}/teams/${teamId}/event-types?eventSlug=${requestEventSlug}`;
|
const pathname = `/organizations/${organizationId}/teams/${teamId}/event-types?eventSlug=${requestEventSlug}`;
|
||||||
|
|
||||||
@@ -35,6 +29,7 @@ export const useTeamEventType = (teamId: number | undefined, eventSlug: string,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
enabled: Boolean(organizationId) && Boolean(teamId) && Boolean(eventSlug) && Boolean(isTeamEvent),
|
||||||
});
|
});
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
|
|||||||
@@ -8,9 +8,21 @@ import http from "../lib/http";
|
|||||||
|
|
||||||
export const QUERY_KEY = "get-available-slots";
|
export const QUERY_KEY = "get-available-slots";
|
||||||
|
|
||||||
export const useAvailableSlots = ({ enabled, ...rest }: GetAvailableSlotsInput & { enabled: boolean }) => {
|
export const useAvailableSlots = ({
|
||||||
|
enabled,
|
||||||
|
...rest
|
||||||
|
}: GetAvailableSlotsInput & { enabled: boolean; isTeamEvent?: boolean; teamId?: number }) => {
|
||||||
const availableSlots = useQuery({
|
const availableSlots = useQuery({
|
||||||
queryKey: [QUERY_KEY, rest.startTime, rest.endTime, rest.eventTypeId, rest.eventTypeSlug],
|
queryKey: [
|
||||||
|
QUERY_KEY,
|
||||||
|
rest.startTime,
|
||||||
|
rest.endTime,
|
||||||
|
rest.eventTypeId,
|
||||||
|
rest.eventTypeSlug,
|
||||||
|
rest.isTeamEvent ?? false,
|
||||||
|
rest.teamId ?? false,
|
||||||
|
rest.usernameList,
|
||||||
|
],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return http
|
return http
|
||||||
.get<ApiResponse<AvailableSlotsType>>("/slots/available", {
|
.get<ApiResponse<AvailableSlotsType>>("/slots/available", {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { AxiosError } from "axios";
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { usePrevious } from "react-use";
|
import { usePrevious } from "react-use";
|
||||||
|
|
||||||
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||||
import type { ApiResponse } from "@calcom/platform-types";
|
import type { ApiResponse } from "@calcom/platform-types";
|
||||||
|
|
||||||
import http from "../lib/http";
|
import http from "../lib/http";
|
||||||
@@ -11,12 +12,11 @@ export interface useOAuthClientProps {
|
|||||||
apiUrl?: string;
|
apiUrl?: string;
|
||||||
refreshUrl?: string;
|
refreshUrl?: string;
|
||||||
onError: (error: string) => void;
|
onError: (error: string) => void;
|
||||||
onSuccess: () => void;
|
onSuccess: (data: { client: string; organizationId: number; name: string }) => void;
|
||||||
}
|
}
|
||||||
export const useOAuthClient = ({ clientId, apiUrl, refreshUrl, onError, onSuccess }: useOAuthClientProps) => {
|
export const useOAuthClient = ({ clientId, apiUrl, refreshUrl, onError, onSuccess }: useOAuthClientProps) => {
|
||||||
const prevClientId = usePrevious(clientId);
|
const prevClientId = usePrevious(clientId);
|
||||||
const [isInit, setIsInit] = useState<boolean>(false);
|
const [isInit, setIsInit] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (apiUrl && http.getUrl() !== apiUrl) {
|
if (apiUrl && http.getUrl() !== apiUrl) {
|
||||||
http.setUrl(apiUrl);
|
http.setUrl(apiUrl);
|
||||||
@@ -31,9 +31,11 @@ export const useOAuthClient = ({ clientId, apiUrl, refreshUrl, onError, onSucces
|
|||||||
if (clientId && http.getUrl() && prevClientId !== clientId) {
|
if (clientId && http.getUrl() && prevClientId !== clientId) {
|
||||||
try {
|
try {
|
||||||
http
|
http
|
||||||
.get<ApiResponse>(`/provider/${clientId}`)
|
.get<ApiResponse<{ client: string; organizationId: number; name: string }>>(`/provider/${clientId}`)
|
||||||
.then(() => {
|
.then((response) => {
|
||||||
onSuccess();
|
if (response.data.status === SUCCESS_STATUS) {
|
||||||
|
onSuccess(response.data.data);
|
||||||
|
}
|
||||||
http.setClientIdHeader(clientId);
|
http.setClientIdHeader(clientId);
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err: AxiosError) => {
|
||||||
|
|||||||
@@ -92,13 +92,10 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
|||||||
<h1>{eventTypeSlug}</h1>
|
<h1>{eventTypeSlug}</h1>
|
||||||
<Booker
|
<Booker
|
||||||
eventSlug={eventTypeSlug}
|
eventSlug={eventTypeSlug}
|
||||||
username={props.calUsername ?? ""}
|
|
||||||
onCreateBookingSuccess={(data) => {
|
onCreateBookingSuccess={(data) => {
|
||||||
setBookingTitle(data.data.title ?? "");
|
setBookingTitle(data.data.title ?? "");
|
||||||
router.push(`/${data.data.uid}`);
|
router.push(`/${data.data.uid}`);
|
||||||
}}
|
}}
|
||||||
teamId={teams?.[0]?.id || 0}
|
|
||||||
isTeamEvent={isTeamEvent}
|
|
||||||
duration={eventTypeDuration}
|
duration={eventTypeDuration}
|
||||||
customClassNames={{
|
customClassNames={{
|
||||||
bookerContainer: "!bg-[#F5F2FE] [&_button:!rounded-full] border-subtle border",
|
bookerContainer: "!bg-[#F5F2FE] [&_button:!rounded-full] border-subtle border",
|
||||||
@@ -113,6 +110,9 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
|||||||
availableTimes: "!bg-[#D7CEF5]",
|
availableTimes: "!bg-[#D7CEF5]",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
{...(isTeamEvent
|
||||||
|
? { isTeamEvent: true, teamId: teams?.[0]?.id || 0 }
|
||||||
|
: { username: props.calUsername })}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export class GetAvailableSlotsInput {
|
|||||||
|
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsString({ each: true })
|
@IsString({ each: true })
|
||||||
|
@IsOptional()
|
||||||
usernameList?: string[];
|
usernameList?: string[];
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
|
|||||||
Reference in new issue
Block a user