my-typescript-library-rahul52us 2.3.9 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,14 +49,14 @@ function findOneAndDeleteDocument(req, res) {
49
49
  documentId: (_a = req.body) === null || _a === void 0 ? void 0 : _a.documentId,
50
50
  });
51
51
  res.status(200).send({
52
- status: 'success',
53
- data: 'Document has been successfully'
52
+ status: "success",
53
+ data: "Document has been successfully",
54
54
  });
55
55
  }
56
56
  catch (err) {
57
57
  res.status(500).send({
58
- status: 'error',
59
- data: err === null || err === void 0 ? void 0 : err.message
58
+ status: "error",
59
+ data: err === null || err === void 0 ? void 0 : err.message,
60
60
  });
61
61
  }
62
62
  });
@@ -66,7 +66,7 @@ function createPendingApprovalFunction(req) {
66
66
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  try {
69
- let { values, file, tags, type, approval, originalValues, isUpperApproval, domain, mailDetails, sendUserMail = true } = req.body;
69
+ let { values, file, tags, type, approval, originalValues, isUpperApproval, domain, mailDetails, sendUserMail = true, } = req.body;
70
70
  const userID = (_a = req.user) === null || _a === void 0 ? void 0 : _a._id;
71
71
  const organisationId = req.body.organisationId;
72
72
  const isguaranteed = ((_c = (_b = req === null || req === void 0 ? void 0 : req.body) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.Threshold_Value_Check) === "True" ? true : false;
@@ -121,7 +121,7 @@ function createPendingApprovalFunction(req) {
121
121
  name: approval.name || ((_e = req.user) === null || _e === void 0 ? void 0 : _e.username),
122
122
  level: approval.level,
123
123
  userId: userID,
124
- createdAt: new Date()
124
+ createdAt: new Date(),
125
125
  },
126
126
  ],
127
127
  helpInfo: req.body.helpInfo || {},
@@ -132,15 +132,19 @@ function createPendingApprovalFunction(req) {
132
132
  user: userID,
133
133
  company: company,
134
134
  workflow: req.body.activeWorkflow || req.user.defaultWorkflow,
135
- values: originalValues ? [{
135
+ values: originalValues
136
+ ? [
137
+ {
138
+ level: req.user.level,
139
+ values: values === null || values === void 0 ? void 0 : values.valuesData,
140
+ created_At: new Date(),
141
+ },
142
+ ]
143
+ : {
136
144
  level: req.user.level,
137
- values: values === null || values === void 0 ? void 0 : values.valuesData,
138
- created_At: new Date()
139
- }] : {
140
- level: req.user.level,
141
- values: values,
142
- created_At: new Date(),
143
- },
145
+ values: values,
146
+ created_At: new Date(),
147
+ },
144
148
  originalValues: originalValues || values.fields,
145
149
  tags: {
146
150
  extraction: {
@@ -161,39 +165,64 @@ function createPendingApprovalFunction(req) {
161
165
  if (file) {
162
166
  uploadedFile = yield (0, filesystem_repository_1.uploadFile)(file.file, file.name, file.type);
163
167
  }
168
+ const now = new Date();
164
169
  values = {
165
170
  user: userID,
166
171
  company: company,
167
172
  isguaranteed: isguaranteed,
168
173
  organisationId: organisationId,
169
174
  workflow: req.body.activeWorkflow || req.user.defaultWorkflow,
170
- values: isUpperApproval ? [{
175
+ values: isUpperApproval
176
+ ? [
177
+ {
178
+ level: req.user.level,
179
+ values,
180
+ created_At: new Date(),
181
+ updated_At: new Date(),
182
+ },
183
+ ]
184
+ : {
171
185
  level: req.user.level,
172
186
  values,
173
187
  created_At: new Date(),
174
188
  updated_At: new Date(),
175
- }] : {
176
- level: req.user.level,
177
- values,
178
- created_At: new Date(),
179
- updated_At: new Date(),
180
- },
189
+ },
181
190
  originalValues: originalValues || values,
182
191
  file: (uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.fileId) || undefined,
183
192
  tags: tags,
184
- approval: (approval === null || approval === void 0 ? void 0 : approval.length) > 0
185
- ? [
186
- {
187
- comment: approval[0].comment,
188
- type: approval[0].type,
189
- status: approval[0].status,
190
- name: approval[0].name || ((_f = req.user) === null || _f === void 0 ? void 0 : _f.username),
191
- level: approval[0].level,
192
- userId: userID,
193
- fileId: (uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.fileId) || undefined,
194
- createdAt: new Date(),
195
- },
196
- ]
193
+ // approval:
194
+ // approval?.length > 0
195
+ // ? [
196
+ // {
197
+ // comment: approval[0].comment,
198
+ // type: approval[0].type,
199
+ // status: approval[0].status,
200
+ // name: approval[0].name || req.user?.username,
201
+ // level: approval[0].level,
202
+ // userId: userID,
203
+ // fileId: uploadedFile?.fileId || undefined,
204
+ // createdAt: new Date(),
205
+ // },
206
+ // ]
207
+ // : [],
208
+ approval: Array.isArray(approval)
209
+ ? approval.length > 1
210
+ ?
211
+ approval.map((item, index) => (Object.assign(Object.assign({}, item), { fileId: uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.fileId, updatedAt: new Date(now.getTime() + index * 10 * 60 * 1000), createdAt: new Date(now.getTime() + index * 10 * 60 * 1000) })))
212
+ : approval.length === 1
213
+ ? [
214
+ {
215
+ comment: approval[0].comment,
216
+ type: approval[0].type,
217
+ status: approval[0].status,
218
+ name: approval[0].name || ((_f = req.user) === null || _f === void 0 ? void 0 : _f.username),
219
+ level: approval[0].level,
220
+ userId: userID,
221
+ fileId: uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.fileId,
222
+ createdAt: new Date()
223
+ },
224
+ ]
225
+ : []
197
226
  : [],
198
227
  helpInfo: req.body.helpInfo || {},
199
228
  };
@@ -273,7 +302,7 @@ function createPendingApprovalFunction(req) {
273
302
  message: message,
274
303
  documentId: createdDocument === null || createdDocument === void 0 ? void 0 : createdDocument._id,
275
304
  type: req.body.type,
276
- workflow: workflowId
305
+ workflow: workflowId,
277
306
  };
278
307
  const notificationsPromises = currentUser.map((userId, index) => __awaiter(this, void 0, void 0, function* () {
279
308
  var _6, _7, _8, _9;
@@ -295,7 +324,8 @@ function createPendingApprovalFunction(req) {
295
324
  });
296
325
  }
297
326
  if (notifyItem.type.includes("email")) {
298
- const dt = mailDetails ? Object.assign(Object.assign({}, mailDetails), { editedValues: formattedValues, approver: currentUserDetails[index].username }) : {
327
+ const dt = mailDetails
328
+ ? Object.assign(Object.assign({}, mailDetails), { editedValues: formattedValues, approver: currentUserDetails[index].username }) : {
299
329
  username: (_6 = req.user) === null || _6 === void 0 ? void 0 : _6.username,
300
330
  approver: currentUserDetails[index].username,
301
331
  status: req.body.status,
@@ -304,11 +334,17 @@ function createPendingApprovalFunction(req) {
304
334
  comments: `${req.user.username} has uploaded the document. Kindly review it once`,
305
335
  subcomment: `Comment : ${req.body.comment}`,
306
336
  editedValues: formattedValues,
307
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
337
+ logo: process.env.domain === "indoco"
338
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
339
+ : process.env.domain === "akums"
340
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
341
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
308
342
  };
309
343
  const template = yield (0, compile_email_template_1.default)({
310
- fileName: domain === "indoco" ? "indocoRequest.mjml" : "workflowApproval.mjml",
311
- data: dt
344
+ fileName: domain === "indoco"
345
+ ? "indocoRequest.mjml"
346
+ : "workflowApproval.mjml",
347
+ data: dt,
312
348
  });
313
349
  // Send email
314
350
  yield (0, mail_1.default)(currentUserDetails[index].username, mailDetails ? mailDetails === null || mailDetails === void 0 ? void 0 : mailDetails.subject : "Review Documents", template);
@@ -336,7 +372,11 @@ function createPendingApprovalFunction(req) {
336
372
  documentUrl: process.env.FRONTEND_URL,
337
373
  comments: `You have successfully uploaded your document`,
338
374
  editedValues: formattedValues,
339
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
375
+ logo: process.env.domain === "indoco"
376
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
377
+ : process.env.domain === "akums"
378
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
379
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
340
380
  };
341
381
  const newTemplate = yield (0, compile_email_template_1.default)({
342
382
  fileName: "workflowApproval.mjml",
@@ -396,7 +436,7 @@ function createPendingApprovalFunction(req) {
396
436
  documentId: createdDocument.documentId,
397
437
  workflowId: createdDocument.workflow,
398
438
  values: req.body.values,
399
- file: file
439
+ file: file,
400
440
  },
401
441
  };
402
442
  }
@@ -413,7 +453,7 @@ function createPendingApprovalFunction(req) {
413
453
  return {
414
454
  status: "error",
415
455
  statusCode: 400,
416
- message: error === null || error === void 0 ? void 0 : error.message
456
+ message: error === null || error === void 0 ? void 0 : error.message,
417
457
  };
418
458
  }
419
459
  });
@@ -427,7 +467,7 @@ function createPendingApprovalService(req, res) {
427
467
  return res.status(statusCode).json({
428
468
  status: status,
429
469
  message: message,
430
- data: data
470
+ data: data,
431
471
  });
432
472
  }
433
473
  catch (error) {
@@ -682,14 +722,14 @@ function saveAsDraftService(req, res) {
682
722
  res.status(statusCode).send({
683
723
  status,
684
724
  message,
685
- data
725
+ data,
686
726
  });
687
727
  }
688
728
  catch (err) {
689
729
  res.status(500).send({
690
730
  message: err === null || err === void 0 ? void 0 : err.message,
691
731
  data: err === null || err === void 0 ? void 0 : err.message,
692
- statusCode: 500
732
+ statusCode: 500,
693
733
  });
694
734
  }
695
735
  });
@@ -743,7 +783,7 @@ function updateDocumentFunction(req, docId) {
743
783
  created_At: new Date(),
744
784
  };
745
785
  }
746
- let { currentUser, currentUserDetails, workflow, notifications, triggerMailForLevel1, triggers } = yield (0, workflow_service_1.getWorkflowLevelService)(updates.workflow, req.user.level, req.body.status);
786
+ let { currentUser, currentUserDetails, workflow, notifications, triggerMailForLevel1, triggers, } = yield (0, workflow_service_1.getWorkflowLevelService)(updates.workflow, req.user.level, req.body.status);
747
787
  let updatedDocuments = null;
748
788
  if (createType === "alternative") {
749
789
  updates.createdAt = new Date();
@@ -774,12 +814,14 @@ function updateDocumentFunction(req, docId) {
774
814
  message: message,
775
815
  documentId: id,
776
816
  type: req.body.type,
777
- workflow: updates.workflow
817
+ workflow: updates.workflow,
778
818
  };
779
- const account = mongoose_1.default.models['Organisation'];
780
- const details = yield account.findOne({ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId });
819
+ const account = mongoose_1.default.models["Organisation"];
820
+ const details = yield account.findOne({
821
+ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId,
822
+ });
781
823
  console.log(docData);
782
- console.log('the details are are', details);
824
+ console.log("the details are are", details);
783
825
  const notificationsPromises = currentUser.map((userId, index) => __awaiter(this, void 0, void 0, function* () {
784
826
  var _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
785
827
  const userData = Object.assign(Object.assign({}, data), { receiver: userId });
@@ -806,11 +848,15 @@ function updateDocumentFunction(req, docId) {
806
848
  let temp = null;
807
849
  let planningGroup = null;
808
850
  if (process.env.domain === "indoco") {
809
- const organigation = mongoose_1.default.models['Organisation'];
810
- const orgs = yield organigation.findOne({ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId });
851
+ const organigation = mongoose_1.default.models["Organisation"];
852
+ const orgs = yield organigation.findOne({
853
+ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId,
854
+ });
811
855
  planningGroup = (_3 = orgs === null || orgs === void 0 ? void 0 : orgs.accountSettingsDetails) === null || _3 === void 0 ? void 0 : _3.planningGroup;
812
- const account = mongoose_1.default.models['Accounts'];
813
- const details = yield account.findOne({ _id: orgs === null || orgs === void 0 ? void 0 : orgs.user_id });
856
+ const account = mongoose_1.default.models["Accounts"];
857
+ const details = yield account.findOne({
858
+ _id: orgs === null || orgs === void 0 ? void 0 : orgs.user_id,
859
+ });
814
860
  if (details) {
815
861
  temp = {
816
862
  vendorName: orgs === null || orgs === void 0 ? void 0 : orgs.vendorName,
@@ -822,7 +868,11 @@ function updateDocumentFunction(req, docId) {
822
868
  approver: currentUserDetails[index].username,
823
869
  comment: message,
824
870
  editedValues: formattedValues,
825
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
871
+ logo: process.env.domain === "indoco"
872
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
873
+ : process.env.domain === "akums"
874
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
875
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
826
876
  };
827
877
  }
828
878
  }
@@ -836,15 +886,27 @@ function updateDocumentFunction(req, docId) {
836
886
  ? `${((_8 = (_7 = req.user.username) === null || _7 === void 0 ? void 0 : _7.charAt(0)) === null || _8 === void 0 ? void 0 : _8.toUpperCase()) +
837
887
  ((_11 = (_10 = (_9 = req.user) === null || _9 === void 0 ? void 0 : _9.username) === null || _10 === void 0 ? void 0 : _10.slice(1)) === null || _11 === void 0 ? void 0 : _11.toLowerCase())} has reuploaded the document`
838
888
  : `${data.message}`,
839
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
840
- editedValues: formattedValues
889
+ logo: process.env.domain === "indoco"
890
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
891
+ : process.env.domain === "akums"
892
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
893
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
894
+ editedValues: formattedValues,
841
895
  };
842
896
  if (notifyItem.type.includes("email")) {
843
897
  const template = yield (0, compile_email_template_1.default)({
844
- fileName: process.env.domain === "indoco" ? (req.body.status === "rejected" ? "indocoRejectedRequest.mjml" : "indocoRequest.mjml") : "workflowApproval.mjml",
898
+ fileName: process.env.domain === "indoco"
899
+ ? req.body.status === "rejected"
900
+ ? "indocoRejectedRequest.mjml"
901
+ : "indocoRequest.mjml"
902
+ : "workflowApproval.mjml",
845
903
  data: dt,
846
904
  });
847
- yield (0, mail_1.default)(currentUserDetails[index].username, process.env.domain === "indoco" ? (req.body.status === "rejected" ? `INDOCO REMEDIES LIMITED: Vendor Onboarding Request Rejected - ${planningGroup}` : `INDOCO REMEDIES LIMITED: Vendor Onboarding Request ${planningGroup}`) : "Review Documents", template);
905
+ yield (0, mail_1.default)(currentUserDetails[index].username, process.env.domain === "indoco"
906
+ ? req.body.status === "rejected"
907
+ ? `INDOCO REMEDIES LIMITED: Vendor Onboarding Request Rejected - ${planningGroup}`
908
+ : `INDOCO REMEDIES LIMITED: Vendor Onboarding Request ${planningGroup}`
909
+ : "Review Documents", template);
848
910
  emailResults.push({
849
911
  status: "success",
850
912
  message: `Email sent to user ${userId}`,
@@ -868,13 +930,16 @@ function updateDocumentFunction(req, docId) {
868
930
  };
869
931
  }
870
932
  }));
871
- if (triggerMailForLevel1 || (((_r = workflow === null || workflow === void 0 ? void 0 : workflow.values[0]) === null || _r === void 0 ? void 0 : _r.reset_to_level_1) && req.body.status === "rejected")) {
933
+ if (triggerMailForLevel1 ||
934
+ (((_r = workflow === null || workflow === void 0 ? void 0 : workflow.values[0]) === null || _r === void 0 ? void 0 : _r.reset_to_level_1) && req.body.status === "rejected")) {
872
935
  let temp = null;
873
936
  let planningGroup = null;
874
937
  if (process.env.domain === "indoco") {
875
- const organigation = mongoose_1.default.models['Organisation'];
876
- const orgs = yield organigation.findOne({ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId });
877
- const account = mongoose_1.default.models['Accounts'];
938
+ const organigation = mongoose_1.default.models["Organisation"];
939
+ const orgs = yield organigation.findOne({
940
+ onboardingId: docData === null || docData === void 0 ? void 0 : docData.documentId,
941
+ });
942
+ const account = mongoose_1.default.models["Accounts"];
878
943
  const details = yield account.findOne({ _id: orgs === null || orgs === void 0 ? void 0 : orgs.user_id });
879
944
  if (details) {
880
945
  planningGroup = (_s = details === null || details === void 0 ? void 0 : details.accountSettingsDetails) === null || _s === void 0 ? void 0 : _s.planningGroup;
@@ -888,7 +953,11 @@ function updateDocumentFunction(req, docId) {
888
953
  approver: docData === null || docData === void 0 ? void 0 : docData.user.username,
889
954
  comment: message,
890
955
  editedValues: formattedValues,
891
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
956
+ logo: process.env.domain === "indoco"
957
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
958
+ : process.env.domain === "akums"
959
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
960
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
892
961
  };
893
962
  }
894
963
  }
@@ -901,15 +970,26 @@ function updateDocumentFunction(req, docId) {
901
970
  comments: createType === "reupload" || createType === "alternative"
902
971
  ? `You have successfully uploaded your document`
903
972
  : `${data.message}`,
904
- logo: process.env.domain === "indoco" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png" : process.env.domain === "akums" ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg" : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
905
- editedValues: formattedValues
973
+ logo: process.env.domain === "indoco"
974
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745298991/taskManager/Indoco-logo-png-W200px.png"
975
+ : process.env.domain === "akums"
976
+ ? "https://res.cloudinary.com/dsckn1jjj/image/upload/v1745336631/taskManager/download.jpg"
977
+ : "https://www.sequelstring.com/_next/image?url=%2Fimages%2Flogo.webp&w=256&q=100",
978
+ editedValues: formattedValues,
906
979
  };
907
980
  const Mailtemplate = yield (0, compile_email_template_1.default)({
908
- fileName: process.env.domain === "indoco" ? (req.body.status === "rejected" ? "indocoRejectedRequest.mjml" : "indocoRequest.mjml") : "workflowApproval.mjml",
981
+ fileName: process.env.domain === "indoco"
982
+ ? req.body.status === "rejected"
983
+ ? "indocoRejectedRequest.mjml"
984
+ : "indocoRequest.mjml"
985
+ : "workflowApproval.mjml",
909
986
  data: Level1Mail,
910
987
  });
911
- yield (0, mail_1.default)((_w = docData === null || docData === void 0 ? void 0 : docData.user) === null || _w === void 0 ? void 0 : _w.username, process.env.domain === "indoco" ? (req.body.status === "rejected" ? `INDOCO REMEDIES LIMITED: Vendor Onboarding Request Rejected - ${planningGroup}` : `INDOCO REMEDIES LIMITED: Vendor Onboarding Request - ${planningGroup}`) :
912
- createType === "reupload" || createType === "alternative"
988
+ yield (0, mail_1.default)((_w = docData === null || docData === void 0 ? void 0 : docData.user) === null || _w === void 0 ? void 0 : _w.username, process.env.domain === "indoco"
989
+ ? req.body.status === "rejected"
990
+ ? `INDOCO REMEDIES LIMITED: Vendor Onboarding Request Rejected - ${planningGroup}`
991
+ : `INDOCO REMEDIES LIMITED: Vendor Onboarding Request - ${planningGroup}`
992
+ : createType === "reupload" || createType === "alternative"
913
993
  ? "Document Reuploaded Successfully."
914
994
  : "Status Updated", Mailtemplate);
915
995
  }
@@ -933,7 +1013,8 @@ function updateDocumentFunction(req, docId) {
933
1013
  for (const item of triggers) {
934
1014
  try {
935
1015
  if (Array.isArray(item.level)) {
936
- if ((item === null || item === void 0 ? void 0 : item.level.includes((_x = req.body) === null || _x === void 0 ? void 0 : _x.level)) && (item === null || item === void 0 ? void 0 : item.approval.includes(req.body.status))) {
1016
+ if ((item === null || item === void 0 ? void 0 : item.level.includes((_x = req.body) === null || _x === void 0 ? void 0 : _x.level)) &&
1017
+ (item === null || item === void 0 ? void 0 : item.approval.includes(req.body.status))) {
937
1018
  const helpInfo = (0, common_1.findTriggerValues)(((_y = docData === null || docData === void 0 ? void 0 : docData._doc) === null || _y === void 0 ? void 0 : _y.helpInfo) || {}, req.body.status);
938
1019
  if (item.action === "url") {
939
1020
  const docs = yield document_schema_1.default.findById(new mongoose_1.default.Types.ObjectId(id));
@@ -971,8 +1052,13 @@ exports.updateDocumentFunction = updateDocumentFunction;
971
1052
  function withdrawalApprovalService(req, res) {
972
1053
  return __awaiter(this, void 0, void 0, function* () {
973
1054
  try {
974
- const { status, statusCode, message, data } = yield (0, document_repository_1.withdrawalApprovalDocument)({ id: req.body.documentId, level: req.user.level });
975
- return res.status(statusCode).send({ status: status, message: message, data });
1055
+ const { status, statusCode, message, data } = yield (0, document_repository_1.withdrawalApprovalDocument)({
1056
+ id: req.body.documentId,
1057
+ level: req.user.level,
1058
+ });
1059
+ return res
1060
+ .status(statusCode)
1061
+ .send({ status: status, message: message, data });
976
1062
  }
977
1063
  catch (error) {
978
1064
  console.log(error);