|
|
|
@ -250,6 +250,55 @@ exports.createTeamMember = async (req, reply) => {
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.getAllDepartments = async (request, reply) => {
|
|
|
|
|
// try {
|
|
|
|
|
// const { departmentName } = request.params;
|
|
|
|
|
|
|
|
|
|
// if (!departmentName) {
|
|
|
|
|
// return reply.status(400).send({
|
|
|
|
|
// simplydata: {
|
|
|
|
|
// error: true,
|
|
|
|
|
// message: "departmentName is required in path params",
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Find all departments matching departmentName
|
|
|
|
|
// const departments = await Deparments.find({ departmentName }).lean();
|
|
|
|
|
|
|
|
|
|
// if (!departments.length) {
|
|
|
|
|
// return reply.status(404).send({
|
|
|
|
|
// simplydata: {
|
|
|
|
|
// error: true,
|
|
|
|
|
// message: "No departments found with the given departmentName",
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Add extra object { firstName: "Self" } at start
|
|
|
|
|
// const extraObject = { firstName: "Self" };
|
|
|
|
|
// const responseData = [extraObject, ...departments];
|
|
|
|
|
|
|
|
|
|
// return reply.send({
|
|
|
|
|
// simplydata: {
|
|
|
|
|
// error: false,
|
|
|
|
|
// message: "Departments retrieved successfully",
|
|
|
|
|
// data: responseData,
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
// console.error("Error fetching departments:", err);
|
|
|
|
|
// return reply.status(500).send({
|
|
|
|
|
// simplydata: {
|
|
|
|
|
// error: true,
|
|
|
|
|
// message: "Internal server error",
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
exports.getAllDepartments = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { departmentName } = request.params;
|
|
|
|
@ -266,24 +315,17 @@ exports.getAllDepartments = async (request, reply) => {
|
|
|
|
|
// Find all departments matching departmentName
|
|
|
|
|
const departments = await Deparments.find({ departmentName }).lean();
|
|
|
|
|
|
|
|
|
|
if (!departments.length) {
|
|
|
|
|
return reply.status(404).send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: true,
|
|
|
|
|
message: "No departments found with the given departmentName",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add extra object { firstName: "Self" } at start
|
|
|
|
|
const extraObject = { firstName: "Self" };
|
|
|
|
|
const responseData = [extraObject, ...departments];
|
|
|
|
|
// Always start with Self
|
|
|
|
|
const responseData = [{ firstName: "Self" }, ...(departments || [])];
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: false,
|
|
|
|
|
message: "Departments retrieved successfully",
|
|
|
|
|
message: departments.length
|
|
|
|
|
? "Departments retrieved successfully"
|
|
|
|
|
: "No departments found with the given departmentName",
|
|
|
|
|
data: responseData,
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -298,6 +340,7 @@ exports.getAllDepartments = async (request, reply) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.assignTeamMemberToQuotation = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { installationId } = request.params;
|
|
|
|
|