From 0e31a5660ababee82b5f648adfc9fae02b042302 Mon Sep 17 00:00:00 2001 From: fetok12 Date: Tue, 7 Jan 2025 17:19:22 +0300 Subject: [PATCH 1/2] mobile-app-control-panel-settings --- server/constants.js | 3 +- server/tools/dbs/checkConfig.js | 1 + web/src/containers/Admin/General/General.js | 153 +++++++++++++++++- .../containers/Admin/General/InterfaceForm.js | 36 ++++- web/src/containers/Admin/General/index.js | 3 + web/src/utils/utils.js | 8 + 6 files changed, 200 insertions(+), 4 deletions(-) diff --git a/server/constants.js b/server/constants.js index 6bab8c07e4..ca57a8500e 100644 --- a/server/constants.js +++ b/server/constants.js @@ -223,7 +223,8 @@ exports.KIT_CONFIG_KEYS = [ 'referral_history_config', 'chain_trade_config', 'selectable_native_currencies', - 'auto_trade_config' + 'auto_trade_config', + 'apps' ]; exports.KIT_SECRETS_KEYS = [ diff --git a/server/tools/dbs/checkConfig.js b/server/tools/dbs/checkConfig.js index a31bf2a56b..8d418d3e51 100644 --- a/server/tools/dbs/checkConfig.js +++ b/server/tools/dbs/checkConfig.js @@ -70,6 +70,7 @@ Status.findOne() balance_history_config: existingKitConfigurations.balance_history_config || {}, selectable_native_currencies: existingKitConfigurations?.selectable_native_currencies || [existingKitConfigurations.native_currency || process.env.NATIVE_CURRENCY || 'usdt'], auto_trade_config: existingKitConfigurations.auto_trade_config || {}, + apps: existingKitConfigurations.apps || {}, }; const secrets = { diff --git a/web/src/containers/Admin/General/General.js b/web/src/containers/Admin/General/General.js index f70ad29ff2..d46f132d86 100644 --- a/web/src/containers/Admin/General/General.js +++ b/web/src/containers/Admin/General/General.js @@ -35,7 +35,11 @@ import { COUNTRIES_OPTIONS } from '../../../utils/countries'; import _get from 'lodash/get'; import './index.css'; -import { handleFiatUpgrade, handleUpgrade } from 'utils/utils'; +import { + handleFiatUpgrade, + handleUpgrade, + handleEnterpriseUpgrade, +} from 'utils/utils'; import { checkFileSize, fileSizeError } from 'utils/icon'; import PublishSection from './PublishSection'; import { CloseCircleOutlined } from '@ant-design/icons'; @@ -516,7 +520,8 @@ class GeneralContent extends Component { features, balance_history_config = null, referral_history_config = null, - chain_trade_config = null + chain_trade_config = null, + auto_trade_config = null ) => { this.handleSubmitGeneral({ kit: { @@ -524,6 +529,7 @@ class GeneralContent extends Component { balance_history_config, referral_history_config, chain_trade_config, + auto_trade_config, }, }); }; @@ -749,6 +755,33 @@ class GeneralContent extends Component { } }; + handleInputChange = (key, value) => { + this.setState((prevState) => ({ + constants: { + ...prevState.constants, + kit: { + ...prevState.constants.kit, + apps: { + ...prevState.constants.kit.apps, + [key]: value, + }, + }, + }, + })); + }; + + handleSave = async () => { + try { + this.handleSubmitGeneral({ + kit: { + apps: this.state.constants.kit.apps, + }, + }); + } catch (error) { + message.error(error.message); + } + }; + render() { const { initialEmailValues, @@ -791,6 +824,7 @@ class GeneralContent extends Component { } const isUpgrade = handleUpgrade(kit.info); const isFiatUpgrade = handleFiatUpgrade(kit.info); + const isEnterpriseUpgrade = handleEnterpriseUpgrade(kit.info); return (
@@ -1181,6 +1215,120 @@ class GeneralContent extends Component { />
) : null} + {activeTab === 'apps' ? ( +
+

Mobile Application Configurations

+

+ You can configure below fields for you mobile application. Those + are publicly available for the users. +

+ +
+
+ + + this.handleInputChange('current_version', e.target.value) + } + placeholder="Enter the current version" + /> +
+ +
+ + + this.handleInputChange('min_version', e.target.value) + } + placeholder="Enter the minimum version" + /> +
+ +
+ + + this.handleInputChange('android_url', e.target.value) + } + placeholder="Enter the Android URL" + /> +
+ +
+ + + this.handleInputChange('ios_url', e.target.value) + } + placeholder="Enter the iOS URL" + /> +
+ +
+ + + this.handleInputChange('macos_url', e.target.value) + } + placeholder="Enter the MacOS URL" + /> +
+ +
+ + + this.handleInputChange('windows_url', e.target.value) + } + placeholder="Enter the Windows URL" + /> +
+ + +
+
+ ) : null} {activeTab === 'features' ? ( diff --git a/web/src/containers/Admin/General/InterfaceForm.js b/web/src/containers/Admin/General/InterfaceForm.js index 0efa973372..481aa94339 100644 --- a/web/src/containers/Admin/General/InterfaceForm.js +++ b/web/src/containers/Admin/General/InterfaceForm.js @@ -19,6 +19,7 @@ const InterfaceForm = ({ isFiatUpgrade, coins, enabledPlugins, + isEnterpriseUpgrade, }) => { const [isSubmit, setIsSubmit] = useState(!buttonSubmitting); const [form] = Form.useForm(); @@ -68,6 +69,7 @@ const InterfaceForm = ({ formValues = { chat: isUpgrade ? false : !!values.chat, quick_trade: !!values.quick_trade, + auto_trade_config: !!values.auto_trade_config, pro_trade: !!values.pro_trade, stake_page: !!values.stake_page, cefi_stake: !!values.cefi_stake, @@ -98,11 +100,17 @@ const InterfaceForm = ({ spread: Number(chainTradeData.spread), source_account: Number(chainTradeData.source_account), }; + + const auto_trade_config = { + active: !!values.auto_trade_config || false, + }; + handleSaveInterface( formValues, values.balance_history_config ? balance_history_config : null, values.referral_history_config ? referral_history_config : null, - values.chain_trade_config ? chain_trade_config : null + values.chain_trade_config ? chain_trade_config : null, + values.auto_trade_config ? auto_trade_config : null ); } }; @@ -614,6 +622,32 @@ const InterfaceForm = ({ + {!isEnterpriseUpgrade && ( + + +
+
+
+
+ SELL +
+
+ BUY +
+
+
+
+ Auto Trade +
+
+ (Automate your trades based on your settings) +
+
+
+
+
+
+ )}
diff --git a/web/src/containers/Admin/General/index.js b/web/src/containers/Admin/General/index.js index 9a6c55daa9..43b75b91c3 100644 --- a/web/src/containers/Admin/General/index.js +++ b/web/src/containers/Admin/General/index.js @@ -53,6 +53,9 @@ const General = () => { + + +
); diff --git a/web/src/utils/utils.js b/web/src/utils/utils.js index 96070df9c2..542d6d83df 100644 --- a/web/src/utils/utils.js +++ b/web/src/utils/utils.js @@ -304,6 +304,14 @@ export const handleFiatUpgrade = (info = {}) => { } }; +export const handleEnterpriseUpgrade = (info = {}) => { + if (_toLower(info.plan) !== 'enterprise') { + return true; + } else { + return false; + } +}; + export const filterPinnedAssets = (pinnedAssets, coins) => { const coinKeys = Object.keys(coins); return pinnedAssets.filter((pinnedAsset) => coinKeys.includes(pinnedAsset)); From 1c112d72bbbe96588ab4c3db289662c87f1fa981 Mon Sep 17 00:00:00 2001 From: fetok12 Date: Tue, 7 Jan 2025 17:21:22 +0300 Subject: [PATCH 2/2] fix conflict --- web/src/containers/Admin/General/General.js | 53 ++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/web/src/containers/Admin/General/General.js b/web/src/containers/Admin/General/General.js index d46f132d86..d4e3519382 100644 --- a/web/src/containers/Admin/General/General.js +++ b/web/src/containers/Admin/General/General.js @@ -655,6 +655,32 @@ class GeneralContent extends Component { } }; + handleInputChange = (key, value) => { + this.setState((prevState) => ({ + constants: { + ...prevState.constants, + kit: { + ...prevState.constants.kit, + apps: { + ...prevState.constants.kit.apps, + [key]: value, + }, + }, + }, + })); + }; + + handleSave = async () => { + try { + this.handleSubmitGeneral({ + kit: { + apps: this.state.constants.kit.apps, + }, + }); + } catch (error) { + message.error(error.message); + } + }; renderModalContent = () => { const { screen, removeCountryLabel, selectedCountry } = this.state; switch (screen) { @@ -755,33 +781,6 @@ class GeneralContent extends Component { } }; - handleInputChange = (key, value) => { - this.setState((prevState) => ({ - constants: { - ...prevState.constants, - kit: { - ...prevState.constants.kit, - apps: { - ...prevState.constants.kit.apps, - [key]: value, - }, - }, - }, - })); - }; - - handleSave = async () => { - try { - this.handleSubmitGeneral({ - kit: { - apps: this.state.constants.kit.apps, - }, - }); - } catch (error) { - message.error(error.message); - } - }; - render() { const { initialEmailValues,