From a059bd1b0ce178eb1b37d7466e790ed466cfccbb Mon Sep 17 00:00:00 2001 From: henry-deriv <118344354+henry-deriv@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:10:41 +0800 Subject: [PATCH] fix: call contracts for on landing company change (#17297) --- .../src/AppV2/Hooks/useContractsForCompany.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/trader/src/AppV2/Hooks/useContractsForCompany.ts b/packages/trader/src/AppV2/Hooks/useContractsForCompany.ts index 8926d2ff1a3b..dfc9f62eddc8 100644 --- a/packages/trader/src/AppV2/Hooks/useContractsForCompany.ts +++ b/packages/trader/src/AppV2/Hooks/useContractsForCompany.ts @@ -28,9 +28,10 @@ const useContractsForCompany = () => { const [contract_types_list, setContractTypesList] = React.useState([]); const [trade_types, setTradeTypes] = React.useState([]); - const { contract_type, onChange, setContractTypesListV2 } = useTraderStore(); + const { contract_type, onChange, setContractTypesListV2, processContractsForV2, symbol } = useTraderStore(); const { client } = useStore(); const { loginid, is_switching, landing_company_shortcode } = client; + const prev_landing_company_shortcode_ref = React.useRef(landing_company_shortcode); const isQueryEnabled = useCallback(() => { if (isLoginidDefined(loginid) && !landing_company_shortcode) return false; @@ -163,6 +164,18 @@ const useContractsForCompany = () => { const new_contract_type = getNewContractType(trade_types); processNewContractType(new_contract_type); + + if (landing_company_shortcode !== prev_landing_company_shortcode_ref.current) { + onChange({ + target: { + name: 'symbol', + value: symbol, + }, + }).then(() => { + processContractsForV2(); + prev_landing_company_shortcode_ref.current = landing_company_shortcode; + }); + } } } catch (err) { /* eslint-disable no-console */