Skip to content

Commit

Permalink
simplified code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Jul 13, 2024
1 parent d1c6a3a commit bd958de
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/yoroi-extension/app/containers/swap/orders/OrdersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,9 @@ export default function SwapOrdersPage(props: StoresAndActionsProps): Node {
.map(c => resolveValueOrGetter(c.width ?? 'auto', columnContext))
.join(' ');

const isOpenOrdersEmpty = openOrders?.length === 0 && !showCompletedOrders;
const isCompleteOrdersEmpty = completedOrders?.length === 0 && showCompletedOrders;

const handleColumnNames = () => {
if (isOpenOrdersEmpty) {
return [];
}
if (isCompleteOrdersEmpty) {
return [];
}
return columnNames;
};
const isDisplayOpenOrdersEmpty = openOrders?.length === 0 && !showCompletedOrders;
const isDisplayCompletedOrdersEmpty = completedOrders?.length === 0 && showCompletedOrders;
const safeColumnNames = isDisplayOpenOrdersEmpty || isDisplayCompletedOrdersEmpty ? [] : columnNames;

return (
<Box sx={{ border: '1px solid transparent' }}>
Expand All @@ -415,7 +406,7 @@ export default function SwapOrdersPage(props: StoresAndActionsProps): Node {

<Table
columnKeys={columnKeys}
columnNames={handleColumnNames()}
columnNames={safeColumnNames}
columnAlignment={columnAlignment}
columnLeftPaddings={columnLeftPaddings}
gridTemplateColumns={gridTemplateColumns}
Expand Down Expand Up @@ -463,8 +454,8 @@ export default function SwapOrdersPage(props: StoresAndActionsProps): Node {
hwWalletError={null}
/>
)}
{isOpenOrdersEmpty && <NoOpenOrders />}
{isCompleteOrdersEmpty && <NoCompleteOrders />}
{isDisplayOpenOrdersEmpty && <NoOpenOrders />}
{isDisplayCompletedOrdersEmpty && <NoCompleteOrders />}
</Box>
);
}
Expand Down

0 comments on commit bd958de

Please sign in to comment.