diff --git a/client/src/components/AddSnippet/AddSnippet.jsx b/client/src/components/AddSnippet/AddSnippet.jsx index c92bfa8..c1aa27b 100644 --- a/client/src/components/AddSnippet/AddSnippet.jsx +++ b/client/src/components/AddSnippet/AddSnippet.jsx @@ -28,10 +28,6 @@ const AddSnippet = ({ closeModal, getUserData }) => { const [error, setError] = useState(false); const [openModal, setOpenModal] = useState(false); - //TODO: Pull user info from global state - //FIXME: HARCODING USER INFO FOR NOW - const userId = '6463eb52ab99bf89a84a3ebd'; - function handleSubmit(e) { e.preventDefault(); if (title === '') { @@ -42,7 +38,7 @@ const AddSnippet = ({ closeModal, getUserData }) => { setError(false); } - fetch('/snippets?' + new URLSearchParams({ userId }), { + fetch('/snippets', { method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/client/src/components/SnippetDisplay/SnippetDisplay.jsx b/client/src/components/SnippetDisplay/SnippetDisplay.jsx index be5818a..85d5f40 100644 --- a/client/src/components/SnippetDisplay/SnippetDisplay.jsx +++ b/client/src/components/SnippetDisplay/SnippetDisplay.jsx @@ -25,18 +25,13 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { const [copied, setCopied] = useState(false); const [editButtonState, setEditButtonState] = useState(false); const [currentDisplay, setCurrentDisplay] = useState(defaultDisplayValues); - //TODO: Pull userId from global state - //FIXME: HARDCODING USER ID FOR NOW - const userId = '6463eb52ab99bf89a84a3ebd'; - // indSnippet = this.props - // create delete method using fetch request useEffect(() => { setCurrentDisplay(selectedSnippet); }, [selectedSnippet, getSnippet]); - const deleteSnippet = (snippetId, userId) => { - fetch('/snippets?' + new URLSearchParams({ snippetId, userId }), { + const deleteSnippet = (snippetId) => { + fetch('/snippets?' + new URLSearchParams({ snippetId }), { method: 'DELETE' }) .then((response) => { @@ -55,7 +50,7 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { }; const editSnippet = (snippetId) => { - fetch(`/snippets?${new URLSearchParams({ snippetId, userId })}`, { + fetch(`/snippets?${new URLSearchParams({ snippetId })}`, { method: 'PUT', headers: { 'Content-type': 'application/json' }, body: JSON.stringify(currentDisplay) @@ -174,7 +169,7 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => {