perf: Booker bundle size optimization - Remove sanitize-html dependency on client (#10801)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-08-16 11:03:21 -07:00
1 parent 7c23773636
commit a09401c203
8 files changed
+17 -26

No files matched your search

@@ -20,7 +20,6 @@ import {
mapRecurringBookingToMutationInput,
useTimePreferences,
} from "@calcom/features/bookings/lib";
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
import getBookingResponsesSchema, {
getBookingResponsesPartialSchema,
} from "@calcom/features/bookings/lib/getBookingResponsesSchema";
@@ -179,14 +178,11 @@ export const BookEventForm = ({ onCancel }: BookEventFormProps) => {
return defaults;
}, [eventType?.bookingFields, formValues, isRescheduling, bookingData, rescheduleUid]);
const disableBookingTitle = !!event.data?.isDynamic;
const bookingFormSchema = z
.object({
responses: event?.data
? getBookingResponsesSchema({
eventType: {
bookingFields: getBookingFieldsWithSystemFields({ ...event.data, disableBookingTitle }),
},
eventType: event?.data,
view: rescheduleUid ? "reschedule" : "booking",
})
: // Fallback until event is loaded.
@@ -7,7 +7,6 @@ import { EventDetails, EventMembers, EventMetaSkeleton, EventTitle } from "@calc
import { EventMetaBlock } from "@calcom/features/bookings/components/event-meta/Details";
import { useTimePreferences } from "@calcom/features/bookings/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
import { Calendar, Globe, User } from "@calcom/ui/components/icon";
import { fadeInUp } from "../config";
@@ -68,7 +67,7 @@ export const EventMeta = () => {
<EventTitle className="my-2">{event?.title}</EventTitle>
{event.description && (
<EventMetaBlock contentClassName="mb-8 break-words max-w-full max-h-[180px] scroll-bar pr-4">
<div dangerouslySetInnerHTML={{ __html: markdownToSafeHTML(event.description) }} />
<div dangerouslySetInnerHTML={{ __html: event.description }} />
</EventMetaBlock>
)}
<div className="space-y-4 font-medium rtl:-mr-2">
@@ -10,3 +10,5 @@ export const SystemField = z.enum([
"rescheduleReason",
"smsReminderNumber",
]);
export const SMS_REMINDER_NUMBER_FIELD = "smsReminderNumber";
@@ -1,6 +1,7 @@
import type { EventTypeCustomInput, EventType, Prisma, Workflow } from "@prisma/client";
import type { z } from "zod";
import { SMS_REMINDER_NUMBER_FIELD } from "@calcom/features/bookings/lib/SystemField";
import { fieldsThatSupportLabelAsSafeHtml } from "@calcom/features/form-builder/fieldsThatSupportLabelAsSafeHtml";
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
import slugify from "@calcom/lib/slugify";
@@ -15,11 +16,10 @@ import {
type Fields = z.infer<typeof eventTypeBookingFields>;
if (typeof window !== "undefined") {
console.warn("This file should not be imported on the client side");
// This file imports some costly dependencies, so we want to make sure it's not imported on the client side.
throw new Error("`getBookingFields` must not be imported on the client side.");
}
export const SMS_REMINDER_NUMBER_FIELD = "smsReminderNumber";
/**
* PHONE -> Phone
*/