From 55b27b698887a4a145237d47da6c22e3f37538ff Mon Sep 17 00:00:00 2001 From: henry-deriv <118344354+henry-deriv@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:44:13 +0800 Subject: [PATCH] [DTRA] henry/dtra-1708/fix: resolve console errors in dtrader v2 (#16666) * fix: resolve console errors in dtrader v2 * fix: resolve comment --- packages/trader/src/AppV2/Components/Guide/guide.tsx | 2 +- .../src/AppV2/Components/TradeParameters/Stake/stake.tsx | 3 ++- .../src/AppV2/Components/TradeParameters/trade-parameters.tsx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/trader/src/AppV2/Components/Guide/guide.tsx b/packages/trader/src/AppV2/Components/Guide/guide.tsx index 0eeb1b04539d..beedfc917cec 100644 --- a/packages/trader/src/AppV2/Components/Guide/guide.tsx +++ b/packages/trader/src/AppV2/Components/Guide/guide.tsx @@ -19,7 +19,7 @@ const Guide = observer(({ has_label, show_guide_for_selected_contract }: TGuide) ui: { is_dark_mode_on }, } = useStore(); const { contract_type, is_vanilla } = useTraderStore(); - const contract_type_title = is_vanilla ? CONTRACT_LIST.VANILLAS : getContractTypesConfig()[contract_type].title; + const contract_type_title = is_vanilla ? CONTRACT_LIST.VANILLAS : getContractTypesConfig()[contract_type]?.title; const [is_description_opened, setIsDescriptionOpened] = React.useState(false); const [selected_contract_type, setSelectedContractType] = React.useState( diff --git a/packages/trader/src/AppV2/Components/TradeParameters/Stake/stake.tsx b/packages/trader/src/AppV2/Components/TradeParameters/Stake/stake.tsx index 7ca1280637c9..a1e5a5524d42 100644 --- a/packages/trader/src/AppV2/Components/TradeParameters/Stake/stake.tsx +++ b/packages/trader/src/AppV2/Components/TradeParameters/Stake/stake.tsx @@ -55,7 +55,8 @@ const Stake = observer(({ is_minimized }: TStakeProps) => { const is_loading_proposal = !id_1 || (!!contract_types[1] && !id_2); const proposal_error_message_1 = has_error_1 ? message_1 : ''; const proposal_error_message_2 = has_error_2 ? message_2 : ''; - const proposal_error_message = proposal_error_message_1 || proposal_error_message_2 || validation_errors?.amount[0]; + const proposal_error_message = + proposal_error_message_1 || proposal_error_message_2 || validation_errors?.amount?.[0]; /* TODO: stop using Max payout from error text as a default max payout and stop using error text for is_max_payout_exceeded after validation_params are added to proposal API (both success & error response): E.g., for is_max_payout_exceeded, we have to temporarily check the error text: Max payout error always contains 3 numbers, the check will work for any languages: */ const float_number_search_regex = /\d+(\.\d+)?/g; diff --git a/packages/trader/src/AppV2/Components/TradeParameters/trade-parameters.tsx b/packages/trader/src/AppV2/Components/TradeParameters/trade-parameters.tsx index ec719831c035..cac00c66bb52 100644 --- a/packages/trader/src/AppV2/Components/TradeParameters/trade-parameters.tsx +++ b/packages/trader/src/AppV2/Components/TradeParameters/trade-parameters.tsx @@ -27,7 +27,7 @@ type TTradeParametersProps = { const TradeParameters = observer(({ is_minimized }: TTradeParametersProps) => { const { contract_type, symbol } = useTraderStore(); const isVisible = (component_key: string) => { - const params = getTradeParams(symbol)[contract_type]; + const params = getTradeParams(symbol)?.[contract_type] ?? {}; return component_key in params; };