Skip to content

Commit 77cb9a7

Browse files
committed
feat: add type for options
1 parent 817d19e commit 77cb9a7

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

packages/tradershub/src/constants/regulators-modal-content.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
/* eslint-disable sort-keys */
2+
import { TextProps } from '@deriv-com/ui/dist/components/Text';
3+
24
export type TRowItem = {
3-
options?: Record<string, boolean | string>;
5+
options?: {
6+
align?: TextProps['align'];
7+
color?: TextProps['color'];
8+
shouldShowAsterickAtEnd?: boolean;
9+
weight?: TextProps['weight'];
10+
};
411
text: string;
512
};
13+
614
type TRegulatorContent = Record<string, TRowItem | TRowItem[]>;
715

816
export type TRegulatorsContentProps = {
@@ -76,7 +84,7 @@ export const getCFDContents: TRegulatorsContentProps[] = [
7684
{ text: 'Cryptocurrencies' },
7785
],
7886
euRegulator: [
79-
{ options: { should_show_asterick_at_end: true }, text: 'Synthetics' },
87+
{ options: { shouldShowAsterickAtEnd: true }, text: 'Synthetics' },
8088
{ text: 'Forex' },
8189
{ text: 'Stocks' },
8290
{ text: 'Stock indices' },
@@ -143,7 +151,7 @@ export const getOptionsContents: TRegulatorsContentProps[] = [
143151
],
144152
euRegulator: [
145153
{
146-
options: { should_show_asterick_at_end: true },
154+
options: { shouldShowAsterickAtEnd: true },
147155
text: 'Synthetics',
148156
},
149157
{ text: 'Forex' },

packages/tradershub/src/modals/RegulationModal/RegulationModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const RegulationModal = () => (
2525
</th>
2626
</tr>
2727
</thead>
28-
<tbody className=''>
28+
<tbody>
2929
{getCFDContents.map((row, idx) => (
3030
<Row key={row.id} {...row} idx={idx} />
3131
))}

packages/tradershub/src/modals/RegulationModal/Row.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { qtMerge } from '@deriv/quill-design';
3-
import { Text, TextProps } from '@deriv-com/ui/dist/components/Text';
3+
import { Text } from '@deriv-com/ui/dist/components/Text';
44
import { TRegulatorsContentProps, TRowItem } from '../../constants/regulators-modal-content';
55

66
type TProps = TRegulatorsContentProps & {
@@ -26,24 +26,24 @@ const Row = ({ attribute, content, id, idx }: TProps) => (
2626
{Array.isArray(content[rowKey]) ? (
2727
(content[rowKey] as TRowItem[])?.map(item => (
2828
<Text
29-
align={(item?.options?.align as TextProps['align']) ?? 'center'}
29+
align={item?.options?.align ?? 'center'}
3030
as='p'
31-
color={(item?.options?.color as TextProps['color']) ?? 'prominent'}
31+
color={item?.options?.color ?? 'prominent'}
3232
key={`${id}_${rowKey}_${item?.text}`}
3333
size='2xs'
34-
weight={item?.options?.weight as TextProps['weight']}
34+
weight={item?.options?.weight}
3535
>
3636
{item?.text}
37-
{item?.options?.should_show_asterick_at_end && <Text color='error'>*</Text>}
37+
{item?.options?.shouldShowAsterickAtEnd && <Text color='error'>*</Text>}
3838
</Text>
3939
))
4040
) : (
4141
<Text
42-
align={((content[rowKey] as TRowItem)?.options?.align as TextProps['align']) ?? 'center'}
42+
align={(content[rowKey] as TRowItem)?.options?.align ?? 'center'}
4343
as='p'
44-
color={((content[rowKey] as TRowItem)?.options?.color as TextProps['color']) ?? 'prominent'}
44+
color={(content[rowKey] as TRowItem)?.options?.color ?? 'prominent'}
4545
size='2xs'
46-
weight={(content[rowKey] as TRowItem)?.options?.weight as TextProps['weight']}
46+
weight={(content[rowKey] as TRowItem)?.options?.weight}
4747
>
4848
{(content[rowKey] as TRowItem)?.text}
4949
</Text>

0 commit comments

Comments
 (0)