From f1e1721b2565f49a0b27b8b17569d7af1bccd3b5 Mon Sep 17 00:00:00 2001 From: sasha-astiadi Date: Wed, 19 Nov 2025 16:09:47 +0100 Subject: [PATCH] refactor: simplify MailerLite integration in Homepod component - Removed unused React import - Removed comments about global types file setup - Replaced window.ml_account type checking with inline type assertion using (window as any) - Simplified function existence check to use typeof === 'function' - Streamlined inline comments for clarity --- src/pages/pods/Homepod.tsx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pages/pods/Homepod.tsx b/src/pages/pods/Homepod.tsx index cbaf9f5..162f6f3 100644 --- a/src/pages/pods/Homepod.tsx +++ b/src/pages/pods/Homepod.tsx @@ -1,22 +1,13 @@ import { H3, Eyebrow, P } from "@/components/Texts" import { Button } from "@/components/Button" -import React from 'react'; - -// NOTE: Ensure your global types file (global.d.ts) is set up -// to avoid TypeScript errors on window.ml_account export default function Homepod() { const onGetStartedClick = () => { - // 1. Ensure we are in a browser environment (client-side) - // and the ml_account function is available globally. - if (typeof window !== 'undefined' && window.ml_account) { - - // 2. Execute the MailerLite pop-up trigger function using the specific snippet you provided. - // TypeScript is happy if you defined the global type in step 1. - window.ml_account('webforms', '6108375', 'l9m8g1', 'show'); - + // Ensure we are in a browser environment and ml_account exists before calling it + if (typeof window !== 'undefined' && typeof (window as any).ml_account === 'function') { + (window as any).ml_account('webforms', '6108375', 'l9m8g1', 'show') } else { - console.log("MailerLite script (ml_account) not fully loaded or not in browser."); + console.log("MailerLite script (ml_account) not fully loaded or not in browser.") } };