diff --git a/src/Router.tsx b/src/Router.tsx index 4b0f62865..713aa6287 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -16,7 +16,6 @@ import OperationsView from "./views/operations/OperationsView"; import SettingsView from "./views/settings/SettingsView"; import { withSideMenu } from "./views/withSideMenu"; import HelpView from "./views/help/HelpView"; -import DelegationsView from "./views/delegations/DelegationsView"; import AddressBookView from "./views/addressBook/AddressBookView"; import BatchView from "./views/batch/BatchView"; import { resetBeacon, useBeaconInit } from "./utils/beacon/beacon"; @@ -52,7 +51,6 @@ const MemoizedRouter = React.memo(() => { )} /> )} /> )} /> - )} /> )} /> )} /> )} /> diff --git a/src/components/SideNavbar.tsx b/src/components/SideNavbar.tsx index 9daf5bcf2..14722524f 100644 --- a/src/components/SideNavbar.tsx +++ b/src/components/SideNavbar.tsx @@ -11,7 +11,6 @@ import { MdSupport, MdViewCompact, } from "react-icons/md"; -import { RxCube } from "react-icons/rx"; import { Link } from "react-router-dom"; import colors from "../style/colors"; import { useTotalBalance } from "../utils/hooks/assetsHooks"; @@ -78,7 +77,6 @@ export const SideNavbar = () => { - diff --git a/src/views/delegations/DelegationsView.test.tsx b/src/views/delegations/DelegationsView.test.tsx deleted file mode 100644 index 16a89bb4c..000000000 --- a/src/views/delegations/DelegationsView.test.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import { mockDelegation, mockImplicitAccount, mockImplicitAddress } from "../../mocks/factories"; -import { ReduxStore } from "../../providers/ReduxStore"; -import accountsSlice from "../../utils/redux/slices/accountsSlice"; -import assetsSlice from "../../utils/redux/slices/assetsSlice"; -import store from "../../utils/redux/store"; -import DelegationsView from "./DelegationsView"; - -jest.mock("react-query"); -const { updateDelegations } = assetsSlice.actions; - -const fixture = () => ( - - - -); - -beforeEach(() => { - store.dispatch(accountsSlice.actions.addAccount([mockImplicitAccount(0)])); -}); - -describe("", () => { - it("a message 'currently not delegating' is displayed", () => { - render(fixture()); - expect(screen.getByText(/currently not delegating/i)).toBeInTheDocument(); - }); - - it("should display the delegations of all accounts", () => { - store.dispatch( - accountsSlice.actions.addAccount([ - mockImplicitAccount(1), - mockImplicitAccount(2), - mockImplicitAccount(3), - ]) - ); - store.dispatch( - updateDelegations([ - { - pkh: mockImplicitAccount(1).address.pkh, - delegation: mockDelegation( - 1, - 17890, - mockImplicitAddress(4).pkh, - "Baker 1", - new Date("2022-10-01") - ), - }, - { - pkh: mockImplicitAccount(2).address.pkh, - delegation: mockDelegation(2, 85000, mockImplicitAddress(5).pkh, "Baker 2"), - }, - { - pkh: mockImplicitAccount(3).address.pkh, - delegation: mockDelegation(3, 37490, mockImplicitAddress(6).pkh, "Baker 3"), - }, - ]) - ); - render(fixture()); - expect(screen.getAllByTestId("delegation-row")).toHaveLength(3); - }); -}); diff --git a/src/views/delegations/DelegationsView.tsx b/src/views/delegations/DelegationsView.tsx deleted file mode 100644 index c0a77e4cd..000000000 --- a/src/views/delegations/DelegationsView.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import { - Box, - Flex, - IconButton, - Table, - TableContainer, - Tbody, - Td, - Th, - Thead, - Tr, -} from "@chakra-ui/react"; -import { compact } from "lodash"; -import { CiCircleRemove } from "react-icons/ci"; -import { MdOutlineModeEdit } from "react-icons/md"; -import { VscWand } from "react-icons/vsc"; -import { useAccountsFilterWithMapFilter } from "../../components/useAccountsFilter"; -import { AccountSmallTile } from "../../components/AccountSelector/AccountSmallTile"; -import { IconAndTextBtn } from "../../components/IconAndTextBtn"; -import { NoDelegations } from "../../components/NoItems"; -import { TopBar } from "../../components/TopBar"; -import { Delegation, makeDelegation } from "../../types/Delegation"; -import { objectMap } from "../../utils/helpers"; -import { useGetOwnedAccount } from "../../utils/hooks/accountHooks"; -import { useAllDelegations } from "../../utils/hooks/assetsHooks"; -import { useGetDelegationPrettyDisplayValues } from "../../utils/hooks/delegationHooks"; -import colors from "../../style/colors"; -import { useContext } from "react"; -import { DynamicModalContext } from "../../components/DynamicModal"; -import DelegationFormPage from "../../components/SendFlow/Delegation/FormPage"; -import UndelegationFormPage from "../../components/SendFlow/Undelegation/FormPage"; -import AddressPill from "../../components/AddressPill/AddressPill"; -import { parsePkh } from "../../types/Address"; - -const DelegationsTable = ({ delegations }: { delegations: Delegation[] }) => { - const getDelegationPrettyDisplay = useGetDelegationPrettyDisplayValues(); - const { openWith } = useContext(DynamicModalContext); - const getOwnedAccount = useGetOwnedAccount(); - return ( - - - { - // Finally a way to have a sticky Header - // https://github.com/chakra-ui/chakra-ui/discussions/5656#discussioncomment-3320528 - } - - - Account: - Initial Balance: - Current Balance: - Duration: - Baker: - {/* For buttons */} - - - - {delegations.map(delegation => { - const { currentBalance, duration, initialBalance } = - getDelegationPrettyDisplay(delegation); - const sender = getOwnedAccount(delegation.sender); - return ( - - - - - {initialBalance} - {currentBalance} - {duration} - - - - - { - openWith( - - ); - }} - aria-label="Change Baker" - icon={} - variant="circle" - mb={2} - /> - openWith()} - variant="circle" - aria-label="Delete Baker" - icon={} - mb={2} - /> - - - ); - })} - - - - ); -}; - -const DelegationsView = () => { - const delegationsOps = useAllDelegations(); - const { filterMap: filter, accountsFilter } = useAccountsFilterWithMapFilter(); - const delegationsArrays = objectMap(delegationsOps, d => (d ? [d] : undefined)); - const delegationsToDisplay = compact(filter(delegationsArrays).map(makeDelegation)); - const { openWith } = useContext(DynamicModalContext); - - return ( - - - - {accountsFilter} - openWith()} - color={colors.green} - icon={VscWand} - label="Delegate" - /> - - {delegationsToDisplay.length > 0 ? ( - - - - ) : ( - openWith()} /> - )} - - ); -}; - -// eslint-disable-next-line import/no-anonymous-default-export -export default DelegationsView;