diff --git a/src/rts/rts.schema.ts b/src/rts/rts.schema.ts index 04c6bcc..9162946 100644 --- a/src/rts/rts.schema.ts +++ b/src/rts/rts.schema.ts @@ -42,6 +42,8 @@ const rtsSchema = new mongoose.Schema({ { _id: false } ), status: String, + labels: [String], + priority: String, createdAt: Date, createdBy: { type: mongoose.Types.ObjectId, @@ -64,6 +66,8 @@ const rtsCreateInput = z.object({ client: z.string().optional(), files: z.array(files).optional(), permitType: z.string().optional(), + labels: z.array(z.string()).optional(), + priority: z.string().optional(), stage: z .object({ pipeline: z.array( @@ -85,6 +89,8 @@ const rtsUpdateInput = z.object({ county: z.string().optional(), client: z.string().optional(), permitType: z.string().optional(), + labels: z.array(z.string()).optional(), + priority: z.string().optional(), stage: z .object({ pipeline: z.array( diff --git a/src/rts/rts.service.ts b/src/rts/rts.service.ts index f49c508..2bdedc0 100644 --- a/src/rts/rts.service.ts +++ b/src/rts/rts.service.ts @@ -10,6 +10,7 @@ import { generateId } from "../utils/id"; import { getFilterObject, getSortObject, PageQueryParams } from "../pagination"; import { getUserWithoutPopulate } from "../user/user.service"; import mongoose from "mongoose"; +import { rtsPipeline } from "../utils/pipeline"; export async function createRts( input: CreateRtsInput, @@ -21,6 +22,13 @@ export async function createRts( defaultClient = userInDb.orgId.toString(); } + if (!input.stage) { + input.stage = { + pipeline: rtsPipeline, + currentStage: 0, + }; + } + const newRts = await rtsModel.create({ ...input, tenantId: user.tenantId, @@ -104,7 +112,10 @@ export async function listRts( documents: 1, statusPipeline: 1, createdAt: 1, + stage: 1, status: 1, + labels: 1, + priority: 1, county: { $let: { vars: { county: { $arrayElemAt: ["$countyRec", 0] } }, diff --git a/src/utils/pipeline.ts b/src/utils/pipeline.ts index 8bf663b..f00d4ac 100644 --- a/src/utils/pipeline.ts +++ b/src/utils/pipeline.ts @@ -112,7 +112,7 @@ export const rtsPipeline: Pipeline = [ comment: "", }, { - name: "Review", + name: "In Review", date: null, description: "", comment: "",