tango-app-api-infra 3.0.15 → 3.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -14,14 +14,15 @@
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "aws-sdk": "^2.1571.0",
17
+ "cors": "^2.8.5",
17
18
  "dayjs": "^1.11.10",
18
19
  "dotenv": "^16.4.5",
19
20
  "express": "^4.18.3",
20
21
  "handlebars": "^4.7.8",
21
22
  "mongodb": "^6.4.0",
22
23
  "nodemon": "^3.1.0",
23
- "tango-api-schema": "^2.0.44",
24
- "tango-app-api-middleware": "^1.0.21",
24
+ "tango-api-schema": "^2.0.49",
25
+ "tango-app-api-middleware": "^1.0.29",
25
26
  "winston": "^3.12.0",
26
27
  "winston-daily-rotate-file": "^5.0.0"
27
28
  },
@@ -1,9 +1,9 @@
1
1
 
2
- import { countDocumentsStore, findStorewithpagination } from '../services/store.service.js';
2
+ import { aggregateStore, countDocumentsStore } from '../services/store.service.js';
3
3
  import { logger, download } from 'tango-app-api-middleware';
4
4
  import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
5
5
  import { findinfraReason } from '../services/infraReason.service.js';
6
- import { findClientwithpagination } from '../services/client.service.js';
6
+ import { aggregateClient } from '../services/client.service.js';
7
7
  import dayjs from 'dayjs';
8
8
  import { getOpenSearchData } from 'tango-app-api-middleware';
9
9
 
@@ -91,7 +91,7 @@ export async function infraCard( req, res ) {
91
91
  },
92
92
  },
93
93
  ];
