diff --git a/src/pages/contacts/ContactsPage.tsx b/src/pages/contacts/ContactsPage.tsx
index 075ac8e..3827c10 100644
--- a/src/pages/contacts/ContactsPage.tsx
+++ b/src/pages/contacts/ContactsPage.tsx
@@ -1,17 +1,14 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under AGPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { useState } from "react";
-import { Button } from "antd";
-import { PlusOutlined } from "@ant-design/icons";
-
import { useTFns } from "@utils/i18n";
import { PageLayout } from "@layout/PageLayout";
import { useContacts } from "@contacts";
+
+import { useContactsPageActions } from "./ContactsPageActions";
import { ContactsTable } from "./ContactsTable";
-import { AddContactModal } from "./AddContactModal";
import { useEditContactModal } from "./ContactEditButton";
import { useSendTransactionModal } from "@comp/transactions/SendTransactionModalLink";
@@ -29,32 +26,16 @@
}>;
}
-function ContactsPageExtraButtons(): JSX.Element {
- const { tStr } = useTFns("addressBook.");
- const [addContactVisible, setAddContactVisible] = useState(false);
-
- return <>
- {/* Add contact */}
- }
- onClick={() => setAddContactVisible(true)}
- >
- {tStr("buttonAddContact")}
-
-
-
- >;
-}
-
export function ContactsPage(): JSX.Element {
const [openEditContact, editContactModal] = useEditContactModal();
const [openSendTx, sendTxModal] = useSendTransactionModal();
+ const extra = useContactsPageActions();
+
return }
- extra={}
+ extra={extra}
>
>;
+}
+
+function ContactsPageActions({
+ setAddContactVisible
+}: ExtraButtonsProps): JSX.Element {
+ const { tStr } = useTFns("addressBook.");
+
+ return <>
+ {/* Add contact */}
+ }
+ onClick={() => setAddContactVisible(true)}
+ >
+ {tStr("buttonAddContact")}
+
+ >;
+}
+
+export function useContactsPageActions(): JSX.Element {
+ const { tStr } = useTFns("addressBook.");
+
+ const [addContactVisible, setAddContactVisible] = useState(false);
+
+ const [usingTopMenu, set, unset] = useTopMenuOptions();
+ useEffect(() => {
+ set(<>
+ {/* Add contact */}
+ setAddContactVisible(true)}>
+ {tStr("buttonAddContact")}
+
+ >);
+
+ return unset;
+ }, [tStr, set, unset]);
+
+ return <>
+ {!usingTopMenu && }
+
+
+ >;
+}
diff --git a/src/pages/wallets/WalletsPageActions.tsx b/src/pages/wallets/WalletsPageActions.tsx
index 8bb8552..de33543 100644
--- a/src/pages/wallets/WalletsPageActions.tsx
+++ b/src/pages/wallets/WalletsPageActions.tsx
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under AGPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { useEffect, useState, Dispatch, SetStateAction} from "react";
+import { useEffect, useState, Dispatch, SetStateAction } from "react";
import { Button, Menu } from "antd";
import { PlusOutlined, ImportOutlined, ExportOutlined } from "@ant-design/icons";
@@ -52,7 +52,7 @@
>;
}
-export function useWalletsPageActions(): JSX.Element | null {
+export function useWalletsPageActions(): JSX.Element {
const { tStr } = useTFns("myWallets.");
const [createWalletVisible, setCreateWalletVisible] = useState(false);