// #region [Imports] =================================================================================================== // Libraries import React, {createContext, useState} from "react"; import {useHistory} from "react-router-dom"; import { Modal, Button } from "antd"; import {LockFilled} from "@ant-design/icons"; // Helpers import { getPathPrefix } from "../../helpers/utils"; // SCSS import "./index.scss"; // #endregion [Imports] // #region [Variables] ================================================================================================= declare var acfwAdminApp: any; // #endregion [Variables] // #region [Interfaces] ================================================================================================ interface IModalData { title: string; content: string[]; buttonTxt: string; } interface IModalProps { data: IModalData; showModal: boolean; setShowModal: any; } interface IProps { children: any; } // #endregion [Interfaces] // #region [Contexts] ================================================================================================= export const UpsellContext = createContext({showModal: false, setShowModal: (value: boolean) => {}}); // #endregion [Contexts] // #region [Component] ================================================================================================= const UpsellModal = (props: IModalProps) => { const {data: {title, content, buttonTxt}, showModal, setShowModal} = props; const history = useHistory(); const pathPrefix = getPathPrefix(); const redirectToPremium = () => { history.push(`${ pathPrefix }admin.php?page=acfw-premium`); }; return ( setShowModal(false)} footer={null} >

{title}

{content.map((text: string) =>

{text}

)}
); } const UpsellProvider = (props: IProps) => { const {children} = props; const [showModal, setShowModal]: [boolean, any] = useState(false); return ( {children} {acfwAdminApp?.upsellModal ? : null} ); } export default UpsellProvider; // #endregion [Component]