feat: Rerouting a booking with corrected responses (#17074)
* POC working with no TS error * cleanup * Fix query booking * Simplify things * Support rerouting to different event * self-review fixes * Some improvements * add more tests * Remove members relation query * Udits feedback * Dont show CTAs when non-eventTypeRedirectUrl action route is chosen --------- Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
1 parent
4f14775a4d
commit
b8d4fccbab
33 files changed
+1990
-98
No files matched your search
@@ -76,6 +76,16 @@ export function handleEvent(event: { detail: Record<string, unknown> & { type: s
|
||||
});
|
||||
});
|
||||
|
||||
// Support sending all events to opener which is currently used by ReroutingDialog to identify if the booking is successfully rescheduled.
|
||||
if (window.opener) {
|
||||
window.opener.postMessage(
|
||||
{
|
||||
type: `CAL:${name}`,
|
||||
...data,
|
||||
},
|
||||
"*"
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
## Ready for Review Requirements
|
||||
- Authorization check for fetch form response and form
|
||||
|
||||
|
||||
|
||||
## TODO - Routing
|
||||
- [x] Use teamMemberIds to calculate availabilithy as well in addition to doing it in handleNewBooking
|
||||
- [x] Don't let the Routing Form with attributesQueryValue be picked
|
||||
@@ -7,13 +12,32 @@
|
||||
- [x] Fix bug with Multiselect attribute
|
||||
- [x] Connect Form Response to Booking
|
||||
- [x] Test with non option based attributes and form field input
|
||||
- [x] We might want to disable attributes query builder for non-orgs. Same for Re-routing.
|
||||
- [ ] Switching from Select to MultiSelect in attribute
|
||||
- [ ] It immediately makes the Routing logic to not work. Fix it.
|
||||
- [ ] It removes the selected option from Routing. Fix it.
|
||||
- [ ] Warnings are needed with recommendation to create new attribute instead in unsupported scenarios. We need to test for more such changes to Attribute types.
|
||||
- [ ] When choosing 'Value of Field' option in RAQB, show a warning somewhere if all options of the Form field aren't present in the attribute option.
|
||||
- So, if Form Field is 'What is Comapny Size' with options Enterprise, Large, Medium, Small and Attribute for which Value of 'What is compnay size' has options Enterprise, Large, Medium. It would show a warning that 'Small' option is not present in the attribute.
|
||||
- [ ] When logic can't be built(Short text maps to an attribute with given set of options but the short text value doesn't match any of the options), the team member matching route throws error but Test Preview still shows the previous value - It show should the error in there.
|
||||
- [ ] Test Seated events as routing targets.
|
||||
- Improvements
|
||||
- [ ] When choosing 'Value of Field' option in RAQB, show a warning somewhere if all options of the Form field aren't present in the attribute option.
|
||||
- So, if Form Field is 'What is Comapny Size' with options Enterprise, Large, Medium, Small and Attribute for which Value of 'What is compnay size' has options Enterprise, Large, Medium. It would show a warning that 'Small' option is not present in the attribute.
|
||||
- [ ] When logic can't be built(Short text maps to an attribute with given set of options but the short text value doesn't match any of the options), the team member matching route throws error but Test Preview still shows the previous value - It show should the error in there.
|
||||
- [ ] When routing to a team that doesn't have the team members assigned that are chosen, we are unable to select those users. FIX it by ignoring the assigned members(except the fixed hosts) and just using the attributes matched team members.
|
||||
- [x] Start storing eventTypeId in routing Action.
|
||||
- [x] Make sure that without making the FORM dirty, user can't reroute
|
||||
- [x] When 'Verify Route' is clicked, it doesn't seem to run the form field logic as there is a warning in console. Fix it.
|
||||
- [x] Give a proper icon to Reroute button
|
||||
- [ ] Fetch bookings on window focus but not when rerouting dialog is open. As soon as it is closed, we need to refetch again.
|
||||
- [ ] Seated Events
|
||||
- [ ] Disable routing for seated events. Disable only during creation.
|
||||
- [ ] When rescheduling to a new event, the booking title remains same which will most probably not match the event-type title. This is the behaviour of reschedule. Should we use the new event-type title?
|
||||
- [ ] What params should we forward to the booking page that we show after rerouting
|
||||
- [ ] On completing the rerouting just show the new Routing status
|
||||
- [ ] We need to disallow changing the email identifier field as during a reschedule user isn't allowed to change their email currently. Allowing to change that email response would mean that we support changing email during reschedule which might be disabled for some reasons unknown yet.
|
||||
- [ ] What if there are changes to Form before rerouting but after initial routing.
|
||||
- [ ] Not able to prefill rescheduleReason due to a bug in useInitialFormValues hook
|
||||
- [ ] It is becoming a requirement to have BookingAttempt record to allow to store reroutingFormResponses as well as teamMemberIds in it. Other query params could also be stored later on when needed. It is important to reduce the payload of the query params due to routedTeamMemberIds and reroutingFormResponses
|
||||
|
||||
|
||||
### Performance Tests and Improvements
|
||||
- [ ] Test with ~1000 team members and ~100 attributes.
|
||||
@@ -34,22 +58,22 @@
|
||||
- [x] getRoutedUsers tests
|
||||
- [ ] getAvailableSlots
|
||||
- [ ] should use routedTeamMemberIds in availability query
|
||||
- [ ] RerouteDialog
|
||||
- [x] BASIC
|
||||
- [ ] New Tab rescheduling
|
||||
|
||||
|
||||
### Documentation / Tooltip
|
||||
- [ ] Document well that the option label in Routing Form Field and Attribute Option label must be same to connect them.
|
||||
- Due to the connection requirement b/w Attribute Option and Field Option, we use label(lowercased) to match attributes instead of attribute slug
|
||||
- [ ] Fixed hosts of the event will be included through attribute routing as well. They aren't tested for attribute routing logic.
|
||||
- [ ] When re-routed, the booking page doesn't allow rescheduling/cancellation to avoid any possible issues. We can open it up later.
|
||||
- [ ] Booking with seats not supported yet. Need to figure out which seats should be re-routed or if re-routing makes sense for it even?
|
||||
- [ ] Hashed link re-routing doesn't make sense with. With Routing you route to an event from form and it doesn't involve hashed link even if it is enabled
|
||||
- [ ] User needs to ensure for now that the team event they redirect to has 'Assign all and future members of the team' checked.
|
||||
|
||||
### V2.0
|
||||
- [ ] Fallback for when no team member matches the criteria.
|
||||
- Fallback will be attributes query builder that would match a different set of users. Though the booking will use the team members assigned to the event type, it might be better to be able to identify such a scenario and use a different set of users. It also makes it easy to identify when the fallback scenario happens.
|
||||
- [ ] cal.routedTeamMembersIds query param - Could possible become a big payload and possibly break the URL limit. We could work on a short-lived row in a table that would hold that info and we pass the id of that row only in query param. handleNewBooking can then retrieve the routedTeamMembersIds from that short-lived row and delete the entry after successfully creating a booking.
|
||||
- [ ] Better ability to test with contact owner from Routing Form Preview itself(if possible). Right now, we need to test the entire booking flow to verify that.
|
||||
|
||||
|
||||
## TODO - Attributes
|
||||
- [ ] Attributes configuration
|
||||
1. through DB initially for POC
|
||||
2. through CSV upload
|
||||
3. through Salesforce Connect
|
||||
- [ ] Better ability to test with contact owner from Routing Form Preview itself(if possible). Right now, we need to test the entire booking flow to verify that.
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { App_RoutingForms_Form } from "@prisma/client";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
|
||||
import { SkeletonText } from "@calcom/ui";
|
||||
|
||||
import getFieldIdentifier from "../lib/getFieldIdentifier";
|
||||
import { getQueryBuilderConfigForFormFields } from "../lib/getQueryBuilderConfig";
|
||||
import isRouterLinkedField from "../lib/isRouterLinkedField";
|
||||
@@ -8,14 +10,21 @@ import { getUIOptionsForSelect } from "../lib/selectOptions";
|
||||
import { getFieldResponseForJsonLogic } from "../lib/transformResponse";
|
||||
import type { SerializableForm, FormResponse } from "../types/types";
|
||||
|
||||
type Props = {
|
||||
form: SerializableForm<App_RoutingForms_Form>;
|
||||
export type FormInputFieldsProps = {
|
||||
form: Pick<SerializableForm<App_RoutingForms_Form>, "fields">;
|
||||
/**
|
||||
* Make sure that response is updated by setResponse
|
||||
*/
|
||||
response: FormResponse;
|
||||
setResponse: Dispatch<SetStateAction<FormResponse>>;
|
||||
/**
|
||||
* Identifier of the fields that should be disabled
|
||||
*/
|
||||
disabledFields?: string[];
|
||||
};
|
||||
|
||||
export default function FormInputFields(props: Props) {
|
||||
const { form, response, setResponse } = props;
|
||||
export default function FormInputFields(props: FormInputFieldsProps) {
|
||||
const { form, response, setResponse, disabledFields = [] } = props;
|
||||
|
||||
const formFieldsQueryBuilderConfig = getQueryBuilderConfigForFormFields(form);
|
||||
|
||||
@@ -33,6 +42,7 @@ export default function FormInputFields(props: Props) {
|
||||
const Component = widget.factory;
|
||||
|
||||
const options = getUIOptionsForSelect(field);
|
||||
const fieldIdentifier = getFieldIdentifier(field);
|
||||
return (
|
||||
<div key={field.id} className="mb-4 block flex-col sm:flex ">
|
||||
<div className="min-w-48 mb-2 flex-grow">
|
||||
@@ -48,10 +58,10 @@ export default function FormInputFields(props: Props) {
|
||||
/* @ts-ignore */
|
||||
required={!!field.required}
|
||||
listValues={options}
|
||||
data-testid={`form-field-${getFieldIdentifier(field)}`}
|
||||
disabled={disabledFields?.includes(fieldIdentifier)}
|
||||
data-testid={`form-field-${fieldIdentifier}`}
|
||||
setValue={(value: number | string | string[]) => {
|
||||
setResponse((response) => {
|
||||
response = response || {};
|
||||
setResponse(() => {
|
||||
return {
|
||||
...response,
|
||||
[field.id]: {
|
||||
@@ -68,3 +78,17 @@ export default function FormInputFields(props: Props) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const FormInputFieldsSkeleton = () => {
|
||||
const numberOfFields = 5;
|
||||
return (
|
||||
<>
|
||||
{Array.from({ length: numberOfFields }).map((_, index) => (
|
||||
<div key={index} className="mb-4 block flex-col sm:flex ">
|
||||
<SkeletonText className="mb-2 h-3.5 w-64" />
|
||||
<SkeletonText className="mb-2 h-9 w-32 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,16 +1,17 @@
|
||||
import type { LocalRoute } from "../types/types";
|
||||
import { RouteActionType } from "../zod";
|
||||
|
||||
export const RoutingPages: { label: string; value: NonNullable<LocalRoute["action"]>["type"] }[] = [
|
||||
{
|
||||
label: "Custom Page",
|
||||
value: "customPageMessage",
|
||||
value: RouteActionType.CustomPageMessage,
|
||||
},
|
||||
{
|
||||
label: "External Redirect",
|
||||
value: "externalRedirectUrl",
|
||||
value: RouteActionType.ExternalRedirectUrl,
|
||||
},
|
||||
{
|
||||
label: "Event Redirect",
|
||||
value: "eventTypeRedirectUrl",
|
||||
value: RouteActionType.EventTypeRedirectUrl,
|
||||
},
|
||||
];
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Utils as QbUtils } from "react-awesome-query-builder";
|
||||
|
||||
import type { GlobalRoute, LocalRoute, SerializableRoute } from "../types/types";
|
||||
import { RouteActionType } from "../zod";
|
||||
|
||||
export const createFallbackRoute = (): Exclude<SerializableRoute, GlobalRoute> => {
|
||||
const uuid = QbUtils.uuid();
|
||||
@@ -8,7 +9,7 @@ export const createFallbackRoute = (): Exclude<SerializableRoute, GlobalRoute> =
|
||||
id: uuid,
|
||||
isFallback: true,
|
||||
action: {
|
||||
type: "customPageMessage",
|
||||
type: RouteActionType.CustomPageMessage,
|
||||
value: "Thank you for your interest! We will be in touch soon.",
|
||||
},
|
||||
queryValue: { id: uuid, type: "group" } as LocalRoute["queryValue"],
|
||||
|
||||
@@ -14,7 +14,7 @@ export function findMatchingRoute({
|
||||
form,
|
||||
response,
|
||||
}: {
|
||||
form: SerializableForm<App_RoutingForms_Form>;
|
||||
form: Pick<SerializableForm<App_RoutingForms_Form>, "routes" | "fields">;
|
||||
response: Record<string, Pick<FormResponse[string], "value">>;
|
||||
}) {
|
||||
const queryBuilderConfig = getQueryBuilderConfigForFormFields(form);
|
||||
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
import isRouter from "../../lib/isRouter";
|
||||
import type { SerializableForm } from "../../types/types";
|
||||
import type { GlobalRoute, LocalRoute, SerializableRoute, Attribute } from "../../types/types";
|
||||
import { RouteActionType } from "../../zod";
|
||||
|
||||
type FormFieldsQueryBuilderState = {
|
||||
tree: ImmutableTree;
|
||||
@@ -61,6 +62,7 @@ type LocalRouteWithRaqbStates = LocalRoute & {
|
||||
type Form = inferSSRProps<typeof getServerSideProps>["form"];
|
||||
|
||||
type Route = LocalRouteWithRaqbStates | GlobalRoute;
|
||||
type SetRoute = (id: string, route: Partial<Route>) => void;
|
||||
|
||||
const RoundRobinContactOwnerOverrideSwitch = ({
|
||||
route,
|
||||
@@ -93,6 +95,42 @@ type AttributesQueryValue = NonNullable<LocalRoute["attributesQueryValue"]>;
|
||||
type FormFieldsQueryValue = LocalRoute["queryValue"];
|
||||
type AttributeRoutingConfig = NonNullable<LocalRoute["attributeRoutingConfig"]>;
|
||||
|
||||
/**
|
||||
* We need eventTypeId in every redirect url action now for Rerouting to work smoothly.
|
||||
* This hook ensures that it is there as soon as someone lands on a Routing Form and next save would automatically update it for them.
|
||||
*/
|
||||
function useEnsureEventTypeIdInRedirectUrlAction({
|
||||
route,
|
||||
eventOptions,
|
||||
setRoute,
|
||||
}: {
|
||||
route: Route;
|
||||
eventOptions: { label: string; value: string; eventTypeId: number }[];
|
||||
setRoute: SetRoute;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
if (isRouter(route)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
route.action.type !== RouteActionType.EventTypeRedirectUrl ||
|
||||
// Must not be set already. Could be zero as well for custom
|
||||
route.action.eventTypeId !== undefined
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const matchingOption = eventOptions.find((eventOption) => eventOption.value === route.action.value);
|
||||
if (!matchingOption) {
|
||||
return;
|
||||
}
|
||||
setRoute(route.id, {
|
||||
action: { ...route.action, eventTypeId: matchingOption.eventTypeId },
|
||||
});
|
||||
}, [eventOptions, setRoute, route.id, (route as unknown as any).action?.value]);
|
||||
}
|
||||
|
||||
const hasRules = (route: Route) => {
|
||||
if (isRouter(route)) return false;
|
||||
route.queryValue.children1 && Object.keys(route.queryValue.children1).length;
|
||||
@@ -106,7 +144,7 @@ const getEmptyRoute = (): Exclude<SerializableRoute, GlobalRoute> => {
|
||||
return {
|
||||
id: uuid,
|
||||
action: {
|
||||
type: "eventTypeRedirectUrl",
|
||||
type: RouteActionType.EventTypeRedirectUrl,
|
||||
value: "",
|
||||
},
|
||||
// It is actually formFieldsQueryValue
|
||||
@@ -184,7 +222,7 @@ const Route = ({
|
||||
form: Form;
|
||||
route: Route;
|
||||
routes: Route[];
|
||||
setRoute: (id: string, route: Partial<Route>) => void;
|
||||
setRoute: SetRoute;
|
||||
setAttributeRoutingConfig: (id: string, attributeRoutingConfig: Partial<AttributeRoutingConfig>) => void;
|
||||
formFieldsQueryBuilderConfig: FormFieldsQueryBuilderConfigWithRaqbFields;
|
||||
attributesQueryBuilderConfig: AttributesQueryBuilderConfigWithRaqbFields | null;
|
||||
@@ -221,6 +259,12 @@ const Route = ({
|
||||
}
|
||||
}, [isLoading]);
|
||||
|
||||
useEnsureEventTypeIdInRedirectUrlAction({
|
||||
route,
|
||||
eventOptions,
|
||||
setRoute,
|
||||
});
|
||||
|
||||
const onChangeFormFieldsQuery = (
|
||||
route: Route,
|
||||
immutableTree: ImmutableTree,
|
||||
@@ -336,7 +380,7 @@ const Route = ({
|
||||
) : null;
|
||||
|
||||
const attributesQueryBuilder =
|
||||
route.action?.type === "eventTypeRedirectUrl" && isTeamForm ? (
|
||||
route.action?.type === RouteActionType.EventTypeRedirectUrl && isTeamForm ? (
|
||||
<div className="mt-4">
|
||||
<span className="text-emphasis flex w-full items-center text-sm">
|
||||
and use only the Team Members that match the following criteria(matches all by default)
|
||||
@@ -453,11 +497,13 @@ const Route = ({
|
||||
}
|
||||
if (option.value !== "custom") {
|
||||
setRoute(route.id, {
|
||||
action: { ...route.action, value: option.value },
|
||||
action: { ...route.action, value: option.value, eventTypeId: option.eventTypeId },
|
||||
});
|
||||
setCustomEventTypeSlug("");
|
||||
} else {
|
||||
setRoute(route.id, { action: { ...route.action, value: "custom" } });
|
||||
setRoute(route.id, {
|
||||
action: { ...route.action, value: "custom", eventTypeId: 0 },
|
||||
});
|
||||
setCustomEventTypeSlug("");
|
||||
}
|
||||
}}
|
||||
|
||||
+44
-10
@@ -1,19 +1,13 @@
|
||||
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
|
||||
|
||||
import getFieldIdentifier from "../../lib/getFieldIdentifier";
|
||||
import type { LocalRoute } from "../../types/types";
|
||||
import type { FormResponse, LocalRoute } from "../../types/types";
|
||||
import type { getServerSideProps } from "./getServerSideProps";
|
||||
|
||||
type FormResponseValueOnly = { [key: string]: { value: FormResponse[keyof FormResponse]["value"] } };
|
||||
type Props = inferSSRProps<typeof getServerSideProps>;
|
||||
type AttributeRoutingConfig = NonNullable<LocalRoute["attributeRoutingConfig"]>;
|
||||
export function getUrlSearchParamsToForward({
|
||||
formResponse,
|
||||
fields,
|
||||
searchParams,
|
||||
teamMembersMatchingAttributeLogic,
|
||||
formResponseId,
|
||||
attributeRoutingConfig,
|
||||
}: {
|
||||
type GetUrlSearchParamsToForwardOptions = {
|
||||
formResponse: Record<
|
||||
string,
|
||||
{
|
||||
@@ -28,7 +22,18 @@ export function getUrlSearchParamsToForward({
|
||||
formResponseId: number;
|
||||
teamMembersMatchingAttributeLogic: number[] | null;
|
||||
attributeRoutingConfig: AttributeRoutingConfig | null;
|
||||
}) {
|
||||
reroutingFormResponses?: FormResponseValueOnly;
|
||||
};
|
||||
|
||||
export function getUrlSearchParamsToForward({
|
||||
formResponse,
|
||||
fields,
|
||||
searchParams,
|
||||
teamMembersMatchingAttributeLogic,
|
||||
formResponseId,
|
||||
attributeRoutingConfig,
|
||||
reroutingFormResponses,
|
||||
}: GetUrlSearchParamsToForwardOptions) {
|
||||
type Params = Record<string, string | string[]>;
|
||||
const paramsFromResponse: Params = {};
|
||||
const paramsFromCurrentUrl: Params = {};
|
||||
@@ -84,6 +89,9 @@ export function getUrlSearchParamsToForward({
|
||||
: null),
|
||||
["cal.routingFormResponseId"]: String(formResponseId),
|
||||
...(attributeRoutingConfig?.skipContactOwner ? { ["cal.skipContactOwner"]: "true" } : {}),
|
||||
...(reroutingFormResponses
|
||||
? { ["cal.reroutingFormResponses"]: JSON.stringify(reroutingFormResponses) }
|
||||
: null),
|
||||
};
|
||||
|
||||
const allQueryURLSearchParams = new URLSearchParams();
|
||||
@@ -98,3 +106,29 @@ export function getUrlSearchParamsToForward({
|
||||
|
||||
return allQueryURLSearchParams;
|
||||
}
|
||||
|
||||
export function getUrlSearchParamsToForwardForReroute({
|
||||
formResponse,
|
||||
formResponseId,
|
||||
fields,
|
||||
searchParams,
|
||||
teamMembersMatchingAttributeLogic,
|
||||
attributeRoutingConfig,
|
||||
rescheduleUid,
|
||||
reroutingFormResponses,
|
||||
}: GetUrlSearchParamsToForwardOptions & {
|
||||
rescheduleUid: string;
|
||||
reroutingFormResponses: FormResponseValueOnly;
|
||||
}) {
|
||||
searchParams.set("rescheduleUid", rescheduleUid);
|
||||
searchParams.set("cal.rerouting", "true");
|
||||
return getUrlSearchParamsToForward({
|
||||
formResponse,
|
||||
formResponseId,
|
||||
fields,
|
||||
searchParams,
|
||||
teamMembersMatchingAttributeLogic,
|
||||
attributeRoutingConfig,
|
||||
reroutingFormResponses,
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import type { BaseWidget } from "react-awesome-query-builder";
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
import type { AttributeType } from "@calcom/prisma/enums";
|
||||
import { RouteActionType } from "@calcom/app-store/routing-forms/zod";
|
||||
|
||||
import { RoutingFormFieldType } from "../../lib/FieldTypes";
|
||||
import { RaqbLogicResult } from "../../lib/evaluateRaqbLogic";
|
||||
@@ -141,7 +142,7 @@ function buildRoute({
|
||||
}: {
|
||||
id: string;
|
||||
action: {
|
||||
type: "customPageMessage" | "externalRedirectUrl" | "eventTypeRedirectUrl";
|
||||
type: RouteActionType;
|
||||
value: string;
|
||||
};
|
||||
queryValue: FormFieldsQueryValue;
|
||||
@@ -164,7 +165,7 @@ function buildDefaultCustomPageRoute({
|
||||
}) {
|
||||
return buildRoute({
|
||||
id,
|
||||
action: { type: "customPageMessage", value: "test" },
|
||||
action: { type: RouteActionType.CustomPageMessage, value: "test" },
|
||||
queryValue: { type: "group" } as unknown as FormFieldsQueryValue,
|
||||
attributesQueryValue,
|
||||
});
|
||||
@@ -193,7 +194,7 @@ describe("findTeamMembersMatchingAttributeLogicOfRoute", () => {
|
||||
{
|
||||
id: "test-route",
|
||||
queryValue: { type: "group" } as unknown as FormFieldsQueryValue,
|
||||
action: { type: "customPageMessage", value: "test" },
|
||||
action: { type: RouteActionType.CustomPageMessage, value: "test" },
|
||||
},
|
||||
],
|
||||
fields: [],
|
||||
@@ -238,7 +239,7 @@ describe("findTeamMembersMatchingAttributeLogicOfRoute", () => {
|
||||
routes: [
|
||||
{
|
||||
id: "test-route",
|
||||
action: { type: "customPageMessage", value: "test" },
|
||||
action: { type: RouteActionType.CustomPageMessage, value: "test" },
|
||||
queryValue: {
|
||||
type: "group",
|
||||
} as unknown as FormFieldsQueryValue,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import authedProcedure from "@calcom/trpc/server/procedures/authedProcedure";
|
||||
import publicProcedure from "@calcom/trpc/server/procedures/publicProcedure";
|
||||
import { router } from "@calcom/trpc/server/trpc";
|
||||
@@ -45,6 +47,12 @@ const getHandler = async <
|
||||
return UNSTABLE_HANDLER_CACHE[nameInCache] as unknown as T["default"];
|
||||
};
|
||||
|
||||
export const ZFormByResponseIdInputSchema = z.object({
|
||||
formResponseId: z.number(),
|
||||
});
|
||||
|
||||
export type TFormQueryInputSchema = z.infer<typeof ZFormQueryInputSchema>;
|
||||
|
||||
const appRoutingForms = router({
|
||||
public: router({
|
||||
response: publicProcedure.input(ZResponseInputSchema).mutation(async ({ ctx, input }) => {
|
||||
@@ -57,6 +65,15 @@ const appRoutingForms = router({
|
||||
const handler = await getHandler("formQuery", () => import("./formQuery.handler"));
|
||||
return handler({ ctx, input });
|
||||
}),
|
||||
getResponseWithFormFields: authedProcedure
|
||||
.input(ZFormByResponseIdInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const handler = await getHandler(
|
||||
"getResponseWithFormFields",
|
||||
() => import("./getResponseWithFormFields.handler")
|
||||
);
|
||||
return handler({ ctx, input });
|
||||
}),
|
||||
formMutation: authedProcedure.input(ZFormMutationInputSchema).mutation(async ({ ctx, input }) => {
|
||||
const handler = await getHandler("formMutation", () => import("./formMutation.handler"));
|
||||
return handler({ ctx, input });
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import type { z } from "zod";
|
||||
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import { enrichFormWithMigrationData } from "../enrichFormWithMigrationData";
|
||||
import { getSerializableForm } from "../lib/getSerializableForm";
|
||||
import type { FormResponse } from "../types/types";
|
||||
import type { ZFormByResponseIdInputSchema } from "./_router";
|
||||
import { canEditEntity } from "@calcom/lib/entityPermissionUtils";
|
||||
|
||||
type GetResponseWithFormFieldsOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
};
|
||||
input: z.infer<typeof ZFormByResponseIdInputSchema>;
|
||||
};
|
||||
|
||||
async function getResponseWithFormFieldsHandler({ ctx, input }: GetResponseWithFormFieldsOptions) {
|
||||
const { user } = ctx;
|
||||
const { formResponseId } = input;
|
||||
|
||||
|
||||
const formResponse = await prisma.app_RoutingForms_FormResponse.findUnique({
|
||||
where: {
|
||||
id: formResponseId,
|
||||
},
|
||||
include: {
|
||||
form: {
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
movedToProfileId: true,
|
||||
organization: {
|
||||
select: {
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
username: true,
|
||||
theme: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
metadata: true,
|
||||
},
|
||||
},
|
||||
team: {
|
||||
select: {
|
||||
members: true,
|
||||
slug: true,
|
||||
parent: {
|
||||
select: { slug: true },
|
||||
},
|
||||
parentId: true,
|
||||
metadata: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!formResponse) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Form response not found",
|
||||
});
|
||||
}
|
||||
|
||||
const form = formResponse.form;
|
||||
|
||||
if (!canEditEntity(form, user.id)) {
|
||||
throw new TRPCError({
|
||||
code: "FORBIDDEN",
|
||||
message: "You don't have access to this form",
|
||||
});
|
||||
}
|
||||
|
||||
const { UserRepository } = await import("@calcom/lib/server/repository/user");
|
||||
const formWithUserProfile = {
|
||||
...form,
|
||||
user: await UserRepository.enrichUserWithItsProfile({ user: form.user }),
|
||||
};
|
||||
|
||||
return {
|
||||
response: formResponse.response as FormResponse,
|
||||
form: await getSerializableForm({ form: enrichFormWithMigrationData(formWithUserProfile) }),
|
||||
};
|
||||
}
|
||||
|
||||
export default getResponseWithFormFieldsHandler;
|
||||
@@ -36,7 +36,7 @@ function compatibleForAttributeAndFormFieldMatch<T extends string | string[]>(
|
||||
) as T extends string[] ? string[] : string;
|
||||
}
|
||||
|
||||
const raqbQueryValueUtils = {
|
||||
export const raqbQueryValueUtils = {
|
||||
isQueryValueARuleGroup: function isQueryValueARuleGroup(queryValue: JsonTree): queryValue is JsonGroup {
|
||||
return queryValue.type === "group";
|
||||
},
|
||||
@@ -77,6 +77,12 @@ const raqbQueryValueUtils = {
|
||||
|
||||
return raqbFieldValueType;
|
||||
},
|
||||
isQueryValueEmpty: function isQueryValueEmpty(queryValue: JsonTree | null): queryValue is null {
|
||||
if (!queryValue) {
|
||||
return true;
|
||||
}
|
||||
return !queryValue.children1;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ import isRouter from "../lib/isRouter";
|
||||
import jsonLogic from "../lib/jsonLogic";
|
||||
import type { SerializableField, OrderedResponses, AttributesQueryValue } from "../types/types";
|
||||
import type { FormResponse, SerializableForm } from "../types/types";
|
||||
import { acrossQueryValueCompatiblity } from "./raqbUtils";
|
||||
import { acrossQueryValueCompatiblity, raqbQueryValueUtils } from "./raqbUtils";
|
||||
|
||||
const {
|
||||
getAttributesData: getAttributes,
|
||||
@@ -201,7 +201,7 @@ export async function findTeamMembersMatchingAttributeLogicOfRoute(
|
||||
})
|
||||
);
|
||||
|
||||
if (!attributesQueryValue) {
|
||||
if (raqbQueryValueUtils.isQueryValueEmpty(attributesQueryValue)) {
|
||||
return {
|
||||
teamMembersMatchingAttributeLogic: null,
|
||||
timeTaken: {
|
||||
|
||||
@@ -55,6 +55,13 @@ const queryValueSchema = z.object({
|
||||
properties: z.any(),
|
||||
});
|
||||
|
||||
export enum RouteActionType {
|
||||
CustomPageMessage = "customPageMessage",
|
||||
ExternalRedirectUrl = "externalRedirectUrl",
|
||||
EventTypeRedirectUrl = "eventTypeRedirectUrl",
|
||||
}
|
||||
|
||||
export const routeActionTypeSchema = z.nativeEnum(RouteActionType);
|
||||
/**
|
||||
* Stricter schema for validating before saving to DB
|
||||
*/
|
||||
@@ -132,12 +139,8 @@ export const zodNonRouterRoute = z.object({
|
||||
attributesQueryValue: queryValueSchema.brand<"attributesQueryValue">().optional(),
|
||||
isFallback: z.boolean().optional(),
|
||||
action: z.object({
|
||||
// TODO: Make it a union type of "customPageMessage" and ..
|
||||
type: z.union([
|
||||
z.literal("customPageMessage"),
|
||||
z.literal("externalRedirectUrl"),
|
||||
z.literal("eventTypeRedirectUrl"),
|
||||
]),
|
||||
type: routeActionTypeSchema,
|
||||
eventTypeId: z.number().optional(),
|
||||
value: z.string(),
|
||||
}),
|
||||
});
|
||||
@@ -170,3 +173,11 @@ export const zodRoutesView = z.union([z.array(zodRouteView), z.null()]).optional
|
||||
export const appDataSchema = z.any();
|
||||
|
||||
export const appKeysSchema = z.object({});
|
||||
|
||||
// This is different from FormResponse in types.d.ts in that it has label optional. We don't seem to be using label at this point, so we might want to use this only while saving the response when Routing Form is submitted
|
||||
export const routingFormResponseInDbSchema = z.record(
|
||||
z.object({
|
||||
label: z.string().optional(),
|
||||
value: z.union([z.string(), z.number(), z.array(z.string())]),
|
||||
})
|
||||
);
|
||||
@@ -47,7 +47,7 @@ export const mapBookingToMutationInput = ({
|
||||
const routingFormResponseIdParam = searchParams.get("cal.routingFormResponseId");
|
||||
const routingFormResponseId = routingFormResponseIdParam ? Number(routingFormResponseIdParam) : undefined;
|
||||
const skipContactOwner = searchParams.get("cal.skipContactOwner") === "true";
|
||||
|
||||
const reroutingFormResponses = searchParams.get("cal.reroutingFormResponses");
|
||||
return {
|
||||
...values,
|
||||
user: username,
|
||||
@@ -72,6 +72,8 @@ export const mapBookingToMutationInput = ({
|
||||
routedTeamMemberIds,
|
||||
routingFormResponseId,
|
||||
skipContactOwner,
|
||||
// In case of rerouting, the form responses are actually the responses that we need to update.
|
||||
reroutingFormResponses: reroutingFormResponses ? JSON.parse(reroutingFormResponses) : undefined,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -235,6 +235,8 @@ async function handler(
|
||||
rescheduleReason,
|
||||
luckyUsers,
|
||||
routedTeamMemberIds,
|
||||
reroutingFormResponses,
|
||||
routingFormResponseId,
|
||||
...reqBody
|
||||
} = bookingData;
|
||||
|
||||
@@ -918,24 +920,12 @@ async function handler(
|
||||
})
|
||||
);
|
||||
|
||||
// update original rescheduled booking (no seats event)
|
||||
if (!eventType.seatsPerTimeSlot && originalRescheduledBooking?.uid) {
|
||||
await prisma.booking.update({
|
||||
where: {
|
||||
id: originalRescheduledBooking.id,
|
||||
},
|
||||
data: {
|
||||
rescheduled: true,
|
||||
status: BookingStatus.CANCELLED,
|
||||
rescheduledBy: reqBody.rescheduledBy,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
booking = await createBooking({
|
||||
uid,
|
||||
routedFromRoutingFormResponseId: reqBody.routingFormResponseId,
|
||||
rescheduledBy: reqBody.rescheduledBy,
|
||||
routingFormResponseId: routingFormResponseId,
|
||||
reroutingFormResponses: reroutingFormResponses ?? null,
|
||||
reqBody: {
|
||||
user: reqBody.user,
|
||||
metadata: reqBody.metadata,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import type short from "short-uuid";
|
||||
import type { z } from "zod";
|
||||
|
||||
import type { routingFormResponseInDbSchema } from "@calcom/app-store/routing-forms/zod";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { isPrismaObjOrUndefined } from "@calcom/lib";
|
||||
import prisma from "@calcom/prisma";
|
||||
@@ -21,7 +23,9 @@ type ReqBodyWithEnd = TgetBookingDataSchema & { end: string };
|
||||
|
||||
type CreateBookingParams = {
|
||||
uid: short.SUUID;
|
||||
routedFromRoutingFormResponseId: number | undefined;
|
||||
routingFormResponseId: number | undefined;
|
||||
reroutingFormResponses: z.infer<typeof routingFormResponseInDbSchema> | null;
|
||||
rescheduledBy: string | undefined;
|
||||
reqBody: {
|
||||
user: ReqBodyWithEnd["user"];
|
||||
metadata: ReqBodyWithEnd["metadata"];
|
||||
@@ -78,21 +82,20 @@ export async function createBooking({
|
||||
input,
|
||||
evt,
|
||||
originalRescheduledBooking,
|
||||
routedFromRoutingFormResponseId,
|
||||
}: CreateBookingParams) {
|
||||
routingFormResponseId,
|
||||
reroutingFormResponses,
|
||||
rescheduledBy,
|
||||
}: CreateBookingParams & { rescheduledBy: string | undefined }) {
|
||||
updateEventDetails(evt, originalRescheduledBooking, input.changedOrganizer);
|
||||
const associatedBookingForFormResponse = routedFromRoutingFormResponseId
|
||||
? await getAssociatedBookingForFormResponse(routedFromRoutingFormResponseId)
|
||||
const associatedBookingForFormResponse = routingFormResponseId
|
||||
? await getAssociatedBookingForFormResponse(routingFormResponseId)
|
||||
: null;
|
||||
|
||||
const newBookingData = buildNewBookingData({
|
||||
const bookingAndAssociatedData = buildNewBookingData({
|
||||
uid,
|
||||
// We allow only the first booking to be connected to the form response
|
||||
// Other bookings could happen due to user doing a booking by using browser back button to reach the same booking form with same query params and changing the time
|
||||
// Such case isn't what the Routing Form redirected the user to, so we avoid this at the moment.
|
||||
routedFromRoutingFormResponseId: associatedBookingForFormResponse
|
||||
? undefined
|
||||
: routedFromRoutingFormResponseId,
|
||||
rescheduledBy,
|
||||
routingFormResponseId: shouldConnectBookingToFormResponse() ? routingFormResponseId : undefined,
|
||||
reroutingFormResponses,
|
||||
reqBody,
|
||||
eventType,
|
||||
input,
|
||||
@@ -101,19 +104,38 @@ export async function createBooking({
|
||||
});
|
||||
|
||||
return await saveBooking(
|
||||
newBookingData,
|
||||
bookingAndAssociatedData,
|
||||
originalRescheduledBooking,
|
||||
eventType.paymentAppData,
|
||||
eventType.organizerUser
|
||||
);
|
||||
|
||||
function shouldConnectBookingToFormResponse() {
|
||||
const isRerouting = !!reroutingFormResponses;
|
||||
|
||||
// During rerouting, we want to connect the new booking to the existing form response for booking being rescheduled(original booking)
|
||||
if (isRerouting) {
|
||||
return true;
|
||||
}
|
||||
// If not rerouting and there is already an associated booking for the form response, we don't want to connect the new booking to the form response
|
||||
// We allow only the first booking to be connected to the form response
|
||||
// Other bookings could happen due to user doing a booking by using browser back button to reach the same booking form with same query params and changing the time
|
||||
// Such case isn't what the Routing Form redirected the user to, so we avoid this at the moment.
|
||||
if (associatedBookingForFormResponse) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveBooking(
|
||||
newBookingData: Prisma.BookingCreateInput,
|
||||
bookingAndAssociatedData: ReturnType<typeof buildNewBookingData>,
|
||||
originalRescheduledBooking: OriginalRescheduledBooking,
|
||||
paymentAppData: PaymentAppData,
|
||||
organizerUser: CreateBookingParams["eventType"]["organizerUser"]
|
||||
) {
|
||||
const { newBookingData, reroutingFormResponseUpdateData, originalBookingUpdateDataForCancellation } =
|
||||
bookingAndAssociatedData;
|
||||
const createBookingObj = {
|
||||
include: {
|
||||
user: {
|
||||
@@ -143,7 +165,21 @@ async function saveBooking(
|
||||
});
|
||||
}
|
||||
|
||||
return prisma.booking.create(createBookingObj);
|
||||
/**
|
||||
* Reschedule(Cancellation + Creation) with an update of reroutingFormResponse should be atomic
|
||||
*/
|
||||
return prisma.$transaction(async (tx) => {
|
||||
if (originalBookingUpdateDataForCancellation) {
|
||||
await tx.booking.update(originalBookingUpdateDataForCancellation);
|
||||
}
|
||||
|
||||
const booking = await tx.booking.create(createBookingObj);
|
||||
if (reroutingFormResponseUpdateData) {
|
||||
await tx.app_RoutingForms_FormResponse.update(reroutingFormResponseUpdateData);
|
||||
}
|
||||
|
||||
return booking;
|
||||
});
|
||||
}
|
||||
|
||||
function getEventTypeRel(eventTypeId: EventTypeId) {
|
||||
@@ -164,12 +200,25 @@ function getAttendeesData(evt: Pick<CalendarEvent, "attendees" | "team">) {
|
||||
}));
|
||||
}
|
||||
|
||||
function buildNewBookingData(params: CreateBookingParams): Prisma.BookingCreateInput {
|
||||
const { uid, evt, reqBody, eventType, input, originalRescheduledBooking, routedFromRoutingFormResponseId } =
|
||||
params;
|
||||
function buildNewBookingData(params: CreateBookingParams) {
|
||||
const {
|
||||
uid,
|
||||
evt,
|
||||
reqBody,
|
||||
eventType,
|
||||
input,
|
||||
originalRescheduledBooking,
|
||||
routingFormResponseId,
|
||||
reroutingFormResponses,
|
||||
rescheduledBy,
|
||||
} = params;
|
||||
|
||||
const attendeesData = getAttendeesData(evt);
|
||||
const eventTypeRel = getEventTypeRel(eventType.id);
|
||||
const reroutingFormResponseUpdateData = getReroutingFormResponseUpdateData({
|
||||
reroutingFormResponses,
|
||||
routingFormResponseId,
|
||||
});
|
||||
|
||||
const newBookingData: Prisma.BookingCreateInput = {
|
||||
uid,
|
||||
@@ -206,8 +255,8 @@ function buildNewBookingData(params: CreateBookingParams): Prisma.BookingCreateI
|
||||
}
|
||||
: undefined,
|
||||
|
||||
routedFromRoutingFormReponse: routedFromRoutingFormResponseId
|
||||
? { connect: { id: routedFromRoutingFormResponseId } }
|
||||
routedFromRoutingFormReponse: routingFormResponseId
|
||||
? { connect: { id: routingFormResponseId } }
|
||||
: undefined,
|
||||
};
|
||||
|
||||
@@ -215,6 +264,8 @@ function buildNewBookingData(params: CreateBookingParams): Prisma.BookingCreateI
|
||||
newBookingData.recurringEventId = reqBody.recurringEventId;
|
||||
}
|
||||
|
||||
let originalBookingUpdateDataForCancellation: Prisma.BookingUpdateArgs | undefined = undefined;
|
||||
|
||||
if (originalRescheduledBooking) {
|
||||
newBookingData.metadata = {
|
||||
...(typeof originalRescheduledBooking.metadata === "object" && originalRescheduledBooking.metadata),
|
||||
@@ -235,12 +286,53 @@ function buildNewBookingData(params: CreateBookingParams): Prisma.BookingCreateI
|
||||
(attendee) => attendee.email === input.bookerEmail
|
||||
);
|
||||
}
|
||||
|
||||
if (originalRescheduledBooking.recurringEventId) {
|
||||
newBookingData.recurringEventId = originalRescheduledBooking.recurringEventId;
|
||||
}
|
||||
|
||||
if (!evt.seatsPerTimeSlot && originalRescheduledBooking?.uid) {
|
||||
originalBookingUpdateDataForCancellation = {
|
||||
where: {
|
||||
id: originalRescheduledBooking.id,
|
||||
},
|
||||
data: {
|
||||
rescheduled: true,
|
||||
status: BookingStatus.CANCELLED,
|
||||
rescheduledBy: rescheduledBy,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return newBookingData;
|
||||
return {
|
||||
newBookingData,
|
||||
reroutingFormResponseUpdateData,
|
||||
originalBookingUpdateDataForCancellation,
|
||||
};
|
||||
|
||||
function getReroutingFormResponseUpdateData({
|
||||
reroutingFormResponses,
|
||||
routingFormResponseId,
|
||||
}: {
|
||||
reroutingFormResponses: z.infer<typeof routingFormResponseInDbSchema> | null;
|
||||
routingFormResponseId: number | undefined | null;
|
||||
}) {
|
||||
if (!routingFormResponseId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!reroutingFormResponses) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
where: { id: routingFormResponseId },
|
||||
data: {
|
||||
response: reroutingFormResponses,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export type Booking = Prisma.PromiseReturnType<typeof createBooking>;
|
||||
@@ -57,6 +57,12 @@ export const useBookingSuccessRedirect = () => {
|
||||
query: Record<string, string | null | undefined | boolean>;
|
||||
booking: SuccessRedirectBookingType;
|
||||
}) => {
|
||||
// Ensures that the param is added both to external redirect url and booking success page URL
|
||||
query = {
|
||||
...query,
|
||||
"cal.rerouting": searchParams.get("cal.rerouting"),
|
||||
};
|
||||
|
||||
if (successRedirectUrl) {
|
||||
const url = new URL(successRedirectUrl);
|
||||
// Using parent ensures, Embed iframe would redirect outside of the iframe.
|
||||
|
||||
@@ -631,6 +631,7 @@ model Booking {
|
||||
cancelledBy String?
|
||||
/// @zod.email()
|
||||
rescheduledBy String?
|
||||
// Ah, made a typo here. Should have been routedFromRoutingFormRe"s"ponse. Live with it :(
|
||||
routedFromRoutingFormReponse App_RoutingForms_FormResponse?
|
||||
|
||||
@@index([eventTypeId])
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
} from "zod";
|
||||
|
||||
import { appDataSchemas } from "@calcom/app-store/apps.schemas.generated";
|
||||
import { routingFormResponseInDbSchema } from "@calcom/app-store/routing-forms/zod";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { isPasswordValid } from "@calcom/features/auth/lib/isPasswordValid";
|
||||
import type { FieldType as FormBuilderFieldType } from "@calcom/features/form-builder/schema";
|
||||
@@ -252,6 +253,11 @@ export const bookingCreateBodySchema = z.object({
|
||||
routedTeamMemberIds: z.array(z.number()).nullish(),
|
||||
routingFormResponseId: z.number().optional(),
|
||||
skipContactOwner: z.boolean().optional(),
|
||||
|
||||
/**
|
||||
* Holds the corrected responses of the Form for a booking, provided during rerouting
|
||||
*/
|
||||
reroutingFormResponses: routingFormResponseInDbSchema.optional(),
|
||||
});
|
||||
|
||||
export const requiredCustomInputSchema = z.union([
|
||||
@@ -745,4 +751,4 @@ export const getStringAsNumberRequiredSchema = (t: TFunction) =>
|
||||
export const bookingSeatDataSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
responses: bookingResponses,
|
||||
});
|
||||
});
|
||||
@@ -210,12 +210,23 @@ export async function getBookings({
|
||||
const bookingSelect = {
|
||||
...bookingMinimalSelect,
|
||||
uid: true,
|
||||
responses: true,
|
||||
/**
|
||||
* Who uses it -
|
||||
* 1. We need to be able to decide which booking can have a 'Reroute' action
|
||||
*/
|
||||
routedFromRoutingFormReponse: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
recurringEventId: true,
|
||||
location: true,
|
||||
eventType: {
|
||||
select: {
|
||||
slug: true,
|
||||
id: true,
|
||||
title: true,
|
||||
eventName: true,
|
||||
price: true,
|
||||
recurringEvent: true,
|
||||
@@ -225,10 +236,12 @@ export async function getBookings({
|
||||
seatsShowAvailabilityCount: true,
|
||||
eventTypeColor: true,
|
||||
schedulingType: true,
|
||||
length: true,
|
||||
team: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -90,12 +90,16 @@ type DialogContentProps = React.ComponentProps<(typeof DialogPrimitive)["Content
|
||||
Icon?: IconName;
|
||||
enableOverflow?: boolean;
|
||||
forceOverlayWhenNoModal?: boolean;
|
||||
/**
|
||||
* Disables the ability to close the dialog by clicking outside of it. Could be useful when the dialog is doing something critical which might be in progress.
|
||||
*/
|
||||
preventCloseOnOutsideClick?: boolean;
|
||||
};
|
||||
|
||||
// enableOverflow:- use this prop whenever content inside DialogContent could overflow and require scrollbar
|
||||
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
||||
(
|
||||
{ children, title, Icon: icon, enableOverflow, forceOverlayWhenNoModal, type = "creation", ...props },
|
||||
{ children, title, Icon: icon, enableOverflow, forceOverlayWhenNoModal, type = "creation", preventCloseOnOutsideClick, ...props },
|
||||
forwardedRef
|
||||
) => {
|
||||
const isPlatform = useIsPlatform();
|
||||
@@ -119,6 +123,11 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
|
||||
)}
|
||||
<Content
|
||||
{...props}
|
||||
onPointerDownOutside={(e) => {
|
||||
if (preventCloseOnOutsideClick) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
className={classNames(
|
||||
"fadeIn bg-default scroll-bar fixed left-1/2 top-1/2 z-50 w-full max-w-[22rem] -translate-x-1/2 -translate-y-1/2 rounded-md text-left shadow-xl focus-visible:outline-none sm:align-middle",
|
||||
props.size == "xl"
|
||||
|
||||
@@ -135,4 +135,5 @@ export const lucideIconList = new Set([
|
||||
"webhook",
|
||||
"x",
|
||||
"zap",
|
||||
"waypoints"
|
||||
]);
|
||||
@@ -132,6 +132,7 @@ export type IconName =
|
||||
| "users"
|
||||
| "venetian-mask"
|
||||
| "video"
|
||||
| "waypoints"
|
||||
| "webhook"
|
||||
| "x"
|
||||
| "zap";
|
||||
Reference in new issue
Block a user