// #region [Imports] =================================================================================================== // Libraries import React, { useState } from 'react'; import { Typography, Spin, Row, Col, Divider, Popover, Tag } from 'antd'; import { QuestionCircleOutlined, LoadingOutlined } from '@ant-design/icons'; import { validateURL } from '../../../helpers/utils'; import { sanitizeHtml } from '../../../../shared/utils'; // Components import FunnelKitUpsell from './FunnelKitUpsell'; import ImportStoreCreditsField from './ImportStoreCreditsField'; import ClearDetachedStoreCreditsField from './ClearDetachedStoreCreditsField'; // Styles import './index.scss'; // Components import InputSwitch from './InputSwitch'; // #endregion [Imports] // #region [Variables] ================================================================================================= declare var acfwAdminApp: any; const { Text } = Typography; // #endregion [Variables] // #region [Interfaces] ================================================================================================ interface IProps { field: any; } // #endregion [Interfaces] // #region [Component] ================================================================================================= const SettingField = (props: IProps) => { const { field } = props; const { id, title, type, desc, desc_tip } = field; const { validation } = acfwAdminApp; const [showSpinner, setShowSpinner]: [boolean, any] = useState(false); const [invalidInput, setInvalidInput]: [boolean, any] = useState(false); const tooltip = desc_tip ?
{desc_tip}
: null; // section title if ('title' === type) { return (

{title}

{desc}

); } // dyk notice if ('notice' === type && field?.noticeData) { const { classname, title: noticeTitle, description, button_text, button_link, button_class, image, } = field?.noticeData; return (

{!!image && } {noticeTitle}
{button_text && button_link ? ( {button_text} ) : null}

); } // FunnelKit upsell. if ('funnelkit_upsell' === type && field?.noticeData) { return ; } // store credits importer field. if ('acfw_store_credits_importer' === id) { return ; } // clear detached store credit entries (Advanced tab). if ('acfw_clear_detached_store_credits' === id) { return ; } // return empty if ('sectionend' === type) return null; const validateInput = (value: unknown) => { // validate url value. if (value && type === 'url' && !validateURL(value + '')) { setInvalidInput(true); return false; } setInvalidInput(false); return true; }; /** Standard Input Layout */ const StandardLayout = () => { return ( <> {desc_tip ? ( ) : null} {showSpinner ? } /> : null}
{invalidInput ? ( {validation[type] ? validation[type] : validation.default} ) : null}
{desc ?

: null} ); }; /** Subtitle Layout */ const SubtitleLayout = () => { return ( <> {showSpinner ? } /> : null}

{invalidInput ? ( {validation[type] ? validation[type] : validation.default} ) : null}
{desc ?

: null} ); }; return ( {'subtitle' === type ? : } ); }; export default SettingField; // #endregion [Component]