From d05f7812579ac22722296b0f53d212a0bd42084e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:17:34 +0000 Subject: [PATCH] Removes the console expressions --- backend/db.js | 4 ++-- backend/index.js | 2 +- src/Components/ContactUs.js | 2 +- src/Components/Login.js | 6 +++--- src/Components/MyAccount.js | 2 +- src/Components/Navbar.js | 2 +- src/Components/Notes.js | 2 +- src/Components/Signup.js | 2 +- src/context/notes/NoteState.js | 14 +++++++------- src/context/toasts/ToastState.js | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/db.js b/backend/db.js index e47ff95..65f182b 100644 --- a/backend/db.js +++ b/backend/db.js @@ -5,9 +5,9 @@ const mongoURI = "mongodb+srv://AyanProgrammer11:Apple123@inotebookcluster.nzmaw const connectToMongo = async () => { // console.log("Function running") try { - console.log("Inside try"); + await mongoose.connect(mongoURI); - console.log("Connected to Mongo Successfully"); + } catch(err) { // console.log("Inside catch") console.log("Failed to Connect"); diff --git a/backend/index.js b/backend/index.js index 121a443..2dcddb1 100644 --- a/backend/index.js +++ b/backend/index.js @@ -19,5 +19,5 @@ app.use('/api/contact', require("./routes/contact")) app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) + }) \ No newline at end of file diff --git a/src/Components/ContactUs.js b/src/Components/ContactUs.js index b0abbf9..fe02a5c 100644 --- a/src/Components/ContactUs.js +++ b/src/Components/ContactUs.js @@ -44,7 +44,7 @@ const handleSubmit = async (e) => { }); const json = await response.json(); setEmail(json.email); - console.log(json); + } fetchUserEmail(); diff --git a/src/Components/Login.js b/src/Components/Login.js index 15a23ac..7628258 100644 --- a/src/Components/Login.js +++ b/src/Components/Login.js @@ -26,12 +26,12 @@ const Login = (props) => { body: JSON.stringify({email: credentials.email, password: credentials.password}) }); const json = await response.json(); - console.log(json); + if(json.success) { // Set the AuthToken to the Local Storage, So the user would not have to enter his/her credentials again and again when visiting the website localStorage.setItem("token", json.authtoken); - console.log(localStorage.getItem("token")); - console.log(json.success) + + // Navigate to the Root route of the application // showAlert("Logged in Successfully!", "success"); showToast.success("Loggged in Successfully") diff --git a/src/Components/MyAccount.js b/src/Components/MyAccount.js index 899aec6..dd5be54 100644 --- a/src/Components/MyAccount.js +++ b/src/Components/MyAccount.js @@ -36,7 +36,7 @@ const closeAfterDeletion = useRef(null); }) const json = await response.json(); localStorage.removeItem("token") - console.log(json); + closeAfterDeletion.current.click(); setIng("Delete Account") Navigate("/signup"); diff --git a/src/Components/Navbar.js b/src/Components/Navbar.js index 653ca24..c492fcc 100644 --- a/src/Components/Navbar.js +++ b/src/Components/Navbar.js @@ -73,7 +73,7 @@ const {showToast} = props; body: JSON.stringify({email: feedback.email, title: feedback.title, message: feedback.message}) }); const json = await response.json(); - console.log(json); + if(json.success) { // If feedback went successful then close the modal by using the "useRef" hook closeModal.current.click(); diff --git a/src/Components/Notes.js b/src/Components/Notes.js index 9673d50..4be653f 100644 --- a/src/Components/Notes.js +++ b/src/Components/Notes.js @@ -40,7 +40,7 @@ const Notes = (props) => { setNote({...note, [event.target.name]: event.target.value}) } const handleClick = (e) => { - console.log("Updating the note", note); + refClose.current.click(); showToast.promise(editNote(note.id, note.etitle, note.edescription, note.etag), { loading: "Updating Note....", diff --git a/src/Components/Signup.js b/src/Components/Signup.js index 4136999..5e9b9e1 100644 --- a/src/Components/Signup.js +++ b/src/Components/Signup.js @@ -37,7 +37,7 @@ const Signup = (props) => { }); // Parsing the Json const json = await response.json(); - console.log(json); + if(json.success) { localStorage.setItem("token", json.authToken); // console.log(json.success); diff --git a/src/context/notes/NoteState.js b/src/context/notes/NoteState.js index 39fa152..82a2c3b 100644 --- a/src/context/notes/NoteState.js +++ b/src/context/notes/NoteState.js @@ -21,7 +21,7 @@ const {showToast} = props; }, }); const json = await response.json(); - console.log(json); + setNotes(json); // setLoading(false); }; @@ -35,7 +35,7 @@ const {showToast} = props; }, }); const json = await response.json(); - console.log(json); + if(json.code === 401) { showToast.error("Permission Not Granted", {duration: 4000}); @@ -63,7 +63,7 @@ const {showToast} = props; body: JSON.stringify({ title, description, tag}), }); const json = await response.json(); - console.log(json); + setNotes(notes.concat(json)) // const note = { @@ -89,13 +89,13 @@ const {showToast} = props; } }); const json = await response.json(); - console.log(json); - console.log("Deleting a Note with id: " + id); + + const newNotes = notes.filter((note) => { return note._id !== id; }); setNotes(newNotes); - console.log("Note Deleted"); + }; // Function for editing a Note const editNote = async (id, title, description, tag) => { @@ -108,7 +108,7 @@ const {showToast} = props; body: JSON.stringify({ title, description, tag }), }); const json = await response.json(); - console.log(json); + let newNotes = JSON.parse(JSON.stringify(notes)); // Logic for Client-side Editing for (let index = 0; index < newNotes.length; index++) { diff --git a/src/context/toasts/ToastState.js b/src/context/toasts/ToastState.js index 1a90900..3a018de 100644 --- a/src/context/toasts/ToastState.js +++ b/src/context/toasts/ToastState.js @@ -5,7 +5,7 @@ const ToastState = (props) => { const displayToast = (message) => { let alert = toast.success(message); - console.log(alert); + return alert; }