Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Contacts/index.tsx
| // Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| import React, { useState, useContext } from 'react'; | import React, { useState, useContext } from 'react'; | ||||
| import { WalletContext, isWalletContextLoaded } from 'wallet/context'; | import { WalletContext, isWalletContextLoaded } from 'wallet/context'; | ||||
| import ActionButtonRow from 'components/Common/ActionButtonRow'; | |||||
| import { | import { | ||||
| TrashcanIcon, | TrashcanIcon, | ||||
| EditIcon, | EditIcon, | ||||
| SendIcon, | SendIcon, | ||||
| ContactsIcon, | |||||
| } from 'components/Common/CustomIcons'; | } from 'components/Common/CustomIcons'; | ||||
| import Modal from 'components/Common/Modal'; | import Modal from 'components/Common/Modal'; | ||||
| import { ModalInput, InputFlex } from 'components/Common/Inputs'; | import { ModalInput, InputFlex } from 'components/Common/Inputs'; | ||||
| import { toast } from 'react-toastify'; | import { toast } from 'react-toastify'; | ||||
| import PrimaryButton, { | import PrimaryButton, { | ||||
| SecondaryButton, | SecondaryButton, | ||||
| IconButton, | IconButton, | ||||
| IconLink, | IconLink, | ||||
| CopyIconButton, | CopyIconButton, | ||||
| } from 'components/Common/Buttons'; | } from 'components/Common/Buttons'; | ||||
| import { getContactAddressError, getContactNameError } from 'validation'; | import { getContactAddressError, getContactNameError } from 'validation'; | ||||
| import { | import { | ||||
| ContactsContainer, | |||||
| ContactList, | ContactList, | ||||
| ContactsPanel, | ContactsPanel, | ||||
| Row, | Row, | ||||
| ButtonRow, | ButtonRow, | ||||
| ContactListName, | ContactListName, | ||||
| ButtonPanel, | ButtonPanel, | ||||
| } from 'components/Contacts/styles'; | } from 'components/Contacts/styles'; | ||||
| import { PageHeader } from 'components/Common/Atoms'; | |||||
| import { CashtabContact } from 'config/CashtabState'; | import { CashtabContact } from 'config/CashtabState'; | ||||
| const Contacts = () => { | const Contacts = () => { | ||||
| const ContextValue = useContext(WalletContext); | const ContextValue = useContext(WalletContext); | ||||
| if (!isWalletContextLoaded(ContextValue)) { | if (!isWalletContextLoaded(ContextValue)) { | ||||
| // Confirm we have all context required to load the page | // Confirm we have all context required to load the page | ||||
| return null; | return null; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | const exportContactList = (contactListArray: CashtabContact[]) => { | ||||
| 'download', | 'download', | ||||
| 'Cashtab_Contacts_' + wallet.name + '.csv', | 'Cashtab_Contacts_' + wallet.name + '.csv', | ||||
| ); | ); | ||||
| document.body.appendChild(csvLink); | document.body.appendChild(csvLink); | ||||
| csvLink.click(); | csvLink.click(); | ||||
| }; | }; | ||||
| return ( | return ( | ||||
| <> | <ContactsContainer> | ||||
| <PageHeader> | <ActionButtonRow variant="tools" activeIndex={0} /> | ||||
| Contacts <ContactsIcon /> | |||||
| </PageHeader> | |||||
| {contactToBeRenamed !== null && ( | {contactToBeRenamed !== null && ( | ||||
| <Modal | <Modal | ||||
| height={180} | height={180} | ||||
| title={`Rename "${contactToBeRenamed.name}"?`} | title={`Rename "${contactToBeRenamed.name}"?`} | ||||
| handleOk={renameContact} | handleOk={renameContact} | ||||
| handleCancel={() => setContactToBeRenamed(null)} | handleCancel={() => setContactToBeRenamed(null)} | ||||
| showCancelButton | showCancelButton | ||||
| disabled={ | disabled={ | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | return ( | ||||
| <SecondaryButton | <SecondaryButton | ||||
| onClick={() => exportContactList(contactList)} | onClick={() => exportContactList(contactList)} | ||||
| > | > | ||||
| Export | Export | ||||
| </SecondaryButton> | </SecondaryButton> | ||||
| </ButtonRow> | </ButtonRow> | ||||
| )} | )} | ||||
| </ContactList> | </ContactList> | ||||
| </> | </ContactsContainer> | ||||
| ); | ); | ||||
| }; | }; | ||||
| export default Contacts; | export default Contacts; | ||||