diff --git a/packages/components/src/components/vertical-tab/vertical-tab-header-group.tsx b/packages/components/src/components/vertical-tab/vertical-tab-header-group.tsx index db6280d8ea19..916de88e3f72 100644 --- a/packages/components/src/components/vertical-tab/vertical-tab-header-group.tsx +++ b/packages/components/src/components/vertical-tab/vertical-tab-header-group.tsx @@ -62,7 +62,7 @@ const VerticalTabHeaderGroup = ({ })} onClick={handleClick} > - +
{is_collapsible && ( - +
{is_collapsible && ( string; has_side_note?: boolean; - icon: string; + icon?: string; is_hidden?: boolean; is_disabled?: boolean; + key?: string; label?: string; path?: string; subitems?: number[]; @@ -88,7 +89,7 @@ const VerticalTabHeader = ({ 'dc-vertical-tab__header--active': is_active, })} > - +
{!!count && } {children} @@ -102,7 +103,7 @@ const VerticalTabHeader = ({ })} onClick={handleClick} > - +
{children} <>{item.component} diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index 3db0fb974df8..29f9fc9aba50 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -54,7 +54,7 @@ export const icons = 'IcAppstoreWalletUsdLight', 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', - 'IcAppstoreWarning', + 'IcAppstoreWarning' ], 'brand': [ 'IcBrandDerivEzWordmark', @@ -64,7 +64,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark', + 'IcBrandDxtradeWordmark' ], 'cashier': [ 'IcCashierAdd', @@ -238,7 +238,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier', + 'IcCashier' ], 'common': [ 'IcAccountCross', @@ -611,7 +611,7 @@ export const icons = 'IcWip', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut', + 'IcZoomOut' ], 'contract': [ 'IcContractBarrier', @@ -629,7 +629,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget', + 'IcContractTarget' ], 'currency': [ 'IcCurrencyAud', @@ -653,10 +653,10 @@ export const icons = 'IcCurrencyUsdc', 'IcCurrencyUsdk', 'IcCurrencyUst', - 'IcCurrencyVirtual', + 'IcCurrencyVirtual' ], 'derivez': [ - 'IcDerivez', + 'IcDerivez' ], 'dxtrade': [ 'IcDxtradeDerivX', @@ -673,7 +673,7 @@ export const icons = 'IcDxtradeFinancialPlatform', 'IcDxtradeFinancial', 'IcDxtradeOnePassword', - 'IcDxtradeSyntheticPlatform', + 'IcDxtradeSyntheticPlatform' ], 'flag': [ 'IcFlagDe', @@ -690,7 +690,7 @@ export const icons = 'IcFlagUk', 'IcFlagVi', 'IcFlagZhCn', - 'IcFlagZhTw', + 'IcFlagZhTw' ], 'mt5': [ 'IcMt5Acuity', @@ -719,7 +719,7 @@ export const icons = 'IcMt5SyntheticDashboard', 'IcMt5SyntheticIndices', 'IcMt5SyntheticPlatform', - 'IcMt5TradeTypes', + 'IcMt5TradeTypes' ], 'option': [ 'IcOptionAccumulators', @@ -737,7 +737,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian', + 'IcOptionUpDownAsian' ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -758,7 +758,7 @@ export const icons = 'IcRebrandingDxtrade', 'IcRebrandingMt5Logo', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader', + 'IcRebrandingSmarttrader' ], 'stock': [ 'IcStockAdidasSalomon', @@ -808,7 +808,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom', + 'IcStockZoom' ], 'tradetype': [ 'IcTradetypeAccu', @@ -848,7 +848,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut', + 'IcTradetypeVanillaLongPut' ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1007,7 +1007,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU', + 'IcUnderlyingWLDXAU' ], 'wallet': [ 'IcWalletClearFunds', @@ -1043,6 +1043,6 @@ export const icons = 'IcWalletWebmoneyLight', 'IcWalletWebmoney', 'IcWalletZingpayDark', - 'IcWalletZingpayLight', - ], -} + 'IcWalletZingpayLight' + ] +} \ No newline at end of file diff --git a/packages/shared/src/utils/route/route.ts b/packages/shared/src/utils/route/route.ts index 98e2dec03177..905cb381e859 100644 --- a/packages/shared/src/utils/route/route.ts +++ b/packages/shared/src/utils/route/route.ts @@ -2,7 +2,7 @@ import React from 'react'; // TODO: Add test cases for this type TRoute = { - component?: React.ComponentType; + component?: JSX.Element | null; default?: boolean; exact?: boolean; getTitle?: () => string; diff --git a/packages/trader/src/Modules/SmartChart/Components/buy-toast-notification.tsx b/packages/trader/src/Modules/SmartChart/Components/buy-toast-notification.tsx index 2c86ed3bc8a4..3ea652c14ccc 100644 --- a/packages/trader/src/Modules/SmartChart/Components/buy-toast-notification.tsx +++ b/packages/trader/src/Modules/SmartChart/Components/buy-toast-notification.tsx @@ -6,7 +6,7 @@ import { findContractCategory } from 'Modules/Trading/Helpers/contract-type'; import { observer, useStore } from '@deriv/stores'; type TContractType = { - text: string; + text?: string; value: string; }; diff --git a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-glossary.tsx b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-glossary.tsx index 4685303783d2..32bb4f6c60f8 100644 --- a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-glossary.tsx +++ b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-glossary.tsx @@ -34,7 +34,7 @@ const ContractTypeGlossary = ({ category }: { category: string }) => { { type: 'paragraph', text: localize( - 'The spot price may change by the time your order reaches our servers. When this happens, your payout maybe affected.' + 'The spot price may change by the time your order reaches our servers. When this happens, your payout may be affected.' ), }, ]; diff --git a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.jsx b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.tsx similarity index 68% rename from packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.jsx rename to packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.tsx index a633de6d8d5d..df1a59d4d8a0 100644 --- a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.jsx +++ b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info-header.tsx @@ -1,8 +1,13 @@ -import PropTypes from 'prop-types'; import React from 'react'; import { Icon, Text } from '@deriv/components'; -const Header = ({ onClickGoBack, text_size = 's', title }) => ( +type THeader = { + onClickGoBack?: () => void; + text_size?: string; + title: string; +}; + +const Header = ({ onClickGoBack, text_size = 's', title }: THeader) => (
@@ -13,10 +18,4 @@ const Header = ({ onClickGoBack, text_size = 's', title }) => (
); -Header.propTypes = { - onClickGoBack: PropTypes.func, - text_size: PropTypes.string, - title: PropTypes.string, -}; - export default Header; diff --git a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.jsx b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.tsx similarity index 59% rename from packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.jsx rename to packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.tsx index 32498936adb5..9d3e79963138 100644 --- a/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.jsx +++ b/packages/trader/src/Modules/Trading/Components/Form/ContractType/ContractTypeInfo/contract-type-info.tsx @@ -1,6 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; -import { Button, ThemedScrollbars, Carousel, ButtonToggle } from '@deriv/components'; +import { Button, ThemedScrollbars, ButtonToggle } from '@deriv/components'; import { isMobile } from '@deriv/shared'; import { localize } from '@deriv/translations'; import TradeCategories from 'Assets/Trading/Categories/trade-categories'; @@ -8,35 +7,39 @@ import TradeCategoriesGIF from 'Assets/Trading/Categories/trade-categories-gif'; import { getContractTypes } from '../../../../Helpers/contract-type'; import ContractTypeGlossary from './contract-type-glossary'; import classNames from 'classnames'; +import { TContractType, TList } from '../types'; + +type TInfo = { + handleSelect: ( + type: TContractType, + e: React.MouseEvent + ) => void; + item: TContractType; + list: TList[]; +}; const TABS = { DESCRIPTION: 'description', GLOSSARY: 'glossary', }; -const Info = ({ handleNavigationClick, handleSelect, initial_index, item, list }) => { - const [carousel_index, setCarouselIndex] = React.useState(''); +const Info = ({ handleSelect, item, list }: TInfo) => { const [selected_tab, setSelectedTab] = React.useState(TABS.DESCRIPTION); - const contract_types = getContractTypes(list, item).filter( - i => i.value !== 'rise_fall_equal' && i.value !== 'turbosshort' + const contract_types: TContractType[] | undefined = getContractTypes(list, item)?.filter( + (i: { value: TContractType['value'] }) => i.value !== 'rise_fall_equal' && i.value !== 'turbosshort' ); - const has_toggle_buttons = /accumulator|vanilla/i.test(carousel_index); - const should_show_video = /accumulator|vanilla/i.test(carousel_index); + const has_toggle_buttons = /accumulator|vanilla/i.test(item.value); + const should_show_video = /accumulator|vanilla/i.test(item.value); const is_description_tab_selected = selected_tab === TABS.DESCRIPTION; const is_glossary_tab_selected = selected_tab === TABS.GLOSSARY; const width = isMobile() ? '328' : '528'; const scroll_bar_height = has_toggle_buttons ? '464px' : '560px'; - const selected_contract_type = contract_types.find(type => type.value === carousel_index); - const onClickGlossary = () => setSelectedTab(TABS.GLOSSARY); - const handleItemSelect = active_index => { - setCarouselIndex(contract_types[active_index].value); - handleNavigationClick(contract_types[active_index]); - }; - const cards = contract_types.map((type, idx) => { + const cards = contract_types?.map((type: TContractType) => { + if (type.value !== item.value) return null; return ( -
+
{is_description_tab_selected ? ( - + + + + ) : ( )}
-
- {is_description_tab_selected && ( - - )} -
); @@ -96,25 +93,23 @@ const Info = ({ handleNavigationClick, handleSelect, initial_index, item, list } />
)} - + style={{ + width: isMobile() ? '328px' : '528px', + }} + > + {cards} +