add config routes

This commit is contained in:
2025-02-18 15:10:51 +05:30
parent fc9abbbec4
commit 5d5cee2d7e
8 changed files with 203 additions and 2 deletions

View File

@@ -0,0 +1,77 @@
import { AuthenticatedUser } from "../auth";
import { configModel, UpdateConfigInput } from "./config.schema";
export async function getConfig(user: AuthenticatedUser) {
return await configModel
.findOne({ tenantId: user.tenantId })
.populate({ path: "updatedBy", select: "pid name avatar" });
}
export async function updateConfig(
input: UpdateConfigInput,
user: AuthenticatedUser
) {
return await configModel
.findOneAndUpdate(
{ tenantId: user.tenantId },
{
updatedAt: new Date(),
updatedBy: user.userId,
...input,
},
{ new: true }
)
.populate({ path: "updatedBy", select: "pid name avatar" });
}
export async function resetConfig(user: AuthenticatedUser) {
return await configModel
.findOneAndUpdate(
{ tenantId: user.tenantId },
{
statusMap: {
Submitted: ["Submitted", "New", "Plans Received"],
"In Review": [
"In Process",
"In Progress",
"In Review",
"Plan Review In Process",
],
"Awaiting Client Reply": [
"Rejected",
"Revision",
"Revision Required",
"Revisions Required",
"Review Verification",
"Awaiting Revisions",
"Pending Client Input",
"Pending Additional Review",
"Awaiting Client Reply",
"Ready to Issue",
"Pending Permit Issuance",
"Approved with Conditions",
],
Issued: ["Permit Issued", "Issued"],
Completed: [
"Approved",
"Administrative Close",
"Closed",
"Closed - Supp-Rev Approved",
"Closed - Void",
"Closed - Finaled",
"Closed - COC Issued",
"Closed - Withdrawn",
"Closed - CO Issued",
"Complete",
"CO Approved",
],
Expired: ["Expired"],
"Cancel/Void": ["Cancel", "Canceled", "Withdrawn"],
},
updatedAt: new Date(),
updatedBy: user.userId,
},
{ new: true }
)
.populate({ path: "updatedBy", select: "pid name avatar" });
}