* AvailabilityPage Component loaded dynamically * update next/bundle-analyzer dependency * Load dynamically SlotPicker and TimezoneDropDown and make some imports refactoring * Gates functionality Returned * Replace crypto with md5 dependency to generate gravatar url * Refactor: AvailableTimes and SlotPicker * Update next.config.js * Update SlotPicker.tsx * Update getEventTypeAppData.ts --------- Co-authored-by: zomars <zomars@me.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import Script from "next/script";
|
|
|
|
import { getEventTypeAppData } from "@calcom/app-store/_utils/getEventTypeAppData";
|
|
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
|
|
|
import type { appDataSchemas } from "./apps.schemas.generated";
|
|
|
|
export default function BookingPageTagManager({
|
|
eventType,
|
|
}: {
|
|
eventType: Parameters<typeof getEventTypeAppData>[0];
|
|
}) {
|
|
return (
|
|
<>
|
|
{Object.entries(appStoreMetadata).map(([appId, app]) => {
|
|
const tag = app.appData?.tag;
|
|
if (!tag) {
|
|
return null;
|
|
}
|
|
const trackingId = getEventTypeAppData(eventType, appId as keyof typeof appDataSchemas)?.trackingId;
|
|
if (!trackingId) {
|
|
return null;
|
|
}
|
|
const parseValue = <T extends string | undefined>(val: T): T =>
|
|
//TODO: Support more template variables.
|
|
val ? (val.replace(/\{TRACKING_ID\}/g, trackingId) as T) : val;
|
|
|
|
return tag.scripts.map((script, index) => {
|
|
const parsedAttributes: NonNullable<(typeof tag.scripts)[number]["attrs"]> = {};
|
|
const attrs = script.attrs || {};
|
|
Object.entries(attrs).forEach(([name, value]) => {
|
|
if (typeof value === "string") {
|
|
value = parseValue(value);
|
|
}
|
|
parsedAttributes[name] = value;
|
|
});
|
|
|
|
return (
|
|
<Script
|
|
src={parseValue(script.src)}
|
|
id={`${appId}-${index}`}
|
|
key={`${appId}-${index}`}
|
|
dangerouslySetInnerHTML={{
|
|
__html: parseValue(script.content) || "",
|
|
}}
|
|
{...parsedAttributes}
|
|
defer
|
|
/>
|
|
);
|
|
});
|
|
})}
|
|
</>
|
|
);
|
|
}
|