tango-app-api-infra 3.1.6 → 3.1.8

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.
package/index.js CHANGED
@@ -5,6 +5,8 @@ import { internalInfraRouter } from './src/routes/internalInfra.routes.js';
5
5
  import { userInfraRouter } from './src/routes/userInfra.routes.js';
6
6
  import { storeInfraRouter } from './src/routes/storeInfra.routes.js';
7
7
  import { clientInfraRouter } from './src/routes/clientInfra.routes.js';
8
- export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter };
8
+ import { employeeTrainigRouter } from './src/routes/employeetrainig.routes.js';
9
+
10
+ export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter, employeeTrainigRouter };
9
11
 
10
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "html-pdf-node": "^1.0.8",
25
25
  "mongodb": "^6.4.0",
26
26
  "nodemon": "^3.1.0",
27
- "tango-api-schema": "^2.0.90",
27
+ "tango-api-schema": "^2.0.92",
28
28
  "tango-app-api-middleware": "^3.1.7",
29
29
  "winston": "^3.12.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
@@ -0,0 +1,54 @@
1
+
2
+ import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { logger } from 'tango-app-api-middleware';
4
+ export async function createTicket( req, res ) {
5
+ console.log( req.body );
6
+ try {
7
+ let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
8
+ if ( ticketExist ) {
9
+ return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
10
+ }
11
+
12
+ req.body.issueDate = new Date( req.body.Date );
13
+ req.body.ticketId = 'TE_MAT_' + new Date().valueOf();
14
+ let create = await createTangoTicket( req.body );
15
+ console.log( create );
16
+ if ( create ) {
17
+ res.sendSuccess( 'Ticket Created Successfully' );
18
+ }
19
+ } catch ( error ) {
20
+ logger.error( { error: error, function: 'createTicket mat' } );
21
+ return res.sendError( error, 500 );
22
+ }
23
+ }
24
+
25
+ export async function updatecomment( req, res ) {
26
+ console.log( req.body );
27
+ try {
28
+ if ( req.body.comment != '' ) {
29
+ req.body.ticketActivity.push( {
30
+ actionType: 'comment',
31
+ actionBy: 'Tango',
32
+ timeStamp: new Date(),
33
+ IdentifiedBy: req.user.userName,
34
+ comment: req.body.comment,
35
+ } );
36
+ }
37
+ let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { ticketActivity: req.body.ticketActivity } );
38
+ if ( updateTicket ) {
39
+ res.sendSuccess( 'Ticket Updated Successfully' );
40
+ }
41
+ } catch ( error ) {
42
+ logger.error( { error: error, function: 'updatecomment mat' } );
43
+ return res.sendError( error, 500 );
44
+ }
45
+ }
46
+ export async function activityLog( req, res ) {
47
+ console.log( req.body );
48
+ try {
49
+ res.sendSuccess( req.body );
50
+ } catch ( error ) {
51
+ logger.error( { error: error, function: 'activityLog mat' } );
52
+ return res.sendError( error, 500 );
53
+ }
54
+ }
@@ -1091,6 +1091,171 @@ export async function installationTable( req, res ) {
1091
1091
  return res.sendError( error, 500 );
1092
1092
  }
1093
1093
  }
