Загрузка данных
diff --git a/src/components/InstrumentSearch/components/Wrapper/index.tsx b/src/components/InstrumentSearch/components/Wrapper/index.tsx
index b4ffc3827b1b020b1a6097d23c45576c77ed3043..1ee12b805534f162d71da020d8fd7144f7165730 100644
--- a/src/components/InstrumentSearch/components/Wrapper/index.tsx
+++ b/src/components/InstrumentSearch/components/Wrapper/index.tsx
@@ -10,13 +10,14 @@ type IWrapper = {
children: ReactNode;
setOpen: (b: boolean) => void;
isOpen: boolean;
+ headerName?: string;
};
/** Компонент обёртка для модального окна */
-export const Wrapper: React.FC<IWrapper> = ({ children, setOpen, isOpen }) => (
+export const Wrapper: React.FC<IWrapper> = ({ children, setOpen, isOpen, headerName }) => (
<Modal isOpen={isOpen}>
<div className={styles.modalWrapper}>
<header>
- <TextInput>Поиск инструментов</TextInput>
+ <TextInput>{ headerName ?? 'Поиск инструментов' }</TextInput>
<div
onClick={() => {
setOpen(false);
diff --git a/src/components/InstrumentSearch/search.tsx b/src/components/InstrumentSearch/search.tsx
index c142a84b776ca2a529c68a19529b69e8450f598a..aed5205283aa8fe41eb1a85ce31a004236d6e85a 100644
--- a/src/components/InstrumentSearch/search.tsx
+++ b/src/components/InstrumentSearch/search.tsx
@@ -14,6 +14,7 @@ export const InstrumentSearch: FC<InstrumentSearchType> = ({
addInstruments,
customActionsFooterHandlers,
isNewScaleDisabled,
+ headerName,
}) => {
const { filters, actions, table } = useData(variant, setOpen, addInstruments);
const tableProps = { ...table, widgetId };
@@ -22,6 +23,7 @@ export const InstrumentSearch: FC<InstrumentSearchType> = ({
<Wrapper
setOpen={setOpen}
isOpen={isOpen}
+ headerName={headerName}
>
<SearchInput {...filters} />
<Filters {...filters} />
diff --git a/src/components/InstrumentSearch/types/hooks.ts b/src/components/InstrumentSearch/types/hooks.ts
index aa7d44a7ceb4efd3eb4f2c64608f7db2634ae8ab..aa6057d6535678ec67392e426c2fddfc04d5287e 100644
--- a/src/components/InstrumentSearch/types/hooks.ts
+++ b/src/components/InstrumentSearch/types/hooks.ts
@@ -80,6 +80,7 @@ export type InstrumentSearchType = {
handleNewPanel: (instrument: Contract) => void;
};
isNewScaleDisabled?: boolean;
+ headerName?: string;
};
export type InstrumentType = Record<AllFiltersVariants, string | number | null | boolean>;
diff --git a/src/widgets/Chart/__tests__/dataSourceProvide.test.ts b/src/widgets/Chart/__tests__/dataSourceProvide.test.ts
index 2bbe173ff5427a9f87f8aad867603f29a5641f83..4827c9a9115578938d8de75b8910573421f40ed9 100644
--- a/src/widgets/Chart/__tests__/dataSourceProvide.test.ts
+++ b/src/widgets/Chart/__tests__/dataSourceProvide.test.ts
@@ -208,7 +208,7 @@ describe('DataSourceProvider', () => {
const provider = new DataSourceProvider();
const dataSource = provider.getDataSource();
- const result = await dataSource(Timeframes['1m'], DEFAULT_SYMBOL);
+ const result = await dataSource(Timeframes['1m'], DEFAULT_SYMBOL.symbolId);
expect(result).toBeNull();
expect(mockRequestBars).not.toHaveBeenCalled();
@@ -218,7 +218,7 @@ describe('DataSourceProvider', () => {
const provider = new DataSourceProvider();
const dataSource = provider.getDataSource();
- const result = await dataSource(Timeframes['1m'], ` ${DEFAULT_SYMBOL} `);
+ const result = await dataSource(Timeframes['1m'], ` ${DEFAULT_SYMBOL.symbolId} `);
expect(result).toBeNull();
expect(mockRequestBars).not.toHaveBeenCalled();
@@ -659,7 +659,7 @@ describe('DataSourceProvider', () => {
const mockUpdate = jest.fn();
const unsubscribe = provider.startRealtime({
- getSymbols: () => [DEFAULT_SYMBOL],
+ getSymbols: () => [DEFAULT_SYMBOL.symbolId],
getTimeframe: () => Timeframes['1m'],
update: mockUpdate,
periodMs: 1000,
diff --git a/src/widgets/Chart/__tests__/useChartPublicContext.test.tsx b/src/widgets/Chart/__tests__/useChartPublicContext.test.tsx
index 0b0f2057249d256e59239aeba58b38632c27e8f9..a5957a0cc51529ed66a0422cb36e39b4aec35f1b 100644
--- a/src/widgets/Chart/__tests__/useChartPublicContext.test.tsx
+++ b/src/widgets/Chart/__tests__/useChartPublicContext.test.tsx
@@ -39,7 +39,7 @@ describe('useChartPublicContext', () => {
const mockContracts = [
{
- issKey: DEFAULT_SYMBOL,
+ issKey: DEFAULT_SYMBOL.symbolId,
displayName: 'Инструмент по умолчанию',
symbol: 'DEFAULT',
// ... other contract properties
@@ -220,7 +220,7 @@ describe('useChartPublicContext', () => {
// Assert
expect(mockSetCurrInstrument).toHaveBeenCalledTimes(1);
expect(mockSetCurrInstrument).toHaveBeenCalledWith({
- symbolId: DEFAULT_SYMBOL,
+ symbolId: DEFAULT_SYMBOL.symbolId,
symbol: 'DEFAULT',
symbolName: 'Инструмент по умолчанию',
});
diff --git a/src/widgets/Chart/components/MoexChart/components/CompareModal.tsx b/src/widgets/Chart/components/MoexChart/components/CompareModal.tsx
index 6f48a72671648ca543bca0daaaabee539c5cdc91..98ffd54a8ffe7c3a11bb8b4f926ff61eea2c8be6 100644
--- a/src/widgets/Chart/components/MoexChart/components/CompareModal.tsx
+++ b/src/widgets/Chart/components/MoexChart/components/CompareModal.tsx
@@ -82,6 +82,7 @@ export const CompareModal = ({ compareManager, widgetId, isOpen, setOpen }: Comp
handleNewScale,
handleNewPanel,
}}
+ headerName='Сравнить инструменты'
/>
);
};
diff --git a/src/widgets/Chart/components/MoexChart/dataSourceProvide.ts b/src/widgets/Chart/components/MoexChart/dataSourceProvide.ts
index b27ddb1faa10bc5584fc85c8e08415fc06e1d2f8..3ca863b40b5a5130537a4dbecac3b35c90efe8b0 100644
--- a/src/widgets/Chart/components/MoexChart/dataSourceProvide.ts
+++ b/src/widgets/Chart/components/MoexChart/dataSourceProvide.ts
@@ -3,7 +3,6 @@ import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import { moexChartTimeConverter, moexChartToIssTimeframe } from '@utils/chartToReqTimeConverter';
-import { DEFAULT_SYMBOL } from '@widgets/Chart/const';
import { requestBars, requestRealtimeBars } from '../../requestBars';
import { ChartIndicativeData } from '../../types';
@@ -21,7 +20,7 @@ interface RealtimeState {
function getRequestSymbol(symbolRaw?: string): string | undefined {
const symbol = String(symbolRaw ?? '').trim();
- if (!symbol || symbol === DEFAULT_SYMBOL) {
+ if (!symbol) {
return undefined;
}
diff --git a/src/widgets/Chart/const.ts b/src/widgets/Chart/const.ts
index e7bfbfac9c95acf7c2e8e3713f79d94c08f72dfa..eeffc33b560c98dc0e7b320cccae8c0cb8b2ce98 100644
--- a/src/widgets/Chart/const.ts
+++ b/src/widgets/Chart/const.ts
@@ -1 +1,5 @@
-export const DEFAULT_SYMBOL = '';
+export const DEFAULT_SYMBOL = {
+ symbolId: 'INDICES:SNDX:IMOEX',
+ symbol: "IMOEX",
+ symbolName: "Индекс МосБиржи"
+};
diff --git a/src/widgets/Chart/hooks/useChartComponentFacade.tsx b/src/widgets/Chart/hooks/useChartComponentFacade.tsx
index 9fd119f338c3712b8ae09525d4448beb7a60bfd7..7ec97a44ab8d857ca11c393b0ab00dfce9991c1c 100644
--- a/src/widgets/Chart/hooks/useChartComponentFacade.tsx
+++ b/src/widgets/Chart/hooks/useChartComponentFacade.tsx
@@ -51,11 +51,17 @@ export default function useChartComponentFacade(props: ChartContainerProps): Use
// TODO временно реф из-за непредсказуемого изменения если используется useState,
// нужен рефакторинг и вернуть обратно useState
- const currentSymbolInfoRef = useRef<SymbolInfoInput>({
- symbolId: widgetProperties?.chartState?.savedInstrument ?? DEFAULT_SYMBOL,
- symbol: widgetProperties?.chartState?.savedSymbol,
- symbolName: widgetProperties?.chartState?.savedSymbolName,
- });
+ const currentSymbolInfoRef = useRef<SymbolInfoInput>(DEFAULT_SYMBOL)
+
+ const savedInstrument = widgetProperties?.chartState?.savedInstrument
+
+ if(savedInstrument){
+ currentSymbolInfoRef.current = {
+ symbolId: savedInstrument,
+ symbol: widgetProperties?.chartState?.savedSymbol,
+ symbolName: widgetProperties?.chartState?.savedSymbolName,
+ };
+ }
const [currentSymbolInfo, setCurrentSymbolInfo] = useState<SymbolInfoInput>(currentSymbolInfoRef.current);
diff --git a/src/widgets/Chart/hooks/useChartPublicContext.ts b/src/widgets/Chart/hooks/useChartPublicContext.ts
index 6a71316e05c1e8a0d0cc7ab261306a3c5e165490..a50be700ce7b824360688d648ff5f1a792a9b15c 100644
--- a/src/widgets/Chart/hooks/useChartPublicContext.ts
+++ b/src/widgets/Chart/hooks/useChartPublicContext.ts
@@ -42,13 +42,7 @@ export function useChartPublicContext({
const fieldValue = getMasterInstrumentFromPublicContext();
if (!fieldValue && widget?.master) {
- const defaultInstrument = instruments.find((instrument) => instrument.issKey === DEFAULT_SYMBOL);
-
- setCurrInstrument({
- symbolId: DEFAULT_SYMBOL,
- symbol: defaultInstrument?.symbol ?? undefined,
- symbolName: defaultInstrument?.displayName ?? undefined,
- });
+ setCurrInstrument(DEFAULT_SYMBOL);
return;
}