Skip to content

Commit

Permalink
fix: filter current pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-path committed Nov 26, 2024
1 parent 025b7a8 commit 0e6bb70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions screens/Trading/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import { IAssetEntry } from "../../../interfaces";
import DataSource from "../../../data/datasource";
import { useAccountId } from "../../../hooks/hooks";

const TradingTable = ({ positionsList }) => {
const TradingTable = ({
positionsList,
filterTitle = "",
}: {
positionsList: any;
filterTitle?: string;
}) => {
const [selectedTab, setSelectedTab] = useState("positions");
const [isClosePositionModalOpen, setIsClosePositionMobileOpen] = useState(false);
const [isChangeCollateralMobileOpen, setIsChangeCollateralMobileOpen] = useState(false);
Expand Down Expand Up @@ -132,6 +138,7 @@ const TradingTable = ({ positionsList }) => {
calculateLeverage={calculateLeverage}
marginConfigTokens={marginConfigTokens}
assets={assets}
filterTitle={filterTitle}
/>
))
) : (
Expand Down Expand Up @@ -252,6 +259,7 @@ const PositionRow = ({
calculateLeverage,
assets,
marginConfigTokens,
filterTitle,
}) => {
// console.log(itemKey, item, index);
const [entryPrice, setEntryPrice] = useState(0);
Expand Down Expand Up @@ -299,7 +307,9 @@ const PositionRow = ({
const positionType = getPositionType(item.token_d_info.token_id);
const marketTitle =
positionType.label === "Long" ? `${symbolP}/${symbolC}` : `${symbolD}/${symbolC}`;

if (filterTitle && marketTitle !== filterTitle) {
return null;
}
const sizeValueLong = parseTokenValue(item.token_p_amount, decimalsP);
const sizeValueShort = parseTokenValue(item.token_d_info.balance, decimalsD);
const sizeValue =
Expand Down
7 changes: 6 additions & 1 deletion screens/Trading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ const Trading = () => {
handleTransactionResults(query?.transactionHashes, query?.errorMessage);
}, [query?.transactionHashes, query?.errorMessage]);

const filterTitle = `${
currentTokenCate1?.metadata?.symbol == "wNEAR" ? "NEAR" : currentTokenCate1?.metadata?.symbol
}/${currentTokenCate2?.metadata?.symbol}`;

//
console.log(marginAccountList);
return (
<LayoutBox>
{/* back */}
Expand Down Expand Up @@ -296,7 +301,7 @@ const Trading = () => {
<TradingOperate />
</div>
</div>
{accountId && <TradingTable positionsList={marginAccountList} />}
{accountId && <TradingTable positionsList={marginAccountList} filterTitle={filterTitle} />}
</LayoutBox>
);
};
Expand Down

0 comments on commit 0e6bb70

Please sign in to comment.