Skip to content

Commit a059bd1

Browse files
authored
fix: call contracts for on landing company change (deriv-com#17297)
1 parent a93b656 commit a059bd1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/trader/src/AppV2/Hooks/useContractsForCompany.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ const useContractsForCompany = () => {
2828
const [contract_types_list, setContractTypesList] = React.useState<TContractTypesList | []>([]);
2929

3030
const [trade_types, setTradeTypes] = React.useState<TContractType[]>([]);
31-
const { contract_type, onChange, setContractTypesListV2 } = useTraderStore();
31+
const { contract_type, onChange, setContractTypesListV2, processContractsForV2, symbol } = useTraderStore();
3232
const { client } = useStore();
3333
const { loginid, is_switching, landing_company_shortcode } = client;
34+
const prev_landing_company_shortcode_ref = React.useRef(landing_company_shortcode);
3435

3536
const isQueryEnabled = useCallback(() => {
3637
if (isLoginidDefined(loginid) && !landing_company_shortcode) return false;
@@ -163,6 +164,18 @@ const useContractsForCompany = () => {
163164

164165
const new_contract_type = getNewContractType(trade_types);
165166
processNewContractType(new_contract_type);
167+
168+
if (landing_company_shortcode !== prev_landing_company_shortcode_ref.current) {
169+
onChange({
170+
target: {
171+
name: 'symbol',
172+
value: symbol,
173+
},
174+
}).then(() => {
175+
processContractsForV2();
176+
prev_landing_company_shortcode_ref.current = landing_company_shortcode;
177+
});
178+
}
166179
}
167180
} catch (err) {
168181
/* eslint-disable no-console */

0 commit comments

Comments
 (0)