Skip to content

Scheduling infrastructure for absolutely everyone.

Fix missing tabs - Embed (#2804)

Hariom Balhara1fb637d29ddd
diff --git a/apps/docs/next.config.js b/apps/docs/next.config.js
index c9e71be6b89..dce01e92c14 100644
--- a/apps/docs/next.config.js
+++ b/apps/docs/next.config.js
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
const withNextra = require("nextra")({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.js",
diff --git a/apps/web/components/NavTabs.tsx b/apps/web/components/NavTabs.tsx
index 4aefe925f9a..bc3de08adb9 100644
--- a/apps/web/components/NavTabs.tsx
+++ b/apps/web/components/NavTabs.tsx
@@ -56,7 +56,6 @@ const NavTabs: FC<NavTabProps> = ({ tabs, linkProps, ...props }) => {
const Component = tab.adminRequired ? AdminRequired : Fragment;
- if (!href) return null;
return (
<Component key={tab.name}>
<Link key={tab.name} href={href} {...linkProps}>
diff --git a/apps/web/contexts/contractsContext.tsx b/apps/web/contexts/contractsContext.tsx
index a65682e4f5d..b061c5b7b1b 100644
--- a/apps/web/contexts/contractsContext.tsx
+++ b/apps/web/contexts/contractsContext.tsx
@@ -39,8 +39,7 @@ export function ContractsProvider({ children }: Props) {
return (
<>
- {/* @ts-ignore */}
- <ContractsContext.Provider value={value}>{children}</ContractsContext.Provider>
+ <ContractsContext.Provider value={value as any}>{children}</ContractsContext.Provider>
</>
);
}
diff --git a/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts b/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts
index fbba84597d5..0c9e9e8e9f8 100644
--- a/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts
+++ b/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts
@@ -10,6 +10,7 @@ export class FloatingButton extends HTMLElement {
].join(" ");
}
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
static get observedAttributes() {
return [
diff --git a/packages/embeds/embed-core/src/Inline/inline.ts b/packages/embeds/embed-core/src/Inline/inline.ts
index f0e101e6917..6cd74ec4a14 100644
--- a/packages/embeds/embed-core/src/Inline/inline.ts
+++ b/packages/embeds/embed-core/src/Inline/inline.ts
@@ -5,6 +5,7 @@ import { getErrorString } from "../utils";
import inlineHtml from "./inlineHtml";
export class Inline extends HTMLElement {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
static get observedAttributes() {
return ["loading"];
diff --git a/packages/embeds/embed-core/src/ModalBox/ModalBox.ts b/packages/embeds/embed-core/src/ModalBox/ModalBox.ts
index 9a7b4dfa08b..eab4215a8a0 100644
--- a/packages/embeds/embed-core/src/ModalBox/ModalBox.ts
+++ b/packages/embeds/embed-core/src/ModalBox/ModalBox.ts
@@ -6,6 +6,7 @@ import modalBoxHtml from "./ModalBoxHtml";
export class ModalBox extends HTMLElement {
static htmlOverflow: string;
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
static get observedAttributes() {
return ["state"];
diff --git a/packages/embeds/embed-core/src/embed-iframe.ts b/packages/embeds/embed-core/src/embed-iframe.ts
index c809ef63662..2b344b01cf6 100644
--- a/packages/embeds/embed-core/src/embed-iframe.ts
+++ b/packages/embeds/embed-core/src/embed-iframe.ts
@@ -105,7 +105,7 @@ type ReactEmbedStylesSetter = React.Dispatch<React.SetStateAction<EmbedStyles |
const setEmbedStyles = (stylesConfig: UiConfig["styles"]) => {
embedStore.styles = stylesConfig;
- for (let [, setEmbedStyle] of Object.entries(embedStore.reactStylesStateSetters)) {
+ for (const [, setEmbedStyle] of Object.entries(embedStore.reactStylesStateSetters)) {
(setEmbedStyle as any)((styles: any) => {
return {
...styles,
@@ -132,7 +132,7 @@ function isValidNamespace(ns: string | null | undefined) {
export const useEmbedTheme = () => {
const router = useRouter();
- let [theme, setTheme] = useState(embedStore.theme || (router.query.theme as string));
+ const [theme, setTheme] = useState(embedStore.theme || (router.query.theme as string));
useEffect(() => {
router.events.on("routeChangeComplete", () => {
sdkActionManager?.fire("__routeChanged", {});
@@ -305,8 +305,8 @@ const messageParent = (data: any) => {
};
function keepParentInformedAboutDimensionChanges() {
- let knownIframeHeight: Number | null = null;
- let knownIframeWidth: Number | null = null;
+ let knownIframeHeight: number | null = null;
+ let knownIframeWidth: number | null = null;
let numDimensionChanges = 0;
let isFirstTime = true;
let isWindowLoadComplete = false;
@@ -344,8 +344,8 @@ function keepParentInformedAboutDimensionChanges() {
// During first render let iframe tell parent that how much is the expected height to avoid scroll.
// Parent would set the same value as the height of iframe which would prevent scroll.
// On subsequent renders, consider html height as the height of the iframe. If we don't do this, then if iframe get's bigger in height, it would never shrink
- let iframeHeight = isFirstTime ? documentScrollHeight : contentHeight;
- let iframeWidth = isFirstTime ? documentScrollWidth : contentWidth;
+ const iframeHeight = isFirstTime ? documentScrollHeight : contentHeight;
+ const iframeWidth = isFirstTime ? documentScrollWidth : contentWidth;
embedStore.parentInformedAboutContentHeight = true;
if (!iframeHeight || !iframeWidth) {
runAsap(informAboutScroll);
diff --git a/packages/embeds/embed-core/src/embed.ts b/packages/embeds/embed-core/src/embed.ts
index a732731df12..181ba55272d 100644
--- a/packages/embeds/embed-core/src/embed.ts
+++ b/packages/embeds/embed-core/src/embed.ts
@@ -64,7 +64,7 @@ function validate(data: any, schema: Record<"props" | "required", any>) {
throw new Error("Argument is required");
}
- for (let [prop, propSchema] of Object.entries<Record<"type" | "required", any>>(schema.props)) {
+ for (const [prop, propSchema] of Object.entries<Record<"type" | "required", any>>(schema.props)) {
if (propSchema.required && isUndefined(data[prop])) {
throw new Error(`"${prop}" is required`);
}
@@ -130,7 +130,7 @@ export class Cal {
log(`Instruction ${method} not FOUND`);
}
try {
- (this[method] as Function)(...args);
+ (this[method] as (...args: any[]) => void)(...args);
} catch (e) {
// Instead of throwing error, log and move forward in the queue
log(`Instruction couldn't be executed`, e);
@@ -145,6 +145,7 @@ export class Cal {
queue.splice(0);
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
/** @ts-ignore */ // We changed the definition of push here.
queue.push = (instruction) => {
this.processInstruction(instruction);
@@ -188,8 +189,9 @@ export class Cal {
}
// Merge searchParams from config onto the URL which might have query params already
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
- for (let [key, value] of searchParams) {
+ for (const [key, value] of searchParams) {
urlInstance.searchParams.append(key, value);
}
iframe.src = urlInstance.toString();
@@ -224,6 +226,7 @@ export class Cal {
elementOrSelector: string | HTMLElement;
config: Record<string, string>;
}) {
+ // eslint-disable-next-line prefer-rest-params
validate(arguments[0], {
required: true,
props: {
@@ -255,7 +258,7 @@ export class Cal {
const iframe = this.createIframe({ calLink, queryObject: Cal.getQueryObject(config) });
iframe.style.height = "100%";
iframe.style.width = "100%";
- let element =
+ const element =
elementOrSelector instanceof HTMLElement
? elementOrSelector
: document.querySelector(elementOrSelector);
@@ -349,6 +352,7 @@ export class Cal {
action: Parameters<SdkActionManager["on"]>[0];
callback: Parameters<SdkActionManager["on"]>[1];
}) {
+ // eslint-disable-next-line prefer-rest-params
validate(arguments[0], {
required: true,
props: {
@@ -366,6 +370,7 @@ export class Cal {
}
preload({ calLink }: { calLink: string }) {
+ // eslint-disable-next-line prefer-rest-params
validate(arguments[0], {
required: true,
props: {
@@ -499,7 +504,7 @@ export class Cal {
globalCal.instance = new Cal("", globalCal.q!);
-for (let [ns, api] of Object.entries(globalCal.ns!)) {
+for (const [ns, api] of Object.entries(globalCal.ns!)) {
api.instance = new Cal(ns, api.q!);
}
diff --git a/packages/embeds/embed-core/src/preview.ts b/packages/embeds/embed-core/src/preview.ts
index 9d671ca2ce6..b2d2763459a 100644
--- a/packages/embeds/embed-core/src/preview.ts
+++ b/packages/embeds/embed-core/src/preview.ts
@@ -8,40 +8,35 @@ const EMBED_LIB_URL = import.meta.env.NEXT_PUBLIC_EMBED_LIB_URL || `${WEBAPP_URL
// Install Cal Embed Code Snippet
(function (C, A, L) {
- // @ts-ignore
- let p = function (a, ar) {
+ const p = function (a: any, ar: any) {
a.q.push(ar);
};
- let d = C.document;
- // @ts-ignore
+ const d = C.document;
C.Cal =
- // @ts-ignore
C.Cal ||
function () {
- // @ts-ignore
- let cal = C.Cal;
- let ar = arguments;
+ const cal = C.Cal!;
+ // eslint-disable-next-line prefer-rest-params
+ const ar = arguments;
if (!cal.loaded) {
cal.ns = {};
cal.q = cal.q || [];
- // @ts-ignore
d.head.appendChild(d.createElement("script")).src = A;
cal.loaded = true;
}
if (ar[0] === L) {
- const api = function () {
+ const api: { (): void; q?: any[] } = function () {
+ // eslint-disable-next-line prefer-rest-params
p(api, arguments);
};
const namespace = ar[1];
- // @ts-ignore
- api.q = api.q || [];
- // @ts-ignore
- typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar);
+ api!.q = api.q || [];
+ typeof namespace === "string" ? (cal!.ns![namespace] = api) && p(api, ar) : p(cal, ar);
return;
}
p(cal, ar);
};
-})(window, EMBED_LIB_URL, "init");
+})(window as CalWindow, EMBED_LIB_URL, "init");
const previewWindow: CalWindow = window;