diff --git a/src/components/shared_ui/input/input.tsx b/src/components/shared_ui/input/input.tsx
index 3cc3885e..bf22741f 100644
--- a/src/components/shared_ui/input/input.tsx
+++ b/src/components/shared_ui/input/input.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import classNames from 'classnames';
-import { Text } from '@deriv-com/ui';
import Field from '../field';
+import Text from '../text';
export type TInputProps = {
autoComplete?: string;
diff --git a/src/components/shared_ui/modal/index.ts b/src/components/shared_ui/modal/index.ts
index ae6504d0..b7aea668 100644
--- a/src/components/shared_ui/modal/index.ts
+++ b/src/components/shared_ui/modal/index.ts
@@ -1,5 +1,4 @@
import Modal from './modal';
-
import './modal.scss';
export default Modal;
diff --git a/src/components/shared_ui/select-native/select-native.tsx b/src/components/shared_ui/select-native/select-native.tsx
index 4a9be834..3d0d8e3d 100644
--- a/src/components/shared_ui/select-native/select-native.tsx
+++ b/src/components/shared_ui/select-native/select-native.tsx
@@ -2,8 +2,8 @@ import React from 'react';
import classNames from 'classnames';
import { Icon } from '@/utils/tmp/dummy';
import { LabelPairedChevronDownLgRegularIcon } from '@deriv/quill-icons';
-import { Text } from '@deriv-com/ui';
import Field from '../field/field';
+import Text from '../text';
type TSelectNative = {
className?: string;
diff --git a/src/components/shared_ui/toggle-switch/index.ts b/src/components/shared_ui/toggle-switch/index.ts
new file mode 100644
index 00000000..a8e345da
--- /dev/null
+++ b/src/components/shared_ui/toggle-switch/index.ts
@@ -0,0 +1,4 @@
+import ToggleSwitch from './toggle-switch';
+import './toggle-switch.scss';
+
+export default ToggleSwitch;
diff --git a/src/components/shared_ui/toggle-switch/toggle-switch.scss b/src/components/shared_ui/toggle-switch/toggle-switch.scss
new file mode 100644
index 00000000..715c8d68
--- /dev/null
+++ b/src/components/shared_ui/toggle-switch/toggle-switch.scss
@@ -0,0 +1,35 @@
+.dc-toggle-switch {
+ height: 0;
+ width: 0;
+ visibility: hidden;
+
+ &__label {
+ display: flex;
+ align-items: center;
+ margin-left: auto;
+ margin-right: 1.6rem;
+ padding-left: 0.4rem;
+ cursor: pointer;
+ width: 4.9rem;
+ height: 2.52rem;
+ background: var(--general-disabled);
+ border-radius: 4.9rem;
+ transition: background-color 0.25s;
+ }
+
+ &__button {
+ width: 1.9rem;
+ height: 1.9rem;
+ border-radius: 1.9rem;
+ transition: transform 0.25s;
+ background: var(--text-colored-background);
+ }
+
+ &:checked + &__label {
+ background: var(--text-profit-success);
+ }
+
+ &:checked + &__label &__button {
+ transform: translateX(2.25rem);
+ }
+}
diff --git a/src/components/shared_ui/toggle-switch/toggle-switch.tsx b/src/components/shared_ui/toggle-switch/toggle-switch.tsx
new file mode 100644
index 00000000..c80659d5
--- /dev/null
+++ b/src/components/shared_ui/toggle-switch/toggle-switch.tsx
@@ -0,0 +1,40 @@
+import * as React from 'react';
+import classNames from 'classnames';
+
+type TToggleSwitch = {
+ className?: string;
+ classNameButton?: string;
+ classNameLabel?: string;
+ handleToggle: () => void;
+ id: string;
+ is_enabled: boolean;
+ name?: string;
+};
+
+const ToggleSwitch = ({
+ className,
+ classNameButton,
+ classNameLabel,
+ handleToggle,
+ id,
+ is_enabled,
+ name = 'toggle_switch',
+}: TToggleSwitch) => {
+ return (
+
+
+
+
+ );
+};
+
+export default ToggleSwitch;
diff --git a/src/pages/bot-builder/quick-strategy/config.ts b/src/pages/bot-builder/quick-strategy/config.ts
index c2324518..2317a378 100644
--- a/src/pages/bot-builder/quick-strategy/config.ts
+++ b/src/pages/bot-builder/quick-strategy/config.ts
@@ -1,5 +1,5 @@
import { config as qs_config } from '@/external/bot-skeleton';
-import { localize } from '@deriv-com/translations';
+import { localize } from '@/utils/tmp/dummy';
import {
D_ALEMBERT,
MARTINGALE,
diff --git a/src/pages/bot-builder/quick-strategy/descriptions/strategy-description.tsx b/src/pages/bot-builder/quick-strategy/descriptions/strategy-description.tsx
index f3773a0a..4f4e7bc9 100644
--- a/src/pages/bot-builder/quick-strategy/descriptions/strategy-description.tsx
+++ b/src/pages/bot-builder/quick-strategy/descriptions/strategy-description.tsx
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import { observer } from 'mobx-react-lite';
+import Text from '@/components/shared_ui/text';
import { useStore } from '@/hooks/useStore';
-import { Text } from '@deriv-com/ui';
import { TStrategyDescription } from '../types';
const StrategyDescription = observer(({ item, font_size }: TStrategyDescription) => {
@@ -37,7 +37,7 @@ const StrategyDescription = observer(({ item, font_size }: TStrategyDescription)
const class_names = classNames(`qs__description__image ${class_name}`);
return (
-
+
);
}
diff --git a/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx b/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx
index 9dcf02a8..27a22449 100644
--- a/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx
+++ b/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx
@@ -2,11 +2,12 @@ import React from 'react';
import classNames from 'classnames';
import { useFormikContext } from 'formik';
import { observer } from 'mobx-react-lite';
+import Button from '@/components/shared_ui/button';
+import Text from '@/components/shared_ui/text';
import ThemedScrollbars from '@/components/shared_ui/themed-scrollbars';
import { useStore } from '@/hooks/useStore';
import { LegacyClose1pxIcon } from '@deriv/quill-icons';
import { Localize } from '@deriv-com/translations';
-import { Button, Text } from '@deriv-com/ui';
import {
rudderStackSendQsEditStrategyEvent,
rudderStackSendQsRunStrategyEvent,
diff --git a/src/pages/bot-builder/quick-strategy/form-wrappers/form-tabs.tsx b/src/pages/bot-builder/quick-strategy/form-wrappers/form-tabs.tsx
index 7c790c2a..6dd4eeb1 100644
--- a/src/pages/bot-builder/quick-strategy/form-wrappers/form-tabs.tsx
+++ b/src/pages/bot-builder/quick-strategy/form-wrappers/form-tabs.tsx
@@ -1,7 +1,7 @@
import React, { KeyboardEvent } from 'react';
import classNames from 'classnames';
import { observer } from 'mobx-react-lite';
-import { Text } from '@deriv-com/ui';
+import Text from '@/components/shared_ui/text';
import { FORM_TABS } from '../config';
import { TDescriptionItem } from '../types';
diff --git a/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx b/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx
index db3456ff..e51c2baf 100644
--- a/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx
+++ b/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx
@@ -7,7 +7,7 @@ import SelectNative from '@/components/shared_ui/select-native';
import Text from '@/components/shared_ui/text';
import ThemedScrollbars from '@/components/shared_ui/themed-scrollbars';
import { useStore } from '@/hooks/useStore';
-import { localize } from '@/utils/tmp/dummy';
+import { localize } from '@deriv-com/translations';
import {
rudderStackSendQsRunStrategyEvent,
rudderStackSendQsSelectedTabEvent,
diff --git a/src/pages/bot-builder/quick-strategy/form.tsx b/src/pages/bot-builder/quick-strategy/form.tsx
index 9bb81487..30e658ae 100644
--- a/src/pages/bot-builder/quick-strategy/form.tsx
+++ b/src/pages/bot-builder/quick-strategy/form.tsx
@@ -20,11 +20,22 @@ const QuickStrategyForm = observer(() => {
const { quick_strategy } = useStore();
const { selected_strategy, setValue, form_data } = quick_strategy;
const config: TConfigItem[][] = STRATEGIES[selected_strategy]?.fields;
- const { is_mobile } = ui;
+ const { is_desktop } = ui;
const { values, setFieldTouched, setFieldValue } = useFormikContext();
- const { current_duration_min_max, is_enabled_toggle_switch, setIsEnabledToggleSwitch } = quick_strategy;
+ const { current_duration_min_max } = quick_strategy;
+
+ const [isEnabledToggleSwitch, setIsEnabledToggleSwitch] = React.useState(false);
+
React.useEffect(() => {
window.addEventListener('keydown', handleEnter);
+ let data: TFormData | null = null;
+ try {
+ data = JSON.parse(localStorage.getItem('qs-fields') ?? '{}');
+ } catch {
+ data = null;
+ }
+ setIsEnabledToggleSwitch(!!data?.boolean_max_stake);
+
return () => {
window.removeEventListener('keydown', handleEnter);
};
@@ -50,6 +61,10 @@ const QuickStrategyForm = observer(() => {
return values[item.key as keyof TFormData] === item.value;
});
+ const toggleSwitch = () => {
+ setIsEnabledToggleSwitch(prev => !prev);
+ };
+
const renderForm = () => {
return config.map((group, group_index) => {
if (!group?.length) return null;
@@ -59,8 +74,8 @@ const QuickStrategyForm = observer(() => {
const key = `${field.name || field.type} + ${field_index}`;
if (
- (is_mobile && field.hide?.includes('mobile')) ||
- (!is_mobile && field.hide?.includes('desktop'))
+ (!is_desktop && field.hide?.includes('mobile')) ||
+ (is_desktop && field.hide?.includes('desktop'))
) {
return null;
}
@@ -84,7 +99,7 @@ const QuickStrategyForm = observer(() => {
}
const should_validate = field.should_have;
if (should_validate && field.name === 'max_stake') {
- min = +(form_data?.stake ?? 0);
+ min = +form_data?.stake;
if (isNaN(min)) {
min = +initial_stake;
}
@@ -102,7 +117,7 @@ const QuickStrategyForm = observer(() => {
max = 9;
}
if (should_have?.length) {
- if (!should_enable && (is_mobile || hide_without_should_have)) {
+ if (!should_enable && (!is_desktop || hide_without_should_have)) {
return null;
}
return (
@@ -148,8 +163,8 @@ const QuickStrategyForm = observer(() => {
key={key}
name={field.name as string}
label={field.label as string}
- isEnabledToggleSwitch={!!is_enabled_toggle_switch}
- setIsEnabledToggleSwitch={setIsEnabledToggleSwitch}
+ isEnabledToggleSwitch={!!isEnabledToggleSwitch}
+ setIsEnabledToggleSwitch={toggleSwitch}
/>
);
// Dedicated components only for Quick-Strategy
diff --git a/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx b/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx
index 942550f0..0f1f8cf9 100644
--- a/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx
+++ b/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import Popover from '@/components/shared_ui/popover';
-import { Text } from '@deriv-com/ui';
+import Text from '@/components/shared_ui/text';
type TQSInputLabel = {
children?: React.ReactNode;
diff --git a/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx b/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx
index ba5881f6..f09a2c52 100644
--- a/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx
+++ b/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx
@@ -2,9 +2,9 @@ import React, { MouseEvent } from 'react';
import classNames from 'classnames';
import { Field, FieldProps, useFormikContext } from 'formik';
import { observer } from 'mobx-react-lite';
+import Input from '@/components/shared_ui/input';
import Popover from '@/components/shared_ui/popover';
import { useStore } from '@/hooks/useStore';
-import { Input } from '@deriv-com/ui';
type TQSInput = {
name: string;
diff --git a/src/pages/bot-builder/quick-strategy/inputs/qs-toggle-switch.tsx b/src/pages/bot-builder/quick-strategy/inputs/qs-toggle-switch.tsx
index fc35207b..2a2b0f5a 100644
--- a/src/pages/bot-builder/quick-strategy/inputs/qs-toggle-switch.tsx
+++ b/src/pages/bot-builder/quick-strategy/inputs/qs-toggle-switch.tsx
@@ -2,8 +2,9 @@ import React from 'react';
import classNames from 'classnames';
import { Field, useFormikContext } from 'formik';
import Popover from '@/components/shared_ui/popover';
-import { localize } from '@/utils/tmp/dummy';
-import { Text, ToggleSwitch } from '@deriv-com/ui';
+import Text from '@/components/shared_ui/text';
+import ToggleSwitch from '@/components/shared_ui/toggle-switch';
+import { localize } from '@deriv-com/translations';
import { TFormData } from '../types';
type TQSToggleSwitch = {
diff --git a/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx b/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx
index c734084d..183f65bf 100644
--- a/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx
+++ b/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx
@@ -1,7 +1,8 @@
import { observer } from 'mobx-react-lite';
+import Checkbox from '@/components/shared_ui/checkbox';
+import Dialog from '@/components/shared_ui/dialog';
import { useStore } from '@/hooks/useStore';
-import { Localize, localize } from '@/utils/tmp/dummy';
-import { Checkbox, Dialog } from '@deriv-com/ui';
+import { Localize, localize } from '@deriv-com/translations';
import useQsSubmitHandler from '../form-wrappers/useQsSubmitHandler';
import './loss-threshold-warning-dialog.scss';
diff --git a/src/pages/bot-builder/quick-strategy/quick-strategy.scss b/src/pages/bot-builder/quick-strategy/quick-strategy.scss
index 61cd6035..49866a6b 100644
--- a/src/pages/bot-builder/quick-strategy/quick-strategy.scss
+++ b/src/pages/bot-builder/quick-strategy/quick-strategy.scss
@@ -31,13 +31,13 @@
@include flex-center(space-between);
border-bottom: 1px solid var(--border-divider);
+ background-color: var(--general-section-1);
&__title {
@extend .x-center;
padding: 0 2.4rem;
height: var(--header-height);
- background-color: var(--general-section-1);
width: var(--sidebar-width);
}
diff --git a/src/pages/bot-builder/quick-strategy/quick-strategy.tsx b/src/pages/bot-builder/quick-strategy/quick-strategy.tsx
index d9d03ad8..9dd66923 100644
--- a/src/pages/bot-builder/quick-strategy/quick-strategy.tsx
+++ b/src/pages/bot-builder/quick-strategy/quick-strategy.tsx
@@ -3,10 +3,10 @@ import { Form as FormikForm, Formik } from 'formik';
import { observer } from 'mobx-react-lite';
import * as Yup from 'yup';
import MobileFullPageModal from '@/components/shared_ui/mobile-full-page-modal';
+import Modal from '@/components/shared_ui/modal';
import { config as qs_config } from '@/external/bot-skeleton';
import { useStore } from '@/hooks/useStore';
import { localize } from '@deriv-com/translations';
-import { Modal } from '@deriv-com/ui';
import { rudderStackSendQsCloseEvent } from './analytics/rudderstack-quick-strategy';
import DesktopFormWrapper from './form-wrappers/desktop-form-wrapper';
import MobileFormWrapper from './form-wrappers/mobile-form-wrapper';
@@ -40,26 +40,43 @@ const getErrorMessage = (dir: 'MIN' | 'MAX', value: number, type = 'DEFAULT') =>
const FormikWrapper: React.FC = observer(({ children }) => {
const { quick_strategy } = useStore();
- const { selected_strategy, form_data, setValue, current_duration_min_max, initializeLossThresholdWarningData } =
+ const { selected_strategy, form_data, current_duration_min_max, initializeLossThresholdWarningData } =
quick_strategy;
const config: TConfigItem[][] = STRATEGIES[selected_strategy]?.fields;
const [dynamic_schema, setDynamicSchema] = useState(Yup.object().shape({}));
const is_mounted = useRef(true);
- const initial_value: TFormData = {
- symbol: qs_config.QUICK_STRATEGY.DEFAULT.symbol,
- tradetype: '',
- durationtype: qs_config.QUICK_STRATEGY.DEFAULT.durationtype,
- stake: '1',
- loss: '',
- profit: '',
- size: String(qs_config.QUICK_STRATEGY.DEFAULT.size),
- duration: '1',
- unit: String(qs_config.QUICK_STRATEGY.DEFAULT.unit),
- action: 'RUN',
- max_stake: 10,
- boolean_max_stake: false,
- last_digit_prediction: 1,
+ let initial_value: TFormData | null = null;
+
+ const getSavedValues = () => {
+ let data: TFormData | null = null;
+ try {
+ data = JSON.parse(localStorage.getItem('qs-fields') ?? '{}');
+ } catch {
+ data = null;
+ }
+ return data;
+ };
+
+ const getInitialValue = () => {
+ const data = getSavedValues();
+ initial_value = {
+ symbol: data?.symbol ?? qs_config.QUICK_STRATEGY.DEFAULT.symbol,
+ tradetype: data?.tradetype ?? '',
+ type: data?.type ?? '',
+ durationtype: data?.durationtype ?? qs_config.QUICK_STRATEGY.DEFAULT.durationtype,
+ duration: data?.duration ?? '1',
+ stake: data?.stake ?? '1',
+ loss: data?.loss ?? '',
+ profit: data?.profit ?? '',
+ size: data?.size ?? String(qs_config.QUICK_STRATEGY.DEFAULT.size),
+ unit: data?.unit ?? String(qs_config.QUICK_STRATEGY.DEFAULT.unit),
+ action: data?.action ?? 'RUN',
+ max_stake: data?.max_stake ?? 10,
+ boolean_max_stake: data?.boolean_max_stake || false,
+ last_digit_prediction: data?.last_digit_prediction ?? 1,
+ };
+ return initial_value;
};
React.useEffect(() => {
@@ -69,11 +86,6 @@ const FormikWrapper: React.FC = observer(({ children }) => {
}, []);
React.useEffect(() => {
- const data = JSON.parse(localStorage.getItem('qs-fields') || '{}');
- Object.keys(data).forEach(key => {
- initial_value[key as keyof TFormData] = data[key];
- setValue(key, data[key]);
- });
initializeLossThresholdWarningData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -105,9 +117,9 @@ const FormikWrapper: React.FC = observer(({ children }) => {
})
: true;
if (should_validate && field.name === 'max_stake') {
- min = +(form_data?.stake ?? 0);
+ min = +form_data?.stake;
if (isNaN(min)) {
- min = +initial_value.stake;
+ min = +(initial_value?.stake ?? 0);
}
min_error = getErrorMessage('MIN', min);
}
@@ -170,7 +182,7 @@ const FormikWrapper: React.FC = observer(({ children }) => {
return (
getErrors(values)}
@@ -184,7 +196,7 @@ const FormikWrapper: React.FC = observer(({ children }) => {
const QuickStrategy = observer(() => {
const { quick_strategy } = useStore();
const { ui } = useStore();
- const { is_mobile } = ui;
+ const { is_desktop } = ui;
const { is_open, setFormVisibility, form_data, selected_strategy } = quick_strategy;
const active_tab_ref = useRef(null);
@@ -195,6 +207,7 @@ const QuickStrategy = observer(() => {
? 'learn more'
: 'trade parameters';
rudderStackSendQsCloseEvent({
+ subform_name: 'quick_strategy',
quick_strategy_tab: active_tab,
selected_strategy,
form_values: form_data as TFormValues,
@@ -210,7 +223,13 @@ const QuickStrategy = observer(() => {
- {is_mobile ? (
+ {is_desktop ? (
+
+
+
+
+
+ ) : (
{
- ) : (
-
-
-
-
-
)}
diff --git a/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx b/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx
index 81b151dd..89f591b0 100644
--- a/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx
+++ b/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx
@@ -3,10 +3,10 @@ import classNames from 'classnames';
import { Field, FieldProps, useFormikContext } from 'formik';
import { observer } from 'mobx-react-lite';
import Autocomplete from '@/components/shared_ui/autocomplete';
+import { TItem } from '@/components/shared_ui/dropdown-list';
+import Text from '@/components/shared_ui/text';
import { ApiHelpers } from '@/external/bot-skeleton';
import { useStore } from '@/hooks/useStore';
-import { TItem } from '@deriv/components/src/components/dropdown-list';
-import { Text } from '@deriv-com/ui';
import { TApiHelpersInstance, TDropdownItems, TFormData } from '../types';
type TContractTypes = {
@@ -16,16 +16,16 @@ type TContractTypes = {
const ContractTypes: React.FC = observer(({ name }) => {
const { ui } = useStore();
- const { is_mobile } = ui;
+ const { is_desktop } = ui;
const [list, setList] = React.useState([]);
const { quick_strategy } = useStore();
const { setValue } = quick_strategy;
const { setFieldValue, values } = useFormikContext();
const { symbol, tradetype } = values;
- const selected = values?.type;
React.useEffect(() => {
- if (tradetype && symbol && selected !== '') {
+ if (tradetype && symbol) {
+ const selected = values?.type;
const getContractTypes = async () => {
const { contracts_for } = ApiHelpers.instance as unknown as TApiHelpersInstance;
const categories = await contracts_for.getContractTypes(tradetype);
@@ -39,7 +39,7 @@ const ContractTypes: React.FC = observer(({ name }) => {
getContractTypes();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [symbol, tradetype, selected]);
+ }, [symbol, tradetype]);
const handleChange = (value: string) => {
setFieldValue?.(name, value);
@@ -53,7 +53,7 @@ const ContractTypes: React.FC = observer(({ name }) => {
{({ field }: FieldProps) => {
const selected_item = list?.find(item => item?.value === field?.value);
- if (is_mobile) {
+ if (!is_desktop) {
return (
{list.map(item => {
@@ -82,7 +82,7 @@ const ContractTypes: React.FC = observer(({ name }) => {
{...field}
readOnly
inputMode='none'
- data-testid='dt_qs_autocomplete_contract_type'
+ data-testid='dt_qs_contract_type'
autoComplete='off'
className='qs__select contract-type'
value={selected_item?.text || ''}
diff --git a/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx b/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx
index dd7f5777..6156281b 100644
--- a/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx
+++ b/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx
@@ -2,9 +2,9 @@ import React from 'react';
import classNames from 'classnames';
import { Field, FieldProps, useFormikContext } from 'formik';
import Autocomplete from '@/components/shared_ui/autocomplete';
+import { TItem } from '@/components/shared_ui/dropdown-list';
import { ApiHelpers } from '@/external/bot-skeleton';
import { useStore } from '@/hooks/useStore';
-import { TItem } from '@deriv/components/src/components/dropdown-list';
import { TApiHelpersInstance, TDurationUnitItem, TFormData } from '../types';
type TDurationUnit = {
@@ -13,11 +13,12 @@ type TDurationUnit = {
const DurationUnit: React.FC = ({ attached }: TDurationUnit) => {
const [list, setList] = React.useState([]);
+ const [prevSymbol, setPrevSymbol] = React.useState('');
+ const [prevTradeType, setPrevTradeType] = React.useState('');
const { quick_strategy } = useStore();
const { setValue, setCurrentDurationMinMax } = quick_strategy;
const { setFieldValue, validateForm, values } = useFormikContext();
const { symbol, tradetype } = values;
- const selected = values?.durationtype;
React.useEffect(() => {
if (tradetype && symbol) {
@@ -31,18 +32,19 @@ const DurationUnit: React.FC = ({ attached }: TDurationUnit) => {
max: duration.max,
}));
setList(duration_units);
+ const selected = values?.durationtype;
const has_selected = duration_units?.some(duration => duration.value === selected);
- if (!has_selected) {
- setFieldValue?.('durationtype', durations?.[0]?.unit);
- setFieldValue?.('duration', durations?.[0]?.min);
- setValue('durationtype', durations?.[0]?.unit ?? '');
+ if (!has_selected || prevSymbol !== symbol || prevTradeType !== tradetype) {
setCurrentDurationMinMax(durations?.[0]?.min, durations?.[0]?.max);
+ setFieldValue?.('durationtype', durations?.[0]?.unit, true);
+ setFieldValue?.('duration', durations?.[0]?.min, true);
+ setValue('durationtype', durations?.[0]?.unit ?? '');
} else {
const duration = duration_units?.find((duration: TDurationUnitItem) => duration.value === selected);
- setFieldValue?.('duration', duration?.min);
- setValue('duration', duration?.min ?? 0);
setCurrentDurationMinMax(duration?.min, duration?.max);
}
+ setPrevSymbol(symbol as string);
+ setPrevTradeType(tradetype as string);
};
getDurationUnits();
}
@@ -63,7 +65,7 @@ const DurationUnit: React.FC = ({ attached }: TDurationUnit) => {
{...field}
readOnly
inputMode='none'
- data-testid='qs_autocomplete_durationtype'
+ data-testid='dt_qs_durationtype'
autoComplete='off'
className='qs__select'
value={selected_item?.text || ''}
diff --git a/src/pages/bot-builder/quick-strategy/selects/symbol.tsx b/src/pages/bot-builder/quick-strategy/selects/symbol.tsx
index 62265789..657d4076 100644
--- a/src/pages/bot-builder/quick-strategy/selects/symbol.tsx
+++ b/src/pages/bot-builder/quick-strategy/selects/symbol.tsx
@@ -1,11 +1,11 @@
import React, { useEffect, useMemo, useState } from 'react';
import { Field, FieldProps, useFormikContext } from 'formik';
import Autocomplete from '@/components/shared_ui/autocomplete';
+import { TItem } from '@/components/shared_ui/dropdown-list';
+import Text from '@/components/shared_ui/text';
import { ApiHelpers } from '@/external/bot-skeleton';
import { useStore } from '@/hooks/useStore';
import { Icon } from '@/utils/tmp/dummy';
-import { TItem } from '@deriv/components/src/components/dropdown-list';
-import { Text } from '@deriv-com/ui';
import { TFormData } from '../types';
type TSymbol = {
@@ -31,7 +31,7 @@ const MarketOption: React.FC = ({ symbol }) => (
const SymbolSelect: React.FC = () => {
const { quick_strategy } = useStore();
const {
- ui: { is_mobile, is_desktop },
+ ui: { is_desktop },
} = useStore();
const { setValue } = quick_strategy;
const [active_symbols, setActiveSymbols] = React.useState([]);
@@ -85,7 +85,7 @@ const SymbolSelect: React.FC = () => {
};
const handleItemSelection = (item: TItem) => {
- if (item) {
+ if (item?.value) {
const { value } = item as TSymbol;
setFieldValue('symbol', value);
setValue('symbol', value);
@@ -115,9 +115,9 @@ const SymbolSelect: React.FC = () => {
<>
= ({ trade_type }: TTradeTypeOption) => (
-
-
-
-
- {trade_type.text}
-
-
-);
+const TradeTypeOption: React.FC = ({ trade_type: { value, icon, text } }: TTradeTypeOption) => {
+ return (
+
+ {icon?.length
+ ? icon.map((ic, idx) => (
+
+ ))
+ : null}
+
+ {text}
+
+
+ );
+};
const TradeTypeSelect: React.FC = () => {
const [trade_types, setTradeTypes] = React.useState([]);
const { setFieldValue, values, validateForm } = useFormikContext();
const { quick_strategy } = useStore();
const { setValue } = quick_strategy;
- const selected = values?.tradetype;
React.useEffect(() => {
- const first_time_user_data = !(JSON.parse(localStorage?.getItem('qs-fields') as string) as TFormData);
- if (first_time_user_data) {
- setFieldValue?.('tradetype', trade_types?.[0]?.value);
- validateForm();
- setValue('tradetype', trade_types?.[0]?.value);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ if (values?.symbol) {
+ const selected = values?.tradetype;
- React.useEffect(() => {
- if (values?.symbol && selected !== '') {
const { contracts_for } = ApiHelpers.instance as unknown as TApiHelpersInstance;
const getTradeTypes = async () => {
const trade_types = await contracts_for.getTradeTypesForQuickStrategy(values?.symbol);
setTradeTypes(trade_types);
const has_selected = trade_types?.some(trade_type => trade_type.value === selected);
if (!has_selected && trade_types?.[0]?.value !== selected) {
- await setFieldValue?.('tradetype', trade_types?.[0].value || '');
+ setFieldValue?.('tradetype', trade_types?.[0].value || '');
setValue('tradetype', trade_types?.[0].value);
}
};
- debounce(async () => {
- getTradeTypes();
- }, 100)();
+ getTradeTypes();
+ validateForm();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [values?.symbol, selected]);
+ }, [values?.symbol]);
const trade_type_dropdown_options = React.useMemo(
() =>
@@ -80,7 +74,7 @@ const TradeTypeSelect: React.FC = () => {
{...field}
readOnly
inputMode='none'
- data-testid='qs_autocomplete_tradetype'
+ data-testid='dt_qs_tradetype'
autoComplete='off'
className='qs__autocomplete'
value={selected_trade_type?.text || ''}
diff --git a/src/pages/main/main.scss b/src/pages/main/main.scss
index 9a07b6e1..77871ed8 100644
--- a/src/pages/main/main.scss
+++ b/src/pages/main/main.scss
@@ -613,6 +613,9 @@
outline: none;
cursor: pointer;
margin-inline-end: 0.8rem;
+ display: flex;
+ align-items: center;
+ justify-content: center;
&.default {
background: transparent;
diff --git a/src/pages/tutorials/common/search-input/index.tsx b/src/pages/tutorials/common/search-input/index.tsx
index 63f67f83..27b2e01e 100644
--- a/src/pages/tutorials/common/search-input/index.tsx
+++ b/src/pages/tutorials/common/search-input/index.tsx
@@ -3,7 +3,7 @@ import debounce from 'debounce';
import { observer } from 'mobx-react-lite';
import { DEBOUNCE_INTERVAL_TIME } from '@/constants/bot-contents';
import { useStore } from '@/hooks/useStore';
-import { localize } from '@/utils/tmp/dummy';
+import { localize } from '@deriv-com/translations';
type TSearchInput = {
faq_value: string;
diff --git a/src/pages/tutorials/dbot-tours/tour-content.tsx b/src/pages/tutorials/dbot-tours/tour-content.tsx
index 96401b09..282d6747 100644
--- a/src/pages/tutorials/dbot-tours/tour-content.tsx
+++ b/src/pages/tutorials/dbot-tours/tour-content.tsx
@@ -2,8 +2,9 @@ import { getImageLocation } from '../../../public-path';
import React from 'react';
import Text from '@/components/shared_ui/text';
import { isDbotRTL } from '@/external/bot-skeleton/utils/workspace';
+import { localize } from '@/utils/tmp/dummy';
import { LabelPairedCircleCheckCaptionRegularIcon } from '@deriv/quill-icons';
-import { Localize, localize } from '@deriv-com/translations';
+import { Localize } from '@deriv-com/translations';
import TourSteps from './common/tour-steps';
type TJoyrideConfig = Record<
diff --git a/src/pages/tutorials/faq-content/index.tsx b/src/pages/tutorials/faq-content/index.tsx
index 503deede..a6f2c8c8 100644
--- a/src/pages/tutorials/faq-content/index.tsx
+++ b/src/pages/tutorials/faq-content/index.tsx
@@ -3,7 +3,7 @@ import Accordion from '@/components/shared_ui/accordion';
import Text from '@/components/shared_ui/text';
import { DBOT_TABS } from '@/constants/bot-contents';
import { useStore } from '@/hooks/useStore';
-import { Localize } from '@/utils/tmp/dummy';
+import { Localize } from '@deriv-com/translations';
import { TDescription } from '../tutorials.types';
type TFAQContent = {
diff --git a/src/pages/tutorials/guide-content/guide-content.tsx b/src/pages/tutorials/guide-content/guide-content.tsx
index 308c2aaf..1c733152 100644
--- a/src/pages/tutorials/guide-content/guide-content.tsx
+++ b/src/pages/tutorials/guide-content/guide-content.tsx
@@ -5,9 +5,8 @@ import Text from '@/components/shared_ui/text';
import { DBOT_TABS } from '@/constants/bot-contents';
import { useStore } from '@/hooks/useStore';
import { removeKeyValue } from '@/utils/settings';
-import { localize } from '@/utils/tmp/dummy';
import { LabelPairedPlayCaptionFillIcon } from '@deriv/quill-icons';
-import { Localize } from '@deriv-com/translations';
+import { Localize, localize } from '@deriv-com/translations';
type TGuideList = {
content?: string;
diff --git a/src/pages/tutorials/tutorials.tsx b/src/pages/tutorials/tutorials.tsx
index 3ebdd1cc..bc3186a6 100644
--- a/src/pages/tutorials/tutorials.tsx
+++ b/src/pages/tutorials/tutorials.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
import { useStore } from '@/hooks/useStore';
-import { localize } from '@/utils/tmp/dummy';
+import { localize } from '@deriv-com/translations';
import NoSearchResult from './common/no-search-result-found';
import QuickStrategyGuides from './quick-strategy-content/quick-strategy-guides';
import FAQContent from './faq-content';
diff --git a/src/stores/quick-strategy-store.ts b/src/stores/quick-strategy-store.ts
index 30178267..bed56d39 100644
--- a/src/stores/quick-strategy-store.ts
+++ b/src/stores/quick-strategy-store.ts
@@ -34,7 +34,6 @@ interface IQuickStrategyStore {
};
is_contract_dialog_open: boolean;
is_stop_bot_dialog_open: boolean;
- is_enabled_toggle_switch: boolean;
setLossThresholdWarningData: (data: TLossThresholdWarningData) => void;
setFormVisibility: (is_open: boolean) => void;
setSelectedStrategy: (strategy: string) => void;
@@ -42,7 +41,6 @@ interface IQuickStrategyStore {
onSubmit: (data: TFormData) => void;
toggleStopBotDialog: () => void;
setCurrentDurationMinMax: (min: number, max: number) => void;
- setIsEnabledToggleSwitch: () => void;
}
export default class QuickStrategyStore implements IQuickStrategyStore {
@@ -64,7 +62,6 @@ export default class QuickStrategyStore implements IQuickStrategyStore {
loss_threshold_warning_data: TLossThresholdWarningData = {
show: false,
};
- is_enabled_toggle_switch = !!this.form_data.boolean_max_stake;
constructor(root_store: RootStore) {
makeObservable(this, {
@@ -83,8 +80,6 @@ export default class QuickStrategyStore implements IQuickStrategyStore {
setLossThresholdWarningData: action,
setValue: action,
toggleStopBotDialog: action,
- is_enabled_toggle_switch: observable,
- setIsEnabledToggleSwitch: action,
});
this.root_store = root_store;
reaction(
@@ -112,10 +107,6 @@ export default class QuickStrategyStore implements IQuickStrategyStore {
};
};
- setIsEnabledToggleSwitch = () => {
- this.is_enabled_toggle_switch = !this.is_enabled_toggle_switch;
- };
-
setFormVisibility = (is_open: boolean) => {
this.is_open = is_open;
};