Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile-app-control-panel-settings #3173

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions server/tools/dbs/checkConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
152 changes: 150 additions & 2 deletions web/src/containers/Admin/General/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -516,14 +520,16 @@ 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: {
features,
balance_history_config,
referral_history_config,
chain_trade_config,
auto_trade_config,
},
});
};
Expand Down Expand Up @@ -649,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) {
Expand Down Expand Up @@ -791,6 +823,7 @@ class GeneralContent extends Component {
}
const isUpgrade = handleUpgrade(kit.info);
const isFiatUpgrade = handleFiatUpgrade(kit.info);
const isEnterpriseUpgrade = handleEnterpriseUpgrade(kit.info);

return (
<div>
Expand Down Expand Up @@ -1181,6 +1214,120 @@ class GeneralContent extends Component {
/>
</div>
) : null}
{activeTab === 'apps' ? (
<div className="general-wrapper">
<h3>Mobile Application Configurations</h3>
<p>
You can configure below fields for you mobile application. Those
are publicly available for the users.
</p>

<div style={{}}>
<div style={{ marginBottom: 16 }}>
<label
htmlFor="current_version"
style={{ display: 'block', marginBottom: -4 }}
>
Current Version
</label>
<Input
id="current_version"
value={constants?.kit?.apps?.current_version}
onChange={(e) =>
this.handleInputChange('current_version', e.target.value)
}
placeholder="Enter the current version"
/>
</div>

<div style={{ marginBottom: 16 }}>
<label
htmlFor="min_version"
style={{ display: 'block', marginBottom: -4 }}
>
Min Version
</label>
<Input
id="min_version"
value={constants?.kit?.apps?.min_version}
onChange={(e) =>
this.handleInputChange('min_version', e.target.value)
}
placeholder="Enter the minimum version"
/>
</div>

<div style={{ marginBottom: 16 }}>
<label
htmlFor="android_url"
style={{ display: 'block', marginBottom: -4 }}
>
Android URL
</label>
<Input
id="android_url"
value={constants?.kit?.apps?.android_url}
onChange={(e) =>
this.handleInputChange('android_url', e.target.value)
}
placeholder="Enter the Android URL"
/>
</div>

<div style={{ marginBottom: 16 }}>
<label
htmlFor="ios_url"
style={{ display: 'block', marginBottom: -4 }}
>
iOS URL
</label>
<Input
id="ios_url"
value={constants?.kit?.apps?.ios_url}
onChange={(e) =>
this.handleInputChange('ios_url', e.target.value)
}
placeholder="Enter the iOS URL"
/>
</div>

<div style={{ marginBottom: 16 }}>
<label
htmlFor="macos_url"
style={{ display: 'block', marginBottom: -4 }}
>
MacOS URL
</label>
<Input
id="macos_url"
value={constants?.kit?.apps?.macos_url}
onChange={(e) =>
this.handleInputChange('macos_url', e.target.value)
}
placeholder="Enter the MacOS URL"
/>
</div>

<div style={{ marginBottom: 16 }}>
<label htmlFor="windows_url" style={{ display: 'block' }}>
Windows URL
</label>
<Input
id="windows_url"
value={constants?.kit?.apps?.windows_url}
onChange={(e) =>
this.handleInputChange('windows_url', e.target.value)
}
placeholder="Enter the Windows URL"
/>
</div>

<Button type="primary" onClick={this.handleSave}>
Save
</Button>
</div>
</div>
) : null}
{activeTab === 'features' ? (
<InterfaceForm
initialValues={kit.features}
Expand All @@ -1189,6 +1336,7 @@ class GeneralContent extends Component {
isUpgrade={isUpgrade}
buttonSubmitting={buttonSubmitting}
isFiatUpgrade={isFiatUpgrade}
isEnterpriseUpgrade={isEnterpriseUpgrade}
coins={coins}
enabledPlugins={enabledPlugins}
/>
Expand Down
36 changes: 35 additions & 1 deletion web/src/containers/Admin/General/InterfaceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const InterfaceForm = ({
isFiatUpgrade,
coins,
enabledPlugins,
isEnterpriseUpgrade,
}) => {
const [isSubmit, setIsSubmit] = useState(!buttonSubmitting);
const [form] = Form.useForm();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
);
}
};
Expand Down Expand Up @@ -614,6 +622,32 @@ const InterfaceForm = ({
</div>
</Checkbox>
</Item>
{!isEnterpriseUpgrade && (
<Item name="auto_trade_config" valuePropName="checked">
<Checkbox className="mt-3">
<div className="d-flex align-items-center">
<div className="feature-trade-box mr-1">
<div className="interface_container">
<div className="sell">
<span className="label">SELL</span>
</div>
<div className="buy">
<span className="label">BUY</span>
</div>
</div>
</div>
<div className="ml-2 checkbox-txt">
Auto Trade
<div className="d-flex justify-content-between">
<div className="small-text">
(Automate your trades based on your settings)
</div>
</div>
</div>
</div>
</Checkbox>
</Item>
)}
<Item name="stake_page" valuePropName="checked">
<Checkbox className="mt-3">
<div className="d-flex align-items-center">
Expand Down
3 changes: 3 additions & 0 deletions web/src/containers/Admin/General/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const General = () => {
<TabPane tab="Help info" key="7">
<GeneralContent activeTab={'help_info'} />
</TabPane>
<TabPane tab="Apps" key="8">
<GeneralContent activeTab={'apps'} />
</TabPane>
</Tabs>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions web/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down