let user add note when creating task

This commit is contained in:
2025-06-09 16:48:53 +05:30
parent 6dea12bb45
commit 77af90c31d
4 changed files with 24 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ const createTaskInput = z.object({
currentStage: z.number(),
})
.optional(),
note: z.string().optional(),
});
const updateTaskInput = z.object({

View File

@@ -1,4 +1,5 @@
import { AuthenticatedUser } from "../auth";
import { createNote } from "../note/note.service";
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
import { generateId } from "../utils/id";
import { taskPipeline } from "../utils/pipeline";
@@ -30,6 +31,16 @@ export async function createTask(
createdBy: user.userId ?? null,
});
if (input.note) {
await createNote(
{
content: input.note,
},
task.pid,
user
);
}
return await taskModel
.findOne({ pid: task.pid })
.populate({ path: "createdBy", select: "pid name avatar" })

View File

@@ -68,6 +68,7 @@ const createTaskInput = z.object({
currentStage: z.number(),
})
.optional(),
note: z.string().optional(),
});
const updateTaskInput = z.object({

View File

@@ -1,4 +1,5 @@
import { AuthenticatedUser } from "../auth";
import { createNote } from "../note/note.service";
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
import { generateId } from "../utils/id";
import { taskPipeline } from "../utils/pipeline";
@@ -29,6 +30,16 @@ export async function createTask(
createdBy: user.userId ?? null,
});
if (input.note) {
await createNote(
{
content: input.note,
},
task.pid,
user
);
}
return await taskModel
.findOne({ pid: task.pid })
.populate({ path: "createdBy", select: "pid name avatar" })