forked from emre/www_projectmycelium_com
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
This commit is contained in:
@@ -1,22 +1,13 @@
|
|||||||
import { H3, Eyebrow, P } from "@/components/Texts"
|
import { H3, Eyebrow, P } from "@/components/Texts"
|
||||||
import { Button } from "@/components/Button"
|
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() {
|
export default function Homepod() {
|
||||||
const onGetStartedClick = () => {
|
const onGetStartedClick = () => {
|
||||||
// 1. Ensure we are in a browser environment (client-side)
|
// Ensure we are in a browser environment and ml_account exists before calling it
|
||||||
// and the ml_account function is available globally.
|
if (typeof window !== 'undefined' && typeof (window as any).ml_account === 'function') {
|
||||||
if (typeof window !== 'undefined' && window.ml_account) {
|
(window as any).ml_account('webforms', '6108375', 'l9m8g1', 'show')
|
||||||
|
|
||||||
// 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');
|
|
||||||
|
|
||||||
} else {
|
} 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.")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user