// #region [Imports] =================================================================================================== // Libraries import { useHistory, useLocation } from 'react-router-dom'; import { Button, Card, Tabs } from 'antd'; import { LockFilled } from '@ant-design/icons'; // Components import AdminHeader from '../../components/AdminHeader'; import StoreCreditsDashboard from '../../components/StoreCreditsDashboard'; import StoreCreditsCustomers from '../../components/StoreCreditsCustomers'; import StoreCreditsCustomersContextProvider from '../../contexts/StoreCreditsCustomersQuery'; import StoreCreditAutomations from '../../components/StoreCreditAutomations'; // Helpers import { getPathPrefix } from '../../helpers/utils'; // SCSS import './index.scss'; // #endregion [Imports] // #region [Variables] ================================================================================================= declare var acfwAdminApp: any; // #endregion [Variables] // #region [Interfaces]================================================================================================= interface ITab { label: string; key: string; } // #endregion [Interfaces] // #region [Component] ================================================================================================= const BulkAdjustUpsell = () => { const upsell = acfwAdminApp?.store_credits_page?.bulk_adjust_upsell; if (!upsell) { return null; } return (

{upsell.title}

{upsell.desc}

); }; const TabSwitch = (props: any) => { const { tabKey } = props; switch (tabKey) { case 'dashboard': return ; case 'customers': return ( ); case 'automations': return ; case 'bulk-adjust': { // Reach the global through `window` so a missing `acfwpElements` (premium // plugin inactive) doesn't throw a ReferenceError under strict-mode ESM. const acfwp = (window as any).acfwpElements; const isPremiumActive = parseInt(acfwp?.is_acfwp_active, 10); const StoreCreditsBulkAdjust = acfwp?.StoreCreditsBulkAdjust; if (isPremiumActive && StoreCreditsBulkAdjust) { return ; } return ; } } return null; }; const StoreCredits = () => { const { store_credits_page: { title, tabs }, } = acfwAdminApp; const history = useHistory(); const urlParams = new URLSearchParams(useLocation().search); const defaultTab = urlParams.get('tab') ?? 'dashboard'; const handleTabClick = (key: string) => { history.push(`${getPathPrefix()}admin.php?page=acfw-store-credits&tab=${key}`); }; return (
{tabs.map((tab: ITab) => ( ))}
); }; export default StoreCredits; // #endregion [Component]