Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions client/src/components/DocGrid/DocGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ const DocGrid = () => {
setLoading(false);
};

const deleteNote = async (noteId) => {
try {
const token = localStorage.getItem("token");
const config = {
headers: {
Authorization: `Bearer ${token}`,
},
withCredentials: true,
};
await axios.delete(
`${import.meta.env.VITE_BASE_URL}/note/${noteId}`,
config
);

setNotes(notes.filter((note) => note._id !== noteId));
setOpen(false);
} catch (error) {
console.error("Error deleting note:", error);
}
};

useEffect(() => {
fetchNotes();
}, [open]);
Expand Down Expand Up @@ -281,6 +302,15 @@ const DocGrid = () => {
{note.subject?.subjectName}
</p>
</div>
<button
className="bg-blue-700 p-2 rounded-md text-white font-bold"
onClick={(e) => {
e.stopPropagation();
deleteNote(note._id);
}}
>
Delete
</button>
</div>
</div>
))}
Expand Down
18 changes: 18 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading