bug fixes, schema updates
This commit is contained in:
@@ -125,17 +125,15 @@ const updatePermitInput = z.object({
|
||||
permitDate: z.date().optional(),
|
||||
stage: z
|
||||
.object({
|
||||
pipeline: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
currentStage: z.number().optional(),
|
||||
pipeline: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
),
|
||||
currentStage: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
status: z.string().optional(),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
UpdatePermitInput,
|
||||
} from "./permit.schema";
|
||||
import { ChangeEvent, dbEvents } from "../realtime";
|
||||
import { pipeline } from "../utils/pipeline";
|
||||
import { permitPipeline } from "../utils/pipeline";
|
||||
import { AuthenticatedUser } from "../auth";
|
||||
|
||||
export async function createPermit(
|
||||
@@ -18,7 +18,7 @@ export async function createPermit(
|
||||
) {
|
||||
if (!input.stage) {
|
||||
input.stage = {
|
||||
pipeline: pipeline,
|
||||
pipeline: permitPipeline,
|
||||
currentStage: 0,
|
||||
};
|
||||
}
|
||||
@@ -297,6 +297,8 @@ export async function searchPermit(params: PageQueryParams, tenantId: string) {
|
||||
permitDate: 1,
|
||||
stage: 1,
|
||||
status: 1,
|
||||
address: 1,
|
||||
description: 1,
|
||||
county: {
|
||||
$let: {
|
||||
vars: { county: { $arrayElemAt: ["$countyRec", 0] } },
|
||||
|
||||
@@ -33,16 +33,10 @@ const rtsSchema = new mongoose.Schema({
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
statusPipeline: new mongoose.Schema(
|
||||
stage: new mongoose.Schema(
|
||||
{
|
||||
pipeline: Array,
|
||||
currentStage: Number,
|
||||
stages: [
|
||||
{
|
||||
name: String,
|
||||
date: Date,
|
||||
description: String,
|
||||
},
|
||||
],
|
||||
},
|
||||
{ _id: false }
|
||||
),
|
||||
@@ -63,11 +57,37 @@ const rtsCreateInput = z.object({
|
||||
county: z.string(),
|
||||
client: z.string().optional(),
|
||||
files: z.array(files).optional(),
|
||||
stage: z
|
||||
.object({
|
||||
pipeline: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
),
|
||||
currentStage: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const rtsUpdateInput = z.object({
|
||||
county: z.string().optional(),
|
||||
client: z.string().optional(),
|
||||
stage: z
|
||||
.object({
|
||||
pipeline: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
),
|
||||
currentStage: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const rtsNewUpload = z.object({
|
||||
|
||||
@@ -9,7 +9,26 @@ const taskSchema = new mongoose.Schema({
|
||||
pid: { type: String, required: true, unique: true },
|
||||
title: String,
|
||||
dueDate: Date,
|
||||
files: Object,
|
||||
documents: [
|
||||
new mongoose.Schema(
|
||||
{
|
||||
files: Array,
|
||||
createdAt: Date,
|
||||
createdBy: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "user",
|
||||
},
|
||||
},
|
||||
{ _id: false }
|
||||
),
|
||||
],
|
||||
stage: new mongoose.Schema(
|
||||
{
|
||||
pipeline: Array,
|
||||
currentStage: Number,
|
||||
},
|
||||
{ _id: false }
|
||||
),
|
||||
createdAt: Date,
|
||||
createdBy: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
@@ -32,6 +51,19 @@ const createTaskInput = z.object({
|
||||
dueDate: z.date().optional(),
|
||||
files: z.array(files).optional(),
|
||||
assignedTo: z.string().optional(),
|
||||
stage: z
|
||||
.object({
|
||||
pipeline: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
),
|
||||
currentStage: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const updateTaskInput = z.object({
|
||||
@@ -39,6 +71,19 @@ const updateTaskInput = z.object({
|
||||
dueDate: z.date().optional(),
|
||||
files: z.array(files).optional(),
|
||||
assignedTo: z.string().optional(),
|
||||
stage: z
|
||||
.object({
|
||||
pipeline: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
date: z.date().nullable().optional(),
|
||||
description: z.string().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
),
|
||||
currentStage: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export type CreateTaskInput = z.infer<typeof createTaskInput>;
|
||||
|
||||
@@ -87,6 +87,8 @@ export async function listTasks(params: PageQueryParams, tenantId: string) {
|
||||
$project: {
|
||||
_id: 1,
|
||||
pid: 1,
|
||||
title: 1,
|
||||
dueDate: 1,
|
||||
createdAt: 1,
|
||||
createdBy: {
|
||||
$let: {
|
||||
@@ -98,7 +100,7 @@ export async function listTasks(params: PageQueryParams, tenantId: string) {
|
||||
},
|
||||
},
|
||||
},
|
||||
client: {
|
||||
assignedTo: {
|
||||
$let: {
|
||||
vars: { assignedTo: { $arrayElemAt: ["$assignedTo", 0] } },
|
||||
in: {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
export const pipeline: {
|
||||
type Pipeline = {
|
||||
name: string;
|
||||
date?: Date;
|
||||
description?: string;
|
||||
comment?: string;
|
||||
}[] = [
|
||||
}[];
|
||||
|
||||
export const permitPipeline: Pipeline = [
|
||||
{
|
||||
name: "Ready to submit",
|
||||
date: null,
|
||||
@@ -101,3 +103,75 @@ export const pipeline: {
|
||||
comment: "",
|
||||
},
|
||||
];
|
||||
|
||||
export const rtsPipeline: Pipeline = [
|
||||
{
|
||||
name: "Received",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Review",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "On Hold",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Submitted",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
];
|
||||
|
||||
export const taskPipeline: Pipeline = [
|
||||
{
|
||||
name: "To Do",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "In Progress",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Awaiting Feedback",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Updates",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Completed",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Parked",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
{
|
||||
name: "Canceled",
|
||||
date: null,
|
||||
description: "",
|
||||
comment: "",
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user