1094
+ export async function matTable( req, res ) {
1095
+ try {
1096
+ let query = [];
1097
+ let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
1098
+ if ( req.body.clientId && req.body.clientId.length > 0 ) {
1099
+ query.push( {
1100
+ $match: {
1101
+ 'basicDetails.clientId': { $in: req.body.clientId },
1102
+ },
1103
+ } );
1104
+ }
1105
+
1106
+ query.push( {
1107
+ $match: {
1108
+ $and: [
1109
+ { issueType: 'mat' },
1110
+ { createdAt: { $gte: date.start } },
1111
+ { createdAt: { $lte: date.end } },
1112
+ ],
1113
+ },
1114
+ },
1115
+ {
1116
+ $project: {
1117
+ storeId: '$basicDetails.storeId',
1118
+ clientId: '$basicDetails.clientId',
1119
+ ticketId: 1,
1120
+ storeName: '$basicDetails.storeName',
1121
+ clientName: '$basicDetails.clientName',
1122
+ status: 1,
1123
+ createdAt: 1,
1124
+ addressingUser: '$ticketDetails.addressingUser',
1125
+ issueDate: 1,
1126
+ },
1127
+ },
1128
+
1129
+ {
1130
+ '$lookup': {
1131
+ 'from': 'users',
1132
+ 'let': { 'userId': '$addressingUser' },
1133
+ 'pipeline': [
1134
+ {
1135
+ '$match': {
1136
+ '$expr': {
1137
+ '$eq': [ '$_id', '$$userId' ],
1138
+ },
1139
+ },
1140
+ },
1141
+ {
1142
+ '$project': {
1143
+ 'userName': 1,
1144
+ 'email': 1,
1145
+ 'role': 1,
1146
+ },
1147
+ },
1148
+ ],
1149
+ 'as': 'user',
1150
+ },
1151
+ },
1152
+
1153
+ {
1154
+ $unwind: {
1155
+ path: '$user',
1156
+ preserveNullAndEmptyArrays: true,
1157
+ },
1158
+ },
1159
+ {
1160
+ $group: {
1161
+ _id: '$ticketId',
1162
+ storeId: { $first: '$storeId' },
1163
+ clientId: { $first: '$clientId' },
1164
+ ticketId: { $first: '$ticketId' },
1165
+ storeName: { $first: '$storeName' },
1166
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
1167
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
1168
+ clientName: { $first: '$clientName' },
1169
+ createdAt: { $first: '$createdAt' },
1170
+ issueDate: { $last: '$issueDate' },
1171
+ status: { $last: '$status' },
1172
+ },
1173
+ },
1174
+ );
1175
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
1176
+ query.push( {
1177
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
1178
+ } );
1179
+ }
1180
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
1181
+ query.push( {
1182
+ $match: {
1183
+ storeId: { $in: req.body.storeIdFilter },
1184
+ },
1185
+ } );
1186
+ }
1187
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
1188
+ query.push( {
1189
+ $match: {
1190
+ status: { $in: req.body.statusFilter },
1191
+ },
1192
+ } );
1193
+ }
1194
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
1195
+ query.push( {
1196
+ $match: {
1197
+ userEmail: { $in: req.body.userFilter },
1198
+ },
1199
+ } );
1200
+ }
1201
+
1202
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' ) {
1203
+ query.push( {
1204
+ $match: {
1205
+ primaryIssue: req.body.filterIssue,
1206
+ },
1207
+ } );
1208
+ }
1209
+ if ( req.body.searchValue && req.body.searchValue != '' ) {
1210
+ query.push( {
1211
+ $match: {
1212
+ $or: [
1213
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
1214
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
1215
+ ],
1216
+ },
1217
+ } );
1218
+ }
1219
+ let count = await aggregateTangoTicket( query );
1220
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
1221
+ query.push(
1222
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
1223
+ { $limit: Number( req.body.limit ) },
1224
+ );
1225
+ }
1226
+ let result = await aggregateTangoTicket( query );
1227
+
1228
+ if ( req.body.export && result.length > 0 ) {
1229
+ const exportdata = [];
1230
+ result.forEach( ( element ) => {
1231
+ exportdata.push( {
1232
+ 'ticketId': element.ticketId,
1233
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1234
+ 'storeId': element.storeId,
1235
+ 'storeName': element.storeName,
1236
+ 'clientId': element.clientId,
1237
+ 'clientName': element.clientName,
1238
+ 'userName': element.userName,
1239
+ 'userEmail': element.userEmail,
1240
+ 'Status': element.installationStatus,
1241
+ } );
1242
+ } );
1243
+ await download( exportdata, res );
1244
+ return;
1245
+ }
1246
+ if ( result.length > 0 ) {
1247
+ res.sendSuccess( {
1248
+ count: count.length,
1249
+ result: result,
1250
+ } );
1251
+ } else {
1252
+ res.sendError( 'no data', 204 );
1253
+ }
1254
+ } catch ( error ) {
1255
+ logger.error( { error: error, function: 'installationTable' } );
1256
+ return res.sendError( error, 500 );
1257
+ }
1258
+ }
1094
1259
  export async function assignTicket( req, res ) {
1095
1260
  try {
1096
1261
  let tickets = await updateManyTangoTicket( { ticketId: { $in: req.body.tickets } }, { 'ticketDetails.assigntoUser': true, 'ticketDetails.addressingUser': req.body.user } );
@@ -123,7 +123,7 @@ export async function downStoresList( req, res ) {
123
123
  }
124
124
  export async function openTicketList( req, res ) {
125
125
  try {
126
- let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
126
+ let openTicketList = await findTangoTicket( { 'issueType': 'infra', 'status': { $ne: 'closed' } }, { issueType: 1, ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
127
127
  if ( openTicketList.length ) {
128
128
  res.sendSuccess( {
129
129
  count: openTicketList.length,
@@ -71,6 +71,15 @@ export async function userTakeTicket( req, res ) {
71
71
  }
72
72
  userTicket = await findOneTangoTicket( query );
73
73
  }
74
+ } else if ( req.body.issueType == 'mat' ) {
75
+ let query = {
76
+ 'status': { $ne: 'closed' },
77
+ 'issueType': 'mat',
78
+ };
79
+ if ( assignedClients.length > 0 ) {
80
+ query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
81
+ }
82
+ userTicket = await findOneTangoTicket( query );
74
83
  }
75
84
  if ( userTicket ) {
76
85
  let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { 'ticketDetails.addressingUser': req.body.userId } );
@@ -202,6 +211,7 @@ export async function userTicketList( req, res ) {
202
211
  } );
203
212
  }
204
213
  let ticketList = await aggregateTangoTicket( query );
214
+ console.log( ticketList );
205
215
  if ( req.body.export ) {
206
216
  const exportdata = [];
207
217
  ticketList.forEach( ( element ) => {
@@ -437,16 +447,16 @@ export async function workHistory( req, res ) {
437
447
  const exportdata = [];
438
448
  result.forEach( ( element ) => {
439
449
  exportdata.push( {
440
- 'CREATED ON': element.createdAt,
450
+ 'CREATED ON': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
441
451
  'TICKET ID': element.ticketId,
442
452
  'STORE ID': element.storeId,
443
453
  'STORE NAME': element.storeName,
444
454
  'CLIENT ID': element.clientId,
445
455
  'CLIENT NAME': element.clientName,
446
- 'CREATED STATUS': element.status,
447
456
  'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
448
457
  'CLOSED ON': element.issueClosedDate,
449
- 'STATUS': element.status,
458
+ 'ISSUE': element.infraIssue?element.infraIssue:'-',
459
+
450
460
  } );
451
461
  } );
452
462
  await download( exportdata, res );
@@ -591,7 +601,7 @@ export async function storeInfraList( req, res ) {
591
601
  if ( installationcheck ) {
592
602
  store.ticketId = installationcheck.ticketId;
593
603
  store.status = installationcheck.ticketDetails.installationStatus;
594
- if ( store.status === 'onboareded' ) {
604
+ if ( store.status === 'onboarded' ) {
595
605
  store.statusDetail = 'Ready to pair';
596
606
  }
597
607
  if ( store.status === 'paired' ) {
@@ -0,0 +1,17 @@
1
+ import { createTicket, updatecomment, activityLog } from '../controllers/employeeTraning.controller.js';
2
+ import { ticketExists, validateDetails } from '../validations/infra.validation.js';
3
+ import express from 'express';
4
+ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
5
+ export const employeeTrainigRouter = express.Router();
6
+
7
+
8
+ employeeTrainigRouter.post( '/createTicket', validateDetails, createTicket );
9
+ employeeTrainigRouter.post( '/updatecomment', isAllowedSessionHandler, authorize( {
10
+ userType: [ 'tango' ], access: [
11
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit' ] } ],
12
+ } ), ticketExists, updatecomment );
13
+
14
+ employeeTrainigRouter.post( '/activityLog', isAllowedSessionHandler, authorize( {
15
+ userType: [ 'tango' ], access: [
16
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
17
+ } ), ticketExists, activityLog );
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
4
4
  import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
- import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
5
+ import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable,
6
6
  secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
7
7
  updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
8
8
 
@@ -63,6 +63,10 @@ infraRouter.post( '/installationTable', isAllowedSessionHandler, authorize( {
63
63
  userType: [ 'client', 'tango' ], access: [
64
64
  { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
65
65
  } ), installationTable );
66
+ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
67
+ userType: [ 'client', 'tango' ], access: [
68
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
69
+ } ), matTable );
66
70
  infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
67
71
  userType: [ 'client', 'tango' ], access: [
68
72
  { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],