Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit a67713b

Browse files
hubert-derivHubert Koster
and
Hubert Koster
authored
Hubert / HOTFIX for deposit error message (#6785)
* adding deposit error message functionality * removing comment * refactoring code * refactoring code Co-authored-by: Hubert Koster <hubertkoster@Huberts-MacBook-Pro.local>
1 parent 8259d2c commit a67713b

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/javascript/app/pages/user/metatrader/metatrader.config.js

+2-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const Validation = require('../../../common/form_validation');
88
const GTM = require('../../../../_common/base/gtm');
99
const localize = require('../../../../_common/localize').localize;
1010
const State = require('../../../../_common/storage').State;
11-
const urlFor = require('../../../../_common/url').urlFor;
1211
const isBinaryApp = require('../../../../config').isBinaryApp;
1312

1413
const MetaTraderConfig = (() => {
@@ -440,28 +439,14 @@ const MetaTraderConfig = (() => {
440439
selector : fields.deposit.txt_amount.id,
441440
validations: [
442441
['req', { hide_asterisk: true }],
443-
// check if entered amount is less than the available balance
444-
// e.g. transfer amount is 10 but client balance is 5
445-
['custom', {
446-
func: () => {
447-
const balance = Client.get('balance');
448-
449-
const is_balance_more_than_entered = +balance >= +$(fields.deposit.txt_amount.id).val();
450-
451-
return balance && is_balance_more_than_entered;
452-
},
453-
message: localize('You have insufficient funds in your Binary account, please <a href="[_1]">add funds</a>.', urlFor('cashier')),
454-
}],
455442
// check if balance is less than the minimum limit for transfer
456443
// e.g. client balance could be 0.45 but min limit could be 1
457444
['custom', {
458445
func: () => {
459-
const balance = Client.get('balance');
446+
const deposit_input_value = document.querySelector('#txt_amount_deposit').value;
460447
const min_req_balance = Currency.getTransferLimits(Client.get('currency'), 'min', 'mt5');
461448

462-
const is_balance_more_than_min_req = +balance >= +min_req_balance;
463-
464-
return balance && is_balance_more_than_min_req;
449+
return +deposit_input_value > +min_req_balance;
465450
},
466451
message: localize('Should be more than [_1]', Currency.getTransferLimits(Client.get('currency'), 'min', 'mt5')),
467452
}],

src/javascript/app/pages/user/metatrader/metatrader.ui.js

+13
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ const MetaTraderUI = (() => {
560560
$form.find('label[for="txt_amount_withdrawal"]').append(` ${mt_currency}`);
561561

562562
const should_show_transfer_fee = client_currency !== mt_currency;
563+
const txt_amount_deposit_element = $form.find('#txt_amount_deposit');
564+
563565
if (should_show_transfer_fee) {
564566
$('#transfer_fee_amount_to').text(getTransferFee(client_currency, mt_currency));
565567
$('#transfer_fee_minimum_to').text(Currency.getMinimumTransferFee(client_currency));
@@ -568,6 +570,17 @@ const MetaTraderUI = (() => {
568570
}
569571
$form.find('#txt_amount_deposit, #txt_amount_withdrawal').siblings('.hint').setVisibility(should_show_transfer_fee);
570572

573+
txt_amount_deposit_element.on('input', () => {
574+
const balance = Client.get('balance');
575+
const insufficient_funds_error = $form.find('#insufficient_funds');
576+
const is_balance_more_than_entered = balance >= txt_amount_deposit_element.val();
577+
578+
if (is_balance_more_than_entered) {
579+
return insufficient_funds_error.setVisibility(0);
580+
}
581+
return insufficient_funds_error.setVisibility(1);
582+
});
583+
571584
['deposit', 'withdrawal'].forEach((act) => {
572585
actions_info[act].prerequisites(acc_type).then((error_msg) => {
573586
if (error_msg) {

src/sass/app/metatrader.scss

+6
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@
340340
font-weight: bold;
341341
color: $COLOR_GRAY_SHADE;
342342
}
343+
#insufficient_funds {
344+
.insufficient-funds-error-link {
345+
color: $COLOR_RED;
346+
}
347+
text-align: left;
348+
}
343349
#mt5_remaining_transfers .empty {
344350
color: $COLOR_RED;
345351
}

src/templates/app/user/metatrader.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ const Metatrader = () => (
543543

544544
<div className='form'>
545545
<FormRow is_two_rows type='text' id='txt_amount_deposit' label={it.L('Amount')} attributes={{ maxLength: 10 }} hint={it.L('Subject to [_1] transfer fee or [_2], whichever is higher', '<strong id="transfer_fee_amount_to"></strong>', '<strong id="transfer_fee_minimum_to"></strong>')} />
546+
<p id='insufficient_funds' className='error-msg center-text invisible'>
547+
{it.L('You have insufficient funds in your Binary account, please <a class="insufficient-funds-error-link" href="[_1]">add funds</a>.', it.url_for('cashier'))}
548+
</p>
546549
<SubmitButton
547550
is_centered
548551
is_full_width

0 commit comments

Comments
 (0)