added new fields to permit model, removed changes endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import { string, z } from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { buildJsonSchemas } from "fastify-zod";
|
||||
import { pageMetadata, pageQueryParams } from "../pagination";
|
||||
@@ -65,6 +65,10 @@ const permitSchema = new mongoose.Schema({
|
||||
lastUpdateDate: Date,
|
||||
statusUpdated: Date,
|
||||
issuedDate: Date,
|
||||
communityName: String,
|
||||
lot: String,
|
||||
jobNumber: String,
|
||||
startDate: Date,
|
||||
}).index({ tenantId: 1, permitNumber: 1 }, { unique: true });
|
||||
|
||||
export const permitFields = Object.keys(permitSchema.paths).filter(
|
||||
@@ -151,26 +155,15 @@ const updatePermitInput = z.object({
|
||||
.optional(),
|
||||
assignedTo: z.string().optional(),
|
||||
newPayment: z.array(z.any()).optional(),
|
||||
communityName: z.string().optional(),
|
||||
lot: z.string().optional(),
|
||||
jobNumber: z.string().optional(),
|
||||
startDate: z.date().optional(),
|
||||
});
|
||||
|
||||
export type CreatePermitInput = z.infer<typeof createPermitInput>;
|
||||
export type UpdatePermitInput = z.infer<typeof updatePermitInput>;
|
||||
|
||||
export const changesModel = mongoose.model(
|
||||
"change",
|
||||
new mongoose.Schema({
|
||||
tenantId: String,
|
||||
permitId: String,
|
||||
field: String,
|
||||
value: String,
|
||||
updatedBy: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "user",
|
||||
},
|
||||
updatedAt: Date,
|
||||
})
|
||||
);
|
||||
|
||||
export const { schemas: permitSchemas, $ref: $permit } = buildJsonSchemas(
|
||||
{
|
||||
createPermitInput,
|
||||
|
||||
Reference in New Issue
Block a user