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

Commit 753b9f1

Browse files
fix: extract types for stream_types enum
1 parent a7cace6 commit 753b9f1

File tree

5 files changed

+27
-41
lines changed

5 files changed

+27
-41
lines changed

src/features/Apiexplorer/Schema/RecursiveContent/SchemaBodyHeader/index.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ const SchemaBodyHeader = ({
120120
)}
121121

122122
{is_stream_types && (
123-
<React.Fragment>
124-
<div className={styles.schemaObjectContent}>
125-
<span className={styles.enumLabel}>{'one of'}</span>
126-
<button onClick={() => setIsOpenObject(!is_open_object)}>{'stream_types'}</button>
127-
<span className={`${styles.enumType} ${styles.array}`}>{'array'}</span>
128-
</div>
129-
</React.Fragment>
123+
<div className={styles.schemaObjectContent}>
124+
<span className={styles.enumLabel}>{'one of'}</span>
125+
<button onClick={() => setIsOpenObject(!is_open_object)}>{'stream_types'}</button>
126+
<span className={`${styles.enumType} ${styles.array}`}>{'array'}</span>
127+
</div>
130128
)}
131129

132130
{pattern && (

src/features/Apiexplorer/Schema/RecursiveContent/StreamTypesObject/StreamTypesBody.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import React from 'react';
2+
import { TEnumStreamType } from '@site/src/types';
23
import styles from '../../Schema.module.scss';
34

45
type TStreamTypesBody = {
56
type: string;
6-
_enum: Array<
7-
| 'balance'
8-
| 'candles'
9-
| 'cashier_payments'
10-
| 'p2p_advert'
11-
| 'p2p_advertiser'
12-
| 'p2p_order'
13-
| 'proposal'
14-
| 'proposal_open_contract'
15-
| 'ticks'
16-
| 'transaction'
17-
| 'trading_platform_asset_listing'
18-
| 'website_status'
19-
| 'p2p_settings'
20-
| 'crypto_estimations'
21-
>;
7+
_enum: TEnumStreamType;
228
};
239

2410
const StreamTypesBody = ({ type, _enum }: TStreamTypesBody) => {

src/features/Apiexplorer/Schema/RecursiveContent/StreamTypesObject/__tests__/StreamTypesObject.test.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import React from 'react';
22
import userEvent from '@testing-library/user-event';
33
import { screen, render } from '@testing-library/react';
4+
import { TEnumStreamType } from '@site/src/types';
45
import StreamTypesObject from '..';
56

67
describe('StreamTypesObject', () => {
8+
const _enum: TEnumStreamType = [
9+
'balance',
10+
'candles',
11+
'cashier_payments',
12+
'p2p_advert',
13+
'p2p_advertiser',
14+
'p2p_order',
15+
'proposal',
16+
'proposal_open_contract',
17+
'ticks',
18+
'transaction',
19+
'website_status',
20+
];
721
const json_schema = {
822
stream_types: {
923
description: 'This stream_types description',
1024
type: 'string',
11-
enum: [
12-
'balance',
13-
'candles',
14-
'cashier_payments',
15-
'p2p_advert',
16-
'p2p_advertiser',
17-
'p2p_order',
18-
'proposal',
19-
'proposal_open_contract',
20-
'ticks',
21-
'transaction',
22-
'trading_platform_asset_listing',
23-
'website_status',
24-
'p2p_settings',
25-
'crypto_estimations',
26-
],
25+
enum: _enum,
2726
},
2827
};
2928

src/features/Apiexplorer/Schema/RecursiveContent/StreamTypesObject/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import React, { Suspense } from 'react';
22
import StreamTypesHeader from './StreamTypesHeader';
33
import StreamTypesBody from './StreamTypesBody';
44
import SourceButton from '../../SourceButton/SourceButton';
5+
import { TEnumStreamType } from '@site/src/types';
56
import styles from '../../Schema.module.scss';
67

78
type TStreamTypesObject = {
89
definitions: {
910
stream_types: {
1011
description: string;
1112
type: string;
12-
enum;
13+
enum: TEnumStreamType;
1314
};
1415
};
1516
};

src/types/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApiToken } from '@deriv/api-types';
1+
import { ApiToken, StreamTypes } from '@deriv/api-types';
22
import { Column } from 'react-table';
33

44
export type TTokensArrayType = ApiToken['tokens'];
@@ -15,3 +15,5 @@ export type TInfo = {
1515
auth_required?: number;
1616
auth_scopes?: string[];
1717
};
18+
19+
export type TEnumStreamType = Array<StreamTypes>;

0 commit comments

Comments
 (0)