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