diff --git a/src/components/transactions/SendTransactionModalLink.tsx b/src/components/transactions/SendTransactionModalLink.tsx new file mode 100644 index 0000000..6f2ce01 --- /dev/null +++ b/src/components/transactions/SendTransactionModalLink.tsx @@ -0,0 +1,36 @@ +// Copyright (c) 2020-2021 Drew Lemmy +// This file is part of KristWeb 2 under GPL-3.0. +// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +import { FC, useState } from "react"; + +import { AuthorisedAction } from "@comp/auth/AuthorisedAction"; +import { SendTransactionModal } from "@pages/transactions/send/SendTransactionModal"; + +import { Wallet } from "@wallets"; + +interface Props { + from?: Wallet | string; + to?: string; +} + +export const SendTransactionModalLink: FC = ({ + from, + to, + children +}): JSX.Element => { + const [modalVisible, setModalVisible] = useState(false); + + return <> + setModalVisible(true)}> + {children} + + + + ; +}; diff --git a/src/pages/addresses/AddressButtonRow.tsx b/src/pages/addresses/AddressButtonRow.tsx index de37436..247159d 100644 --- a/src/pages/addresses/AddressButtonRow.tsx +++ b/src/pages/addresses/AddressButtonRow.tsx @@ -9,6 +9,7 @@ import { KristAddressWithNames } from "@api/lookup"; import { Wallet } from "@wallets"; import { WalletEditButton } from "../wallets/WalletEditButton"; +import { SendTransactionModalLink } from "@comp/transactions/SendTransactionModalLink"; interface Props { address: KristAddressWithNames; @@ -20,17 +21,21 @@ return <> {/* Send/transfer Krist button */} - {myWallet - ? ( - - ) - : ( - - )} + + + {/* Add friend/edit wallet button */} {/* TODO: Change this to edit if they're already a friend */} diff --git a/src/pages/transactions/send/SendTransactionModal.tsx b/src/pages/transactions/send/SendTransactionModal.tsx index 7abc748..562da27 100644 --- a/src/pages/transactions/send/SendTransactionModal.tsx +++ b/src/pages/transactions/send/SendTransactionModal.tsx @@ -9,7 +9,7 @@ import { Link } from "react-router-dom"; -import { useWallets } from "@wallets"; +import { useWallets, Wallet } from "@wallets"; import { NoWalletsModal } from "@comp/results/NoWalletsResult"; import { KristTransaction } from "@api/types"; @@ -21,11 +21,16 @@ interface Props { visible: boolean; setVisible: Dispatch>; + + from?: Wallet | string; + to?: string; } export function SendTransactionModal({ visible, - setVisible + setVisible, + from, + to }: Props): JSX.Element { const { t } = useTranslation(); @@ -34,6 +39,9 @@ // Create the transaction form const { isSubmitting, triggerSubmit, triggerReset, txForm } = useTransactionForm({ + from, + to, + // Display a success notification when the transaction is made onSuccess(tx: KristTransaction) { notif.success({