From 7b5d4c3255d3b0fb73675a64d41f0223b0d6e04b Mon Sep 17 00:00:00 2001 From: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:00:46 +0200 Subject: [PATCH] Mp 2546 borrow asset modal (#255) * Refactor Modal folder and setup basic addassetsmodal * basic tables * Update basic logic * small fixes * Update closing for modals * fix slider update bug and set borrowing subtitle * fix store * add missing dependency * fix tests for VaultBorrowings * Add DisplayCurrency test for VaultBorrowings * trigger updated * update borrowModal import path * update imports for modals * updating paths again * update structure of modals directory * fix all file naming and relative imports * fix icon spacing button and jest.mocked import * fix icon classes for button * change Map to array and add BNCoin * add AssetImage * update logic for selecting borrow denoms --- .../Modals/vault/VaultBorrowings.test.tsx | 47 ++++- src/api/markets/getMarketBorrowings.ts | 6 +- src/components/Accordion.tsx | 8 +- src/components/Account/AccountSummary.tsx | 4 +- src/components/AssetImage.tsx | 19 ++ src/components/Borrow/BorrowTable.tsx | 3 +- src/components/Button/index.tsx | 10 +- src/components/Checkbox.tsx | 27 +++ src/components/Earn/vault/VaultCard.tsx | 7 +- src/components/Earn/vault/VaultExpanded.tsx | 7 +- src/components/Earn/vault/VaultLogo.tsx | 5 +- src/components/Icons/Search.svg | 3 + src/components/Icons/index.ts | 1 + src/components/Modal.tsx | 13 +- .../AddVaultAssets/AddVaultAssetTable.tsx | 129 ++++++++++++ .../AddVaultBorrowAssetsModal.tsx | 46 ++++ .../AddVaultBorrowAssetsModalContent.tsx | 96 +++++++++ .../useAddVaultAssetTableColumns.tsx | 54 +++++ .../Modals/{ => Borrow}/BorrowModal.tsx | 4 +- .../FundAndWithdrawModal.tsx | 3 +- .../FundAndWithdrawModalContent.tsx} | 0 src/components/Modals/ModalsContainer.tsx | 8 +- .../Modals/Vault/VaultBorrowings.tsx | 197 ++++++++++++++++++ .../Modals/Vault/VaultBorrowingsSubTitle.tsx | 49 +++++ .../VaultDeposits.tsx} | 0 .../VaultDepositsSubTitle.tsx} | 0 .../Modals/{vault => Vault}/VaultModal.tsx | 3 +- .../{vault => Vault}/VaultModalContent.tsx | 20 +- .../Modals/vault/VaultBorrowings.tsx | 112 ---------- src/components/SearchBar.tsx | 34 +++ src/components/Select/Option.tsx | 26 +-- src/components/TokenInput.tsx | 3 +- src/components/Tooltip/index.tsx | 3 +- src/constants/assets.ts | 2 + src/hooks/useMarketBorrowings.tsx | 3 +- src/hooks/usePrice.tsx | 2 +- src/hooks/useUpdateAccount.tsx | 33 +-- src/store/slices/modal.ts | 1 + src/types/classes/BNCoin.ts | 18 ++ src/types/interfaces/asset.d.ts | 9 +- .../store/{comon.d.ts => common.d.ts} | 4 +- src/types/interfaces/store/modals.d.ts | 14 +- src/utils/assets.ts | 4 + src/utils/vaults.ts | 7 +- 44 files changed, 845 insertions(+), 199 deletions(-) create mode 100644 src/components/AssetImage.tsx create mode 100644 src/components/Checkbox.tsx create mode 100644 src/components/Icons/Search.svg create mode 100644 src/components/Modals/AddVaultAssets/AddVaultAssetTable.tsx create mode 100644 src/components/Modals/AddVaultAssets/AddVaultBorrowAssetsModal.tsx create mode 100644 src/components/Modals/AddVaultAssets/AddVaultBorrowAssetsModalContent.tsx create mode 100644 src/components/Modals/AddVaultAssets/useAddVaultAssetTableColumns.tsx rename src/components/Modals/{ => Borrow}/BorrowModal.tsx (98%) rename src/components/Modals/{fundwithdraw => FundWithdraw}/FundAndWithdrawModal.tsx (92%) rename src/components/Modals/{fundwithdraw/FundWithdrawModalContent.tsx => FundWithdraw/FundAndWithdrawModalContent.tsx} (100%) create mode 100644 src/components/Modals/Vault/VaultBorrowings.tsx create mode 100644 src/components/Modals/Vault/VaultBorrowingsSubTitle.tsx rename src/components/Modals/{vault/VaultDeposit.tsx => Vault/VaultDeposits.tsx} (100%) rename src/components/Modals/{vault/VaultDepositSubTitle.tsx => Vault/VaultDepositsSubTitle.tsx} (100%) rename src/components/Modals/{vault => Vault}/VaultModal.tsx (95%) rename src/components/Modals/{vault => Vault}/VaultModalContent.tsx (77%) delete mode 100644 src/components/Modals/vault/VaultBorrowings.tsx create mode 100644 src/components/SearchBar.tsx create mode 100644 src/types/classes/BNCoin.ts rename src/types/interfaces/store/{comon.d.ts => common.d.ts} (100%) diff --git a/__tests__/components/Modals/vault/VaultBorrowings.test.tsx b/__tests__/components/Modals/vault/VaultBorrowings.test.tsx index 75301cb0..3c1f0c0a 100644 --- a/__tests__/components/Modals/vault/VaultBorrowings.test.tsx +++ b/__tests__/components/Modals/vault/VaultBorrowings.test.tsx @@ -1,25 +1,36 @@ import { render } from '@testing-library/react' -import VaultBorrowings from 'components/Modals/vault/VaultBorrowings' -import BigNumber from 'bignumber.js' +import { ASSETS } from 'constants/assets' +import { BN } from 'utils/helpers' +import useStore from 'store' +import DisplayCurrency from 'components/DisplayCurrency' +import VaultBorrowings, { VaultBorrowingsProps } from 'components/Modals/Vault/VaultBorrowings' jest.mock('hooks/usePrices', () => jest.fn(() => ({ data: [], })), ) + +jest.mock('hooks/usePrice', () => jest.fn(() => '1')) + jest.mock('hooks/useMarketAssets', () => jest.fn(() => ({ data: [], })), ) +jest.mock('components/DisplayCurrency') +const mockedDisplayCurrency = jest + .mocked(DisplayCurrency) + .mockImplementation(() =>
+
+
+ {header.column.getCanSort()
+ ? {
+ asc:
+ |
+ )
+ })}
+
---|
+ {flexRender(cell.column.columnDef.cell, cell.getContext())} + | + ) + })} +