Skip to content

Commit

Permalink
fix: set default trade type when switching to vanillas and turbos (de…
Browse files Browse the repository at this point in the history
  • Loading branch information
akmal-deriv authored Oct 14, 2024
1 parent 0d1b31b commit ba2717f
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ type TTradeTypeTabsProps = {
const TradeTypeTabs = observer(({ is_minimized }: TTradeTypeTabsProps) => {
const { contract_type, onChange, trade_type_tab, setTradeTypeTab } = useTraderStore();
const tab_list = getTradeTypeTabsList(contract_type);
const initial_index = tab_list.findIndex(tab =>
trade_type_tab ? tab.contract_type === trade_type_tab : tab.value === contract_type
);
let initial_index = 0;

// If the trade type tab is VANILLALONGPUT or TURBOSSHORT, keep the first tab
if (
!(
(trade_type_tab === 'VANILLALONGPUT' && contract_type === 'vanillalongcall') ||
(trade_type_tab === 'TURBOSSHORT' && contract_type === 'turboslong')
)
) {
initial_index = tab_list.findIndex(tab =>
trade_type_tab ? tab.contract_type === trade_type_tab : tab.value === contract_type
);
}

const initial_tab_index = initial_index < 0 ? 0 : initial_index;
const [tab_index, setTabIndex] = React.useState(initial_tab_index);

Expand Down

0 comments on commit ba2717f

Please sign in to comment.