add assignedTo field to unique fields endpoint

This commit is contained in:
2025-05-13 13:49:39 +05:30
parent d9397e572b
commit 4028c05d5f
6 changed files with 65 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import {
updateTaskHandler,
} from "./task.controller";
import { noteRoutes } from "../note/note.route";
import { getUniqueValuesTasks } from "./task.service";
export async function taskRoutes(fastify: FastifyInstance) {
fastify.post(
@@ -107,6 +108,35 @@ export async function taskRoutes(fastify: FastifyInstance) {
newFilesHandler
);
fastify.get(
"/fields/:field",
{
schema: {
params: {
type: "object",
properties: {
field: { type: "string" },
},
},
},
config: { requiredClaims: ["rts:read"] },
preHandler: [fastify.authorize],
},
async (req, res) => {
const { field } = req.params as { field: string };
try {
const uniqueValues = await getUniqueValuesTasks(
field,
req.user.tenantId
);
return res.code(200).send(uniqueValues);
} catch (err) {
return err;
}
}
);
await noteRoutes(fastify, {
read: "task:read",
write: "task:write",