diff --git a/client/src/components/SnippetDisplay/SnippetDisplay.jsx b/client/src/components/SnippetDisplay/SnippetDisplay.jsx index 85d5f40..c15fc78 100644 --- a/client/src/components/SnippetDisplay/SnippetDisplay.jsx +++ b/client/src/components/SnippetDisplay/SnippetDisplay.jsx @@ -12,6 +12,7 @@ import { langs } from '@uiw/codemirror-extensions-langs'; // importing utils import { Card, Button } from 'react-bootstrap'; +import { set } from 'mongoose'; const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { const defaultDisplayValues = { @@ -19,7 +20,7 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { language: '', comments: '', storedCode: '', - tags: [] + tags: [], }; const [copied, setCopied] = useState(false); @@ -30,9 +31,16 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { setCurrentDisplay(selectedSnippet); }, [selectedSnippet, getSnippet]); + const handleCopy = () => { + setCopied(true); + setTimeout(() => { + setCopied(false); + }, 2000); + }; + const deleteSnippet = (snippetId) => { fetch('/snippets?' + new URLSearchParams({ snippetId }), { - method: 'DELETE' + method: 'DELETE', }) .then((response) => { if (response.ok) { @@ -44,7 +52,7 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { return { log: `SnippetDisiplay.deleteSnippet: Error: ${err}`, status: err.status, - message: 'There was an error deleting snippet.' + message: 'There was an error deleting snippet.', }; }); }; @@ -53,7 +61,7 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { fetch(`/snippets?${new URLSearchParams({ snippetId })}`, { method: 'PUT', headers: { 'Content-type': 'application/json' }, - body: JSON.stringify(currentDisplay) + body: JSON.stringify(currentDisplay), }) .then((response) => { //Are we using this response anywhere? IF not, delete this. @@ -68,66 +76,63 @@ const SnippetDisplay = ({ selectedSnippet, getSnippet }) => { return { log: `SnippetDisplay.editSnippet: Error: ${err}`, status: err.status, - message: 'There was an error editing code snippet.' + message: 'There was an error editing code snippet.', }; }); }; const displayContent = (