diff --git a/packages/suite/src/views/contacts/AddNewContactModal.tsx b/packages/suite/src/views/contacts/AddNewContactModal.tsx new file mode 100644 index 00000000000..a3f594de0bf --- /dev/null +++ b/packages/suite/src/views/contacts/AddNewContactModal.tsx @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; + +import { Column, Input, NewModal, Textarea } from '@trezor/components'; +import { selectDevice } from '@suite-common/wallet-core'; +import { spacings } from '@trezor/theme'; + +import { useSelector } from '../../hooks/suite'; +import { getDeviceState } from '../../reducers/suite/contactsReducer'; +import { useAddContact } from './useAddContact'; + +type AddNewContactModalProps = { + onClose: () => void; +}; + +export const AddNewContactModal = ({ onClose }: AddNewContactModalProps) => { + const device = useSelector(selectDevice); + const deviceState = device && getDeviceState(device); + + const [errorMessage, setErrorMessage] = useState(null); + const [label, setLabel] = useState(''); + const [address, setAddress] = useState(''); + + const addContact = useAddContact(onClose, label, address); + const onAddContact = async () => { + const { error } = await addContact(); + setErrorMessage(error); + }; + + if (!deviceState || errorMessage) + return ( + + Close + + } + > + No device selected or device unacquired + + ); + + return ( + + Save + + Cancel + + + } + > + + setLabel(event.target.value)} + /> +