import React, { useMemo } from "react"; import { Button } from "./ui/button"; import { __ } from "@wordpress/i18n"; // Pro Feature Component Props interface ProFeatureProps { title?: string; description: string; moduleName: string; pricingUrl: string; isProActive: boolean; isModuleEnabled: boolean; children: React.ReactNode; } // Reusable PRO Badge Component Props interface ProBadgeProps { isProActive: boolean; } // Reusable PRO Badge Component export const ProBadge: React.FC = ({ isProActive }) => { // Only show PRO badge when Pro is not active if (!isProActive) { return ( PRO ); } return null; }; // Reusable Pro Feature Component export const ProFeature: React.FC = ({ title, description, moduleName, pricingUrl, isProActive, isModuleEnabled, children, }) => { // Get the correct modules page URL const modulesPageUrl = useMemo(() => { const baseUrl = window.yatraAdmin?.siteUrl ? `${window.yatraAdmin.siteUrl}/wp-admin/admin.php?page=yatra` : "/wp-admin/admin.php?page=yatra"; return `${baseUrl}&subpage=modules`; }, []); // Show full settings if Pro is active AND module is enabled if (isProActive && isModuleEnabled) { return <>{children}; } // Show "Enable Module" if Pro is active BUT module is not enabled if (isProActive && !isModuleEnabled) { return (

{__("Please activate", "yatra")} {moduleName}

{__("You have Yatra Pro installed. Enable the", "yatra")}{" "} {moduleName} {__("module to access", "yatra")}{" "} {description.toLowerCase()} {__("features.", "yatra")}

); } // Show "Upgrade to Pro" if Pro is not active return (

{__("Upgrade to Pro for", "yatra")} {moduleName}

{__( `Get Yatra Pro to access ${description} and unlock all premium features.`, "yatra", )}

{__("Upgrade to Pro", "yatra")}
); };