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

[BOT] sandeep/bot-2144/ server-bot fix: 🔥 fixed digits contract bot error #16630

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
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const SERVER_BOT_FIELDS = 'server-form-fields';
export const SERVER_BOT_LOSS_THRESHOLD_WARNING = 'server-bot-loss-threshold-warning';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useFormikContext } from 'formik';
import { useStore } from '@deriv/stores';
import { useDBotStore } from 'Stores/useDBotStore';
import { rudderStackSendQsRunStrategyEvent } from '../../../../analytics/rudderstack-quick-strategy';
import { SERVER_BOT_LOSS_THRESHOLD_WARNING } from '../constants';
import { TFormValues } from '../types';

const useQsSubmitHandler = () => {
Expand All @@ -20,7 +21,7 @@ const useQsSubmitHandler = () => {
const handleSubmit = async () => {
const loss_amount = Number(values?.loss ?? 0);
const profit_threshold = Number(values?.profit ?? 0);
const stored_dont_show_warning_value = localStorage?.getItem('qs-dont-show-loss-threshold-warning');
const stored_dont_show_warning_value = localStorage?.getItem(SERVER_BOT_LOSS_THRESHOLD_WARNING);
const dont_show_warning = JSON.parse(stored_dont_show_warning_value ?? 'false');
if (
!loss_threshold_warning_data.already_shown &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event';
import { mock_ws } from 'Utils/mock';
import RootStore from 'Stores/root-store';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import { SERVER_BOT_LOSS_THRESHOLD_WARNING } from '../../constants';
import LossThresholdWarningDialog from '../loss-threshold-warning-dialog';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
Expand Down Expand Up @@ -88,6 +89,6 @@ describe('LossThresholdWarningDialog', () => {
});
const checkbox = screen.getByRole('checkbox', { name: /Do not show this message again./i });
userEvent.click(checkbox);
expect(localStorage.getItem('ssb-dont-show-loss-threshold-warning')).toEqual('true');
expect(localStorage.getItem(SERVER_BOT_LOSS_THRESHOLD_WARNING)).toEqual('true');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Checkbox, Dialog } from '@deriv/components';
import { observer } from '@deriv/stores';
import { Localize, localize } from '@deriv/translations';
import { useDBotStore } from 'Stores/useDBotStore';
import { SERVER_BOT_LOSS_THRESHOLD_WARNING } from '../constants';
import useQsSubmitHandler from '../form-wrappers/useQsSubmitHandler';
import './loss-threshold-warning-dialog.scss';

Expand All @@ -27,9 +28,9 @@ const LossThresholdWarningDialog = observer(() => {
};

const handleDontShowAgain = () => {
const stored_dont_show_warning_value = localStorage?.getItem('qs-dont-show-loss-threshold-warning');
const stored_dont_show_warning_value = localStorage?.getItem(SERVER_BOT_LOSS_THRESHOLD_WARNING);
const dont_show_warning = JSON.parse(stored_dont_show_warning_value ?? 'false');
localStorage.setItem('ssb-dont-show-loss-threshold-warning', `${!dont_show_warning}`);
localStorage.setItem(SERVER_BOT_LOSS_THRESHOLD_WARNING, `${!dont_show_warning}`);
};

return (
Expand Down
3 changes: 2 additions & 1 deletion packages/bot-web-ui/src/stores/server-side-bot-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,11 @@ export default class ServerBotStore {
amount: data.stake,
basis: 'stake',
contract_type: data.type,
currency: 'USD',
currency: this.root_store?.app?.core?.client?.currency || 'USD',
duration: data.duration,
duration_unit: data.durationtype,
symbol: data.symbol,
barrier: data.last_digit_prediction,
},
parameters: {
initial_stake: data.stake,
Expand Down
Loading