94
- if ( req.body.filter&&req.body.filter.length>0 ) {
94
+ if ( req.body.filter && req.body.filter.length > 0 ) {
95
95
  query.push(
96
96
  {
97
97
  $match: {
@@ -101,6 +101,7 @@ export async function infraCard( req, res ) {
101
101
  );
102
102
  }
103
103
  let ticketList = await aggregateTangoTicket( query );
104
+
104
105
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
105
106
  const categoryCounts = {};
106
107
  let response;
@@ -336,7 +337,7 @@ export async function infraIssuesTable( req, res ) {
336
337
  );
337
338
  }
338
339
  let result = await aggregateTangoTicket( query );
339
- if ( req.body.export ) {
340
+ if ( req.body.export && result.length > 0 ) {
340
341
  const exportdata = [];
341
342
  result.forEach( ( element ) => {
342
343
  exportdata.push( {
@@ -445,13 +446,47 @@ export async function InstallationIssuesTable( req, res ) {
445
446
  export async function hourWiseDownClients( req, res ) {
446
447
  try {
447
448
  let inputData = req.body;
448
- let skip = 0;
449
- let limit = 10;
449
+
450
+ let query = [
451
+ {
452
+ $match: {
453
+ clientId: { $in: req.body.clientId },
454
+ },
455
+ },
456
+ {
457
+ $project: {
458
+ clientId: 1,
459
+ clientName: 1,
460
+ },
461
+ },
462
+ ];
463
+
464
+
465
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
466
+ query.push( {
467
+ $match: {
468
+ $or: [
469
+ { clientName: { $regex: req.body.searchValue, $options: 'i' } },
470
+ ],
471
+ },
472
+ } );
473
+ }
474
+ if ( req.body.sortColumName && req.body.sortColumName != '' && req.body.sortBy && req.body.sortBy != '' ) {
475
+ query.push( {
476
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
477
+ } );
478
+ }
479
+ let count = await aggregateClient( query );
450
480
  if ( req.body.limit && req.body.offset && !req.body.export ) {
451
- skip = ( req.body.offset - 1 ) * req.body.limit,
452
- limit = Number( req.body.limit );
481
+ query.push(
482
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
483
+ { $limit: Number( req.body.limit ) },
484
+ );
485
+ }
486
+ let clientlist = await aggregateClient( query );
487
+ if ( clientlist.length == 0 ) {
488
+ return res.sendError( 'no data', 204 );
453
489
  }
454
- let clientlist = await findClientwithpagination( { clientId: { $in: req.body.clientId } }, { clientId: 1, clientName: 1 }, skip, limit );
455
490
  let data = {};
456
491
  let result = [];
457
492
  for ( const client of clientlist ) {
@@ -460,7 +495,11 @@ export async function hourWiseDownClients( req, res ) {
460
495
  let clientdata = await livecountCheck( data, inputData );
461
496
  result.push( clientdata[0] );
462
497
  }
463
- res.sendSuccess( { result: result } );
498
+ if ( req.body.export && result.length > 0 ) {
499
+ await download( result, res );
500
+ return;
501
+ }
502
+ res.sendSuccess( { count: count.length, result: result } );
464
503
  } catch ( error ) {
465
504
  logger.error( { error: error, function: 'hourWiseDownClients' } );
466
505
  return res.sendError( error, 500 );
@@ -556,13 +595,47 @@ export async function hourWiseDownstores( req, res ) {
556
595
  try {
557
596
  let inputData = req.body;
558
597
  inputData.Date = dayjs().format( 'YYYY-MM-DD' );
559
- let skip = 0;
560
- let limit = 10;
598
+
599
+ let query = [ {
600
+ $match: {
601
+ clientId: req.body.clientId,
602
+ },
603
+ },
604
+ {
605
+ $project: {
606
+ storeId: 1,
607
+ storeName: 1,
608
+ storeProfile: 1,
609
+ },
610
+ },
611
+
612
+ ];
613
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
614
+ query.push( {
615
+ $match: {
616
+ $or: [
617
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
618
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
619
+ ],
620
+ },
621
+ } );
622
+ }
623
+ if ( req.body.sortColumName && req.body.sortColumName != '' && req.body.sortBy && req.body.sortBy != '' ) {
624
+ query.push( {
625
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
626
+ } );
627
+ }
628
+ let count = await aggregateStore( query );
561
629
  if ( req.body.limit && req.body.offset && !req.body.export ) {
562
- skip = ( req.body.offset - 1 ) * req.body.limit,
563
- limit = Number( req.body.limit );
630
+ query.push(
631
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
632
+ { $limit: Number( req.body.limit ) },
633
+ );
634
+ }
635
+ let storeslist = await aggregateStore( query );
636
+ if ( storeslist.length == 0 ) {
637
+ return res.sendError( 'no data', 204 );
564
638
  }
565
- let storeslist = await findStorewithpagination( { clientId: req.body.clientId }, { storeId: 1, storeName: 1, storeProfile: 1 }, skip, limit );
566
639
  let data = {};
567
640
  let result = [];
568
641
  for ( const store of storeslist ) {
@@ -571,7 +644,11 @@ export async function hourWiseDownstores( req, res ) {
571
644
  let storedata = await downStoresCheck( data, inputData );
572
645
  result.push( storedata[0] );
573
646
  }
574
- res.sendSuccess( { result: result } );
647
+ if ( req.body.export && result.length > 0 ) {
648
+ await download( result, res );
649
+ return;
650
+ }
651
+ res.sendSuccess( { count: count.length, result: result } );
575
652
  } catch ( error ) {
576
653
  logger.error( { error: error, function: 'hourWiseDownstores' } );
577
654
  return res.sendError( error, 500 );
@@ -2,7 +2,9 @@
2
2
 
3
3
  import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
- import { logger } from 'tango-app-api-middleware';
5
+ import { updateOneStore } from '../services/store.service.js';
6
+ import { logger, fileUpload } from 'tango-app-api-middleware';
7
+ import dayjs from 'dayjs';
6
8
  export async function createTicket( req, res ) {
7
9
  try {
8
10
  req.body.issueDate = new Date( req.body.Date );
@@ -106,7 +108,7 @@ export async function updateTicketIssue( req, res ) {
106
108
 
107
109
  export async function viewTicket( req, res ) {
108
110
  try {
109
- let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketActivity: 1 } );
111
+ let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketDetails: 1, basicDetails: 1, ticketActivity: 1 } );
110
112
  if ( ticket ) {
111
113
  res.sendSuccess( ticket );
112
114
  }
@@ -124,8 +126,30 @@ export async function AlertTicketReply( req, res ) {
124
126
  statusCheckReply: req.body.statusCheckReply,
125
127
  hibernationDays: req.body.hibernationDays,
126
128
  } );
129
+ await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity } );
130
+ if ( req.body.hibernationDays ) {
131
+ req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
132
+ await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
133
+ }
134
+ res.sendSuccess( 'Updated Successfully' );
127
135
  } catch ( error ) {
128
136
  logger.error( { error: error, function: 'AlertTicketReply' } );
129
137
  return res.sendError( error, 500 );
130
138
  }
131
139
  }
140
+ export async function uploadAttachments( req, res ) {
141
+ try {
142
+ let params ={
143
+ Bucket: 'tango-brand-info-uat',
144
+ key: req.params.ticketId,
145
+ fileName: req.files[0].name,
146
+
147
+
148
+ };
149
+ let response =await fileUpload( params );
150
+ res.sendSuccess( response );
151
+ } catch ( error ) {
152
+ logger.error( { error: error, function: 'uploadAttachments' } );
153
+ return res.sendError( error, 500 );
154
+ }
155
+ }
@@ -1,6 +1,11 @@
1
1
 
2
2
  import { logger } from 'tango-app-api-middleware';
3
3
  import dayjs from 'dayjs';
4
+ import utc from 'dayjs/plugin/utc.js';
5
+ import timezone from 'dayjs/plugin/timezone.js';
6
+ import 'dayjs/locale/en.js';
7
+ dayjs.extend( utc );
8
+ dayjs.extend( timezone );
4
9
  import { createClient, findClient } from '../services/client.service.js';
5
10
  import { createStore, findStore, updateOneStore } from '../services/store.service.js';
6
11
  import { findTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
@@ -98,8 +103,7 @@ export async function setTicketTime( req, res ) {
98
103
 
99
104
  export async function downStoresList( req, res ) {
100
105
  try {
101
- let getCurrentHour = dayjs().startOf( 'hour' ).format( 'YYYY-MM-DDTHH:mm' );
102
- let storesList = await findStore( { 'ticketConfigs.nextTicektGenerationTime': new Date( getCurrentHour ) }, { storeId: 1, storeName: 1, storeProfile: 1, ticketConfigs: 1 } );
106
+ let storesList = await findStore( { 'ticketConfigs.hibernation': { $lt: new Date() }, 'ticketConfigs.nextTicektGenerationTime': new Date( req.body.getTime ) }, { storeId: 1, storeName: 1, storeProfile: 1, ticketConfigs: 1 } );
103
107
  if ( storesList.length > 0 ) {
104
108
  res.sendSuccess( storesList );
105
109
  } else {
@@ -1,5 +1,5 @@
1
1
 
2
- import { logger, getOpenSearchData } from 'tango-app-api-middleware';
2
+ import { logger, getOpenSearchData, download } from 'tango-app-api-middleware';
3
3
  import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { findOneStore } from '../services/store.service.js';
5
5
  import dayjs from 'dayjs';
@@ -8,14 +8,18 @@ export async function storeTicketList( req, res ) {
8
8
  try {
9
9
  let query = [ {
10
10
  $match: {
11
- 'basicDetails.storeId': req.body.storeId,
11
+ $and: [
12
+ { 'basicDetails.storeId': req.body.storeId },
13
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
14
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
15
+ ],
12
16
  },
13
17
  },
14
18
  {
15
19
  $project: {
16
20
  storeId: '$basicDetails.storeId',
17
21
  status: 1,
18
- Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
22
+ Date: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
19
23
  issueClosedDate: 1,
20
24
  ticketId: 1,
21
25
  issueStatus: '$ticketDetails.issueStatus',
@@ -53,7 +57,30 @@ export async function storeTicketList( req, res ) {
53
57
  },
54
58
  },
55
59
  ];
60
+
61
+ if ( req.body.filter && req.body.filter !== '' ) {
62
+ query.push( {
63
+ $match: {
64
+ primaryIssue: req.body.filter,
65
+ },
66
+ } );
67
+ }
56
68
  let ticketList = await aggregateTangoTicket( query );
69
+ if ( req.body.export && ticketList.length > 0 ) {
70
+ const exportdata = [];
71
+ ticketList.forEach( ( element ) => {
72
+ exportdata.push( {
73
+ 'STORE ID': element.storeId,
74
+ 'TICKET ID': element.ticketId,
75
+ 'DATE': element.Date,
76
+ 'ISSUE CLOSED DATE': element.issueClosedDate,
77
+ 'ISSUE': element.primaryIssue,
78
+ 'STATUS': element.status,
79
+ } );
80
+ } );
81
+ await download( exportdata, res );
82
+ return;
83
+ }
57
84
  if ( ticketList.length ) {
58
85
  res.sendSuccess( {
59
86
  count: ticketList.length,
@@ -72,8 +99,13 @@ export async function storeTicketcard( req, res ) {
72
99
  try {
73
100
  let query = [ {
74
101
  $match: {
75
- 'basicDetails.storeId': req.body.storeId,
76
- 'ticketDetails.issueStatus': 'identified',
102
+ $and: [
103
+ { 'basicDetails.storeId': req.body.storeId },
104
+ { 'ticketDetails.issueStatus': 'identified' },
105
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
106
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
107
+ ],
108
+
77
109
  },
78
110
  },
79
111
  {
@@ -309,6 +341,10 @@ export async function edgeAppLogTable( req, res ) {
309
341
  const appStatus = await getOpenSearchData( 'edgeapp_systemlogs', appStatusQuery );
310
342
  obj.appStatus = appStatus.body.hits.hits.length > 0 ? appStatus.body.hits.hits[0]._source.data.message : '';
311
343
  }
344
+ if ( req.body.export ) {
345
+ await download( timeSlots, res );
346
+ return;
347
+ }
312
348
  res.sendSuccess( timeSlots );
313
349
  } catch ( error ) {
314
350
  logger.error( { error: error, function: 'edgeAppLog' } );
@@ -94,7 +94,41 @@ export async function userTicketList( req, res ) {
94
94
  infraIssue: '$primaryIssue.reasons.primaryIssue',
95
95
  },
96
96
  } );
97
+
98
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
99
+ query.push( {
100
+ $match: {
101
+ $or: [
102
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
103
+ { infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
104
+ ],
105
+ },
106
+ } );
107
+ }
108
+ if ( req.body.filter && req.body.filter !== '' ) {
109
+ query.push( {
110
+ $match: {
111
+ $or: [
112
+ { issueStatus: req.body.filter },
113
+ { infraIssue: req.body.filter },
114
+ ],
115
+ },
116
+ } );
117
+ }
97
118
  let ticketList = await aggregateTangoTicket( query );
119
+ if ( req.body.export ) {
120
+ const exportdata = [];
121
+ ticketList.forEach( ( element ) => {
122
+ exportdata.push( {
123
+ 'DATE': element.Date,
124
+ 'TICKET ID': element.ticketId,
125
+ 'STORE ID': element.storeId,
126
+ 'ISSUE': element.issueStatus,
127
+ } );
128
+ } );
129
+ await download( exportdata, res );
130
+ return;
131
+ }
98
132
  if ( ticketList.length ) {
99
133
  res.sendSuccess( {
100
134
  count: ticketList.length,
@@ -108,6 +142,40 @@ export async function userTicketList( req, res ) {
108
142
  return res.sendError( error, 500 );
109
143
  }
110
144
  }
145
+ export async function activeTicketList( req, res ) {
146
+ try {
147
+ let query = [ {
148
+ $match: {
149
+ $and: [
150
+ { 'status': { $in: [ 'open', 'inprogress' ] } },
151
+ { issueType: req.body.issueType },
152
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
153
+ ],
154
+ },
155
+ }, {
156
+ $project: {
157
+ storeId: '$basicDetails.storeId',
158
+ address: { $ifNull: [ '$basicDetails.address', '' ] },
159
+ status: 1,
160
+ },
161
+ } ];
162
+
163
+
164
+ let ticketList = await aggregateTangoTicket( query );
165
+
166
+ if ( ticketList.length ) {
167
+ res.sendSuccess( {
168
+ count: ticketList.length,
169
+ data: ticketList,
170
+ } );
171
+ } else {
172
+ return res.sendError( 'NO data', 204 );
173
+ }
174
+ } catch ( error ) {
175
+ logger.error( { error: error, function: 'activeTicketList' } );
176
+ return res.sendError( error, 500 );
177
+ }
178
+ }
111
179
  export async function basicDetails( req, res ) {
112
180
  try {
113
181
  let user = await findOneUser( { _id: new mongoose.Types.ObjectId( req.body.userId ) }, { userName: 1, userType: 1 } );
@@ -139,57 +207,113 @@ export async function workHistory( req, res ) {
139
207
  $match: {
140
208
  $and: [
141
209
  { 'status': 'closed' },
210
+ { issueType: req.body.issueType },
142
211
  { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
143
- { createdAt: { $gte: new Date( req.body.fromDate ) } },
144
- { createdAt: { $lte: new Date( req.body.toDate ) } },
145
212
  ],
146
213
  },
147
- },
148
- {
149
- $project: {
150
- storeId: '$basicDetails.storeId',
151
- storeName: '$basicDetails.storeName',
152
- clientId: '$basicDetails.clientId',
153
- clientName: '$basicDetails.clientName',
154
- issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
155
- issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
156
- issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
157
- ticketId: 1,
158
- issueStatus: '$ticketDetails.issueStatus',
159
- ticketType: '$ticketDetails.ticketType',
160
- primaryIssue: {
161
- $filter: {
162
- input: '$ticketActivity',
163
- as: 'item',
164
- cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
214
+ } ];
215
+
216
+ if ( req.body.dateFilter&&req.body.dateFilter !='' ) {
217
+ if ( req.body.dateFilter === 'issueIdentifiedDate' ) {
218
+ query.push(
219
+ {
220
+ $match: {
221
+ $and: [
222
+ { 'ticketDetails.issueIdentifiedDate': { $gte: new Date( req.body.fromDate ) } },
223
+ { 'ticketDetails.issueIdentifiedDate': { $lte: new Date( req.body.toDate ) } },
224
+ ],
225
+
226
+ },
227
+ },
228
+ );
229
+ } else if ( req.body.dateFilter === 'closedDate' ) {
230
+ query.push(
231
+ {
232
+ $match: {
233
+ $and: [
234
+ { 'issueClosedDate': { $gte: new Date( req.body.fromDate ) } },
235
+ { 'issueClosedDate': { $lte: new Date( req.body.toDate ) } },
236
+ ],
237
+
238
+ },
239
+ },
240
+ );
241
+ } else {
242
+ query.push(
243
+ {
244
+ $match: {
245
+ $and: [
246
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
247
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
248
+ ],
249
+
250
+ },
251
+ },
252
+ );
253
+ }
254
+ }
255
+
256
+ if ( req.body.storeFilter&&req.body.storeFilter.length>0 ) {
257
+ query.push(
258
+ {
259
+ $match: {
260
+ 'basicDetails.storeId': { $in: req.body.storeFilter } },
261
+ },
262
+ );
263
+ }
264
+ query.push(
265
+ {
266
+ $project: {
267
+ storeId: '$basicDetails.storeId',
268
+ storeName: '$basicDetails.storeName',
269
+ clientId: '$basicDetails.clientId',
270
+ clientName: '$basicDetails.clientName',
271
+ issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
272
+ issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
273
+ issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
274
+ ticketId: 1,
275
+ issueStatus: '$ticketDetails.issueStatus',
276
+ ticketType: '$ticketDetails.ticketType',
277
+ primaryIssue: {
278
+ $filter: {
279
+ input: '$ticketActivity',
280
+ as: 'item',
281
+ cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
282
+ },
283
+ },
165
284
  },
166
285
  },
167
- },
168
- },
169
- {
170
- $unwind: {
171
- path: '$primaryIssue', preserveNullAndEmptyArrays: true,
172
- },
173
- },
174
- {
175
- $unwind: {
176
- path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
177
- },
178
- }, {
179
- $project: {
180
- storeId: 1,
181
- storeName: 1,
182
- clientId: 1,
183
- clientName: 1,
184
- issueDate: 1,
185
- issueIdentifiedDate: 1,
186
- issueClosedDate: 1,
187
- ticketId: 1,
188
- issueStatus: 1,
189
- ticketType: 1,
190
- infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
191
- },
192
- } ];
286
+ {
287
+ $unwind: {
288
+ path: '$primaryIssue', preserveNullAndEmptyArrays: true,
289
+ },
290
+ },
291
+ {
292
+ $unwind: {
293
+ path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
294
+ },
295
+ }, {
296
+ $project: {
297
+ storeId: 1,
298
+ storeName: 1,
299
+ clientId: 1,
300
+ clientName: 1,
301
+ issueDate: 1,
302
+ issueIdentifiedDate: 1,
303
+ issueClosedDate: 1,
304
+ ticketId: 1,
305
+ issueStatus: 1,
306
+ ticketType: 1,
307
+ infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
308
+ },
309
+ } );
310
+ if ( req.body.issueFilter && req.body.issueFilter !== '' ) {
311
+ query.push( {
312
+ $match: {
313
+ infraIssue: req.body.issueFilter,
314
+ },
315
+ } );
316
+ }
193
317
  if ( req.body.searchValue && req.body.searchValue !== '' ) {
194
318
  query.push( {
195
319
  $match: {
@@ -289,7 +413,7 @@ export async function storeInfraList( req, res ) {
289
413
  },
290
414
  },
291
415
  ];
292
- if ( req.body.storeId && req.body.storeId.length>0 ) {
416
+ if ( req.body.storeId && req.body.storeId.length > 0 ) {
293
417
  query.push( {
294
418
  $match: {
295
419
  storeId: { $in: req.body.storeId },
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import { isAllowedSessionHandler } from 'tango-app-api-middleware';
4
4
  import { validateDetails, validateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
- import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply } from '../controllers/infra.controllers.js';
5
+ import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments } from '../controllers/infra.controllers.js';
6
6
 
7
7
 
8
8
  export const infraRouter = express.Router();
@@ -15,5 +15,6 @@ infraRouter.post( '/secondaryReason', isAllowedSessionHandler, secondaryReason )
15
15
  infraRouter.post( '/updateTicketIssue', isAllowedSessionHandler, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
16
16
  infraRouter.post( '/viewTicket', isAllowedSessionHandler, ticketExists, viewTicket );
17
17
  infraRouter.post( '/AlertTicketReply', isAllowedSessionHandler, ticketExists, AlertTicketReply );
18
+ infraRouter.put( '/uploadAttachments/:ticketId', isAllowedSessionHandler, ticketExists, uploadAttachments );
18
19
 
19
20
 
@@ -1,12 +1,13 @@
1
1
  import express from 'express';
2
2
  import { isAllowedSessionHandler } from 'tango-app-api-middleware';
3
- import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
3
+ import { userTakeTicket, userTicketList, activeTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
4
4
 
5
5
  export const userInfraRouter = express.Router();
6
6
 
7
7
 
8
8
  userInfraRouter.post( '/userTakeTicket', isAllowedSessionHandler, userTakeTicket );
9
9
  userInfraRouter.post( '/userTicketList', isAllowedSessionHandler, userTicketList );
10
+ userInfraRouter.post( '/activeTicketList', isAllowedSessionHandler, activeTicketList );
10
11
  userInfraRouter.post( '/basicDetails', isAllowedSessionHandler, basicDetails );
11
12
  userInfraRouter.post( '/workHistory', isAllowedSessionHandler, workHistory );
12
13
  userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, storeInfraList );
@@ -13,3 +13,6 @@ export async function findOneClient( query, project ) {
13
13
  export async function findClientwithpagination( query, project ) {
14
14
  return await dataModel.clientModel.find( query, project );
15
15
  }
16
+ export async function aggregateClient( query ) {
17
+ return await dataModel.clientModel.aggregate( query );
18
+ }
@@ -18,6 +18,7 @@ export async function validateDetails( req, res, next ) {
18
18
  req.body.basicDetails = {
19
19
  storeId: req.body.storeId,
20
20
  storeName: store.storeName,
21
+ address: store.storeProfile&&store.storeProfile.address?store.storeProfile.address:'',
21
22
  clientId: store.clientId,
22
23
  clientName: client.clientName,
23
24
  };
@@ -71,9 +72,10 @@ export async function validateTicket( req, res, next ) {
71
72
  };
72
73
  export async function ticketExists( req, res, next ) {
73
74
  try {
75
+ let ticketId = req.body.ticketId?req.body.ticketId:req.params.ticketId;
74
76
  let Ticket = await findOneTangoTicket(
75
77
  {
76
- ticketId: req.body.ticketId,
78
+ ticketId: ticketId,
77
79
  },
78
80
  );
79
81
  if ( !Ticket ) {