Started working on the assignments page

This commit is contained in:
Tiago Ribeiro
2024-10-02 19:20:05 +01:00
parent 564e6438cb
commit 3d4a604aa2
25 changed files with 2225 additions and 688 deletions

View File

@@ -128,8 +128,10 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
return;
}
const id = uuidv4();
await db.collection("assignments").insertOne({
id: uuidv4(),
id,
assigner: req.session.user?.id,
assignees,
results: [],
@@ -138,11 +140,10 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
...body,
});
res.status(200).json({ok: true});
res.status(200).json({ok: true, id});
for (const assigneeID of assignees) {
const assignee = await db.collection("users").findOne<User>({ id: assigneeID });
const assignee = await db.collection("users").findOne<User>({id: assigneeID});
if (!assignee) continue;
const name = body.name;