add config routes
This commit is contained in:
77
src/config/config.service.ts
Normal file
77
src/config/config.service.ts
Normal 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" });
|
||||
}
|
||||
Reference in New Issue
Block a user