generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added middleware to assign the task to the user
- Loading branch information
1 parent
adbffeb
commit 22e4c5b
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { fetchSkillLevelTasks } = require("../models/tasks"); | ||
const db = require("../utils/firestore"); | ||
|
||
const assignTask = async function (req, res, next) { | ||
if (req.body.percentCompleted === 100) { | ||
const { task } = await fetchSkillLevelTasks("frontend", 1); | ||
if (task) { | ||
const docId = task.id; | ||
const userId = req.userData.id; | ||
db.collection("tasks").doc(docId).set({ assignee: userId, status: "ASSIGNED" }, { merge: true }); | ||
return res.json({ message: "task updated and another task got assigned" }); | ||
} else { | ||
return res.json({ message: "Task updated but another task not found" }); | ||
} | ||
} else { | ||
return res.json({ message: "Task updated successfully!" }); | ||
} | ||
}; | ||
|
||
module.exports = assignTask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters