Skip to content

Instantly share code, notes, and snippets.

View trillionclues's full-sized avatar
🏌️‍♂️
I code for fun

Excel Nwachukwu trillionclues

🏌️‍♂️
I code for fun
View GitHub Profile
@trillionclues
trillionclues / updateNote.js
Created April 20, 2023 12:11
Gist to send and update specific node status by matching the Id in a database
View updateNote.js
// PUT ? UPDATE SPECIFIC NOTES
exports.dashboardUpdateNote = async (req, res) => {
try {
await Note.findOneAndUpdate(
{ _id: req.params.id },
{ title: req.body.title, body: req.body.body, updatedAt: Date.now() }
).where({ user: req.user.id })
res.redirect('/dashboard')
} catch (error) {
console.log(error)
@trillionclues
trillionclues / handleCheckboxChange.js
Created April 20, 2023 12:06
Handle checkbox change to validate if a todos has been checked as completed and moved to completed tab.
View handleCheckboxChange.js
const handleCheckboxChange = (id) => {
const todoIndex = items.findIndex((item) => item.id === id)
const updatedItems = [...items]
updatedItems[todoIndex].completed = !updatedItems[todoIndex].completed
if (updatedItems[todoIndex].completed) {
setCompletedTodo([...completedTodo, updatedItems[todoIndex].id])
} else {
setCompletedTodo(completedTodo.filter((item) => item.id !== id))
}