feat: update permit schema
This commit is contained in:
@@ -57,7 +57,7 @@ export async function updatePermitHandler(
|
|||||||
req: FastifyRequest,
|
req: FastifyRequest,
|
||||||
res: FastifyReply
|
res: FastifyReply
|
||||||
) {
|
) {
|
||||||
const input = req.body as UpdatePermitInput;
|
const input = req.body as CreatePermitInput;
|
||||||
const { permitId } = req.params as { permitId: string };
|
const { permitId } = req.params as { permitId: string };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export async function permitRoutes(fastify: FastifyInstance) {
|
|||||||
type: "object",
|
type: "object",
|
||||||
properties: { permitId: { type: "string" } },
|
properties: { permitId: { type: "string" } },
|
||||||
},
|
},
|
||||||
body: $permit("updatePermitInput"),
|
body: $permit("createPermitInput"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updatePermitHandler
|
updatePermitHandler
|
||||||
|
|||||||
@@ -59,9 +59,35 @@ const permitSchema = new mongoose.Schema({
|
|||||||
type: mongoose.Types.ObjectId,
|
type: mongoose.Types.ObjectId,
|
||||||
ref: "user",
|
ref: "user",
|
||||||
},
|
},
|
||||||
newProcessingStatus: Array,
|
newProcessingStatus: [
|
||||||
newPayment: Array,
|
{
|
||||||
newConditions: Array,
|
last_modified_date: Date,
|
||||||
|
description: String,
|
||||||
|
status: String,
|
||||||
|
assigned_user_text: String,
|
||||||
|
due_date: Date,
|
||||||
|
is_completed: String,
|
||||||
|
comment: String,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
newPayment: [
|
||||||
|
{
|
||||||
|
apply_date: String,
|
||||||
|
invoice_id: Number,
|
||||||
|
amount: Number,
|
||||||
|
balance_due: Number,
|
||||||
|
code_text: String,
|
||||||
|
status: String,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
newConditions: [
|
||||||
|
{
|
||||||
|
status_date: Date,
|
||||||
|
status_value: String,
|
||||||
|
short_comments: String,
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
|
],
|
||||||
professionals: Object,
|
professionals: Object,
|
||||||
recordId: String,
|
recordId: String,
|
||||||
relatedRecords: Object,
|
relatedRecords: Object,
|
||||||
@@ -85,10 +111,25 @@ export const permitFields = Object.keys(permitSchema.paths).filter(
|
|||||||
export const permitModel = mongoose.model("permit", permitSchema);
|
export const permitModel = mongoose.model("permit", permitSchema);
|
||||||
|
|
||||||
const permitCore = {
|
const permitCore = {
|
||||||
permitNumber: z.string(),
|
permitNumber: z.string().optional(),
|
||||||
county: z.string().optional(),
|
|
||||||
client: z.string().optional(),
|
client: z.string().optional(),
|
||||||
permitDate: z.date(),
|
county: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
pid: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
avatar: z.string(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
clientData: z
|
||||||
|
.object({
|
||||||
|
pid: z.string(),
|
||||||
|
licenseNumber: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
avatar: z.string(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
permitDate: z.date().optional(),
|
||||||
stage: z
|
stage: z
|
||||||
.object({
|
.object({
|
||||||
pipeline: z.array(
|
pipeline: z.array(
|
||||||
@@ -103,7 +144,70 @@ const permitCore = {
|
|||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
status: z.string().optional(),
|
status: z.string().optional(),
|
||||||
assignedTo: z.string().optional(),
|
manualStatus: z.string().nullable().optional(),
|
||||||
|
cleanStatus: z.string().optional(),
|
||||||
|
permitType: z.string().optional(),
|
||||||
|
utility: z.string().nullable().optional(),
|
||||||
|
assignedTo: z.string().nullable().optional(),
|
||||||
|
link: z.string().optional(),
|
||||||
|
address: z
|
||||||
|
.object({
|
||||||
|
full_address: z.string(),
|
||||||
|
community_address: z.string(),
|
||||||
|
postal_code: z.string(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
recordType: z.string().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
newProcessingStatus: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
last_modified_date: z.date().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
status: z.string().optional(),
|
||||||
|
assigned_user_text: z.string().optional(),
|
||||||
|
due_date: z.date().optional(),
|
||||||
|
is_completed: z.string().optional(),
|
||||||
|
comment: z.string().optional(),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
newPayment: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
apply_date: z.string().optional(),
|
||||||
|
invoice_id: z.number().optional(),
|
||||||
|
amount: z.number().optional(),
|
||||||
|
balance_due: z.number().optional(),
|
||||||
|
code_text: z.string().optional(),
|
||||||
|
status: z.string().optional(),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
newConditions: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
status_date: z.date().optional(),
|
||||||
|
status_value: z.string().optional(),
|
||||||
|
short_comments: z.string().optional(),
|
||||||
|
name: z.string().optional(),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
professionals: z.record(z.any()).optional(),
|
||||||
|
recordId: z.string().optional(),
|
||||||
|
relatedRecords: z.string().optional(),
|
||||||
|
accelaStatus: z.string().optional(),
|
||||||
|
openDate: z.date().optional(),
|
||||||
|
lastUpdatedDate: z.date().optional(),
|
||||||
|
statusUpdated: z.date().optional(),
|
||||||
|
issuedDate: z.date().optional(),
|
||||||
|
communityName: z.string().nullable().optional(),
|
||||||
|
lot: z.string().nullable().optional(),
|
||||||
|
block: z.string().nullable().optional(),
|
||||||
|
jobNumber: z.string().nullable().optional(),
|
||||||
|
startDate: z.date().nullable().optional(),
|
||||||
|
history: z.record(z.any()).optional(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const createPermitInput = z.object({
|
const createPermitInput = z.object({
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export async function listPermits(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updatePermit(
|
export async function updatePermit(
|
||||||
input: UpdatePermitInput,
|
input: CreatePermitInput,
|
||||||
permitId: string,
|
permitId: string,
|
||||||
user: AuthenticatedUser
|
user: AuthenticatedUser
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user