diff --git a/src/views/ManageList.jsx b/src/views/ManageList.jsx index 6222b23..f4490a3 100644 --- a/src/views/ManageList.jsx +++ b/src/views/ManageList.jsx @@ -1,15 +1,16 @@ import { useState, useMemo } from 'react'; -import { addItem, shareList } from '../api/firebase'; +import { addItem } from '../api/firebase'; import { FaPlusSquare } from 'react-icons/fa'; import { IconButton } from '../components/IconButton'; -import { FaEnvelope } from 'react-icons/fa6'; +import { Share } from './Share'; export function ManageList({ listPath, user, data }) { const currentUserId = user?.uid; const [itemName, setItemName] = useState(''); const [daysUntilNextPurchase, setDaysUntilNextPurchase] = useState(7); const [message, setMessage] = useState(''); - const [recipientEmail, setRecipientEmail] = useState(''); + + const [isModalDialogOpen, setIsModalDialogOpen] = useState(false); const messages = { added: 'Your item was successfully added!', @@ -59,18 +60,6 @@ export function ManageList({ listPath, user, data }) { } }; - const handleShare = (event) => { - event.preventDefault(); - shareList(listPath, currentUserId, recipientEmail) - .then((result) => { - alert(result); - setRecipientEmail(''); - }) - .catch((error) => { - alert(error); - }); - }; - return (

Manage Your Shopping List for {extractedListName}

@@ -129,27 +118,7 @@ export function ManageList({ listPath, user, data }) { {messages[message] || ''}

)} - -
-
- - setRecipientEmail(e.target.value)} - required - /> - - -
+
); } diff --git a/src/views/Share.jsx b/src/views/Share.jsx new file mode 100644 index 0000000..806cc7a --- /dev/null +++ b/src/views/Share.jsx @@ -0,0 +1,43 @@ +import { useState } from 'react'; +import { shareList } from '../api/firebase'; +import { IconButton } from '../components/IconButton'; +import { FaEnvelope } from 'react-icons/fa6'; + +export function Share() { + const [recipientEmail, setRecipientEmail] = useState(''); + + const handleShare = (event) => { + event.preventDefault(); + shareList(listPath, currentUserId, recipientEmail) + .then((result) => { + alert(result); + setRecipientEmail(''); + }) + .catch((error) => { + alert(error); + }); + }; + + return ( +
+
+ + setRecipientEmail(e.target.value)} + required + /> + + +
+ ); +}