From a149db57aba68524cb49a74abb1e066a2ef2bca7 Mon Sep 17 00:00:00 2001 From: Michal Zielenkiewicz Date: Wed, 6 Sep 2023 13:06:38 +0200 Subject: [PATCH] Enable adding new contacts --- .../Toolbar/Features/Contacts/AddContact.tsx | 49 +++++++++++++++++++ .../Toolbar/Features/Contacts/index.tsx | 13 +++++ src/locales/en/translation.json | 2 + 3 files changed, 64 insertions(+) create mode 100644 src/app/components/Toolbar/Features/Contacts/AddContact.tsx diff --git a/src/app/components/Toolbar/Features/Contacts/AddContact.tsx b/src/app/components/Toolbar/Features/Contacts/AddContact.tsx new file mode 100644 index 0000000000..1f6658eee0 --- /dev/null +++ b/src/app/components/Toolbar/Features/Contacts/AddContact.tsx @@ -0,0 +1,49 @@ +import { useContext } from 'react' +import { useDispatch } from 'react-redux' +import { useTranslation } from 'react-i18next' +import { Box } from 'grommet/es6/components/Box' +import { Tabs } from 'grommet/es6/components/Tabs' +import { Tab } from 'grommet/es6/components/Tab' +import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext' +import { contactsActions } from 'app/state/contacts' +import { Contact } from 'app/state/contacts/types' +import { ResponsiveLayer } from '../../../ResponsiveLayer' +import { ContactAccountForm } from './ContactAccountForm' + +interface AddContactProps { + setLayerVisibility: (isVisible: boolean) => void +} + +export const AddContact = ({ setLayerVisibility }: AddContactProps) => { + const { t } = useTranslation() + const isMobile = useContext(ResponsiveContext) === 'small' + const dispatch = useDispatch() + const submitHandler = (contact: Contact) => dispatch(contactsActions.add(contact)) + + return ( + setLayerVisibility(false)} + onEsc={() => setLayerVisibility(false)} + animation="none" + background="background-front" + modal + position="top" + margin={isMobile ? 'none' : 'xlarge'} + > + + + + + + + + + + + ) +} diff --git a/src/app/components/Toolbar/Features/Contacts/index.tsx b/src/app/components/Toolbar/Features/Contacts/index.tsx index 4d8e4ec358..cb63a791c8 100644 --- a/src/app/components/Toolbar/Features/Contacts/index.tsx +++ b/src/app/components/Toolbar/Features/Contacts/index.tsx @@ -1,8 +1,11 @@ +import { useState } from 'react' import { useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' import { Box } from 'grommet/es6/components/Box' +import { Button } from 'grommet/es6/components/Button' import { Inbox } from 'grommet-icons/es6/icons/Inbox' import { selectContactsList } from 'app/state/contacts/selectors' +import { AddContact } from './AddContact' const ContactsListEmptyState = () => { const { t } = useTranslation() @@ -16,6 +19,8 @@ const ContactsListEmptyState = () => { } export const Contacts = () => { + const { t } = useTranslation() + const [layerVisibility, setLayerVisibility] = useState(false) const contacts = useSelector(selectContactsList) return ( @@ -30,6 +35,14 @@ export const Contacts = () => { )} + +