tango-app-api-infra 3.0.13 → 3.0.14

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.13",
3
+ "version": "3.0.14",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,8 +20,8 @@
20
20
  "handlebars": "^4.7.8",
21
21
  "mongodb": "^6.4.0",
22
22
  "nodemon": "^3.1.0",
23
- "tango-api-schema": "^2.0.38",
24
- "tango-app-api-middleware": "^1.0.18",
23
+ "tango-api-schema": "^2.0.39",
24
+ "tango-app-api-middleware": "^1.0.21",
25
25
  "winston": "^3.12.0",
26
26
  "winston-daily-rotate-file": "^5.0.0"
27
27
  },
@@ -13,8 +13,13 @@ export async function infraCard( req, res ) {
13
13
  let infraStoreCount = await aggregateTangoTicket( [
14
14
  {
15
15
  $match: {
16
- 'status': { $ne: 'closed' },
17
- 'basicDetails.clientId': { $in: req.body.clientId },
16
+ $and: [
17
+ { issueType: 'infra' },
18
+ { 'status': { $ne: 'closed' } },
19
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
20
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
21
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
22
+ ],
18
23
  },
19
24
  },
20
25
  {
@@ -42,8 +47,14 @@ export async function infraCard( req, res ) {
42
47
  ] );
43
48
  let query = [ {
44
49
  $match: {
45
- 'basicDetails.clientId': { $in: req.body.clientId },
46
- 'infraTicketDetails.issueStatus': 'identified',
50
+ $and: [
51
+ { issueType: 'infra' },
52
+ { 'status': { $ne: 'closed' } },
53
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
54
+ { 'infraTicketDetails.issueStatus': 'identified' },
55
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
56
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
57
+ ],
47
58
  },
48
59
  },
49
60
  {
@@ -115,12 +126,18 @@ export async function infraCard( req, res ) {
115
126
  }
116
127
  }
117
128
 
118
-
119
129
  export async function infraIssuesTable( req, res ) {
120
130
  try {
121
131
  let query = [ {
122
132
  $match: {
123
- 'basicDetails.clientId': { $in: req.body.clientId },
133
+ $and: [
134
+ { issueType: 'infra' },
135
+ { status: { $ne: 'closed' } },
136
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
137
+ { 'infraTicketDetails.issueStatus': 'identified' },
138
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
139
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
140
+ ],
124
141
  },
125
142
  },
126
143
  {
@@ -149,7 +166,13 @@ export async function infraIssuesTable( req, res ) {
149
166
  $unwind: {
150
167
  path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
151
168
  },
152
- }, {
169
+ },
170
+ {
171
+ $unwind: {
172
+ path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
173
+ },
174
+ },
175
+ {
153
176
  $project: {
154
177
  storeId: 1,
155
178
  storeName: 1,
@@ -157,9 +180,45 @@ export async function infraIssuesTable( req, res ) {
157
180
  issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '-' ] },
158
181
  issueClosedDate: { $ifNull: [ '$issueClosedDate', '-' ] },
159
182
  status: 1,
160
- infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
183
+ primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
184
+ secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
185
+ },
186
+ },
187
+ {
188
+ $group: {
189
+ _id: '$storeId',
190
+ storeName: { $first: '$storeName' },
191
+ createdAt: { $first: '$createdAt' },
192
+ issueIdentifiedDate: { $first: '$issueIdentifiedDate' },
193
+ issueClosedDate: { $first: '$issueClosedDate' },
194
+ status: { $first: '$status' },
195
+ primaryIssue: { $first: '$primaryIssue' },
196
+ secondaryIssue: { $first: '$secondaryIssue' },
161
197
  },
162
- } ];
198
+ },
199
+ ];
200
+ if ( req.body.filterIssue && req.body.filterIssue !== '' ) {
201
+ query.push( {
202
+ $match: {
203
+ primaryIssue: req.body.filterIssue,
204
+ },
205
+ } );
206
+ }
207
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
208
+ query.push( {
209
+ $match: {
210
+ $or: [
211
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
212
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
213
+ ],
214
+ },
215
+ } );
216
+ }
217
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
218
+ query.push( {
219
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
220
+ } );
221
+ }
163
222
  let count = await aggregateTangoTicket( query );
164
223
  if ( req.body.limit && req.body.offset && !req.body.export ) {
165
224
  query.push(
@@ -168,17 +227,112 @@ export async function infraIssuesTable( req, res ) {
168
227
  );
169
228
  }
170
229
  let result = await aggregateTangoTicket( query );
230
+ if ( req.body.export ) {
231
+ const exportdata = [];
232
+ result.forEach( ( element ) => {
233
+ exportdata.push( {
234
+ 'STORE ID': element.storeId,
235
+ 'STORE NAME': element.storeName,
236
+ 'STATUS': element.status,
237
+ 'CITY': element.city,
238
+ 'STATE': element.state,
239
+ 'COUNTRY': element.country,
240
+ 'SPOC EMAIL': element.spocEmail,
241
+ 'SPOC CONTACT': element.spocContact,
242
+ 'DOWNTIME': element.downTime,
243
+ 'STATUS DETAIL': element.statusDetail,
244
+ } );
245
+ } );
246
+ await download( exportdata, res );
247
+ return;
248
+ }
249
+ if ( result.length > 0 ) {
250
+ res.sendSuccess( {
251
+ count: count.length,
252
+ result: result,
253
+ } );
254
+ } else {
255
+ res.sendError( 'no data', 204 );
256
+ }
257
+ } catch ( error ) {
258
+ logger.error( { error: error, function: 'infraIssuesTable' } );
259
+ return res.sendError( error, 500 );
260
+ }
261
+ }
262
+ export async function InstallationIssuesTable( req, res ) {
263
+ try {
264
+ let query = [
265
+ {
266
+ $match: {
267
+ $and: [
268
+ { issueType: 'installation' },
269
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
270
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
271
+ // { createdAt: { $lte: new Date( req.body.toDate ) } },
272
+ ],
273
+ },
274
+ },
275
+ {
276
+ $project: {
277
+ createdAt: 1,
278
+ clientName: '$basicDetails.clientName',
279
+ storeId: '$basicDetails.storeId',
280
+ storeName: '$basicDetails.storeName',
281
+ status: '$basicDetails.status',
282
+ },
283
+ },
284
+ ];
285
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
286
+ query.push( {
287
+ $match: {
288
+ $or: [
289
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
290
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
291
+ { clientName: { $regex: req.body.searchValue, $options: 'i' } },
292
+ { status: { $regex: req.body.searchValue, $options: 'i' } },
293
+ ],
294
+ },
295
+ } );
296
+ }
297
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
298
+ query.push( {
299
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
300
+ } );
301
+ }
302
+ let count = await aggregateTangoTicket( query );
303
+ if ( req.body.limit && req.body.offset && !req.body.export ) {
304
+ query.push(
305
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
306
+ { $limit: Number( req.body.limit ) },
307
+ );
308
+ }
309
+ let storesList = await aggregateTangoTicket( query );
310
+ if ( storesList.length == 0 ) {
311
+ return res.sendError( 'no data', 204 );
312
+ }
313
+ if ( req.body.export ) {
314
+ const exportdata = [];
315
+ infrastoreList.forEach( ( element ) => {
316
+ exportdata.push( {
317
+ 'CLIENT NAME': element.clientName,
318
+ 'STORE ID': element.storeId,
319
+ 'STORE NAME': element.storeName,
320
+ 'STATUS': element.status,
321
+ } );
322
+ } );
323
+ await download( exportdata, res );
324
+ return;
325
+ }
171
326
  res.sendSuccess( {
172
327
  count: count.length,
173
- result: result,
328
+ result: storesList,
174
329
  } );
175
330
  } catch ( error ) {
176
- logger.error( { error: error, function: 'infraIssuesTable' } );
331
+ logger.error( { error: error, function: 'InstallationIssuesTable' } );
177
332
  return res.sendError( error, 500 );
178
333
  }
179
334
  }
180
335
 
181
-
182
336
  export async function hourWiseDownClients( req, res ) {
183
337
  try {
184
338
  let inputData = req.body;
@@ -118,7 +118,8 @@ export async function AlertTicketReply( req, res ) {
118
118
  req.body.infraActivity.push( {
119
119
  actionType: 'statusCheckReply',
120
120
  actionBy: 'Tango',
121
-
121
+ statusCheckReply: req.body.statusCheckReply,
122
+ hibernationDays: req.body.hibernationDays,
122
123
  } );
123
124
  } catch ( error ) {
124
125
  logger.error( { error: error, function: 'AlertTicketReply' } );
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { findOneTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
3
- import { logger } from 'tango-app-api-middleware';
3
+ import { logger, download } from 'tango-app-api-middleware';
4
4
  import { findOneUser } from '../services/user.service.js';
5
5
  import { aggregateStore } from '../services/store.service.js';
6
6
 
@@ -26,11 +26,34 @@ export async function userTicketList( req, res ) {
26
26
  try {
27
27
  let query = [ {
28
28
  $match: {
29
- 'status': req.body.status,
30
- 'infraTicketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ),
29
+ $and: [
30
+ { 'status': req.body.status },
31
+ { 'infraTicketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
32
+ ],
31
33
  },
32
- },
33
- {
34
+ } ];
35
+
36
+ if ( req.body.status != 'closed' ) {
37
+ query.push( {
38
+ $match: {
39
+ $and: [
40
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
41
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
42
+ ],
43
+ },
44
+ } );
45
+ } else {
46
+ query.push( {
47
+ $match: {
48
+ $and: [
49
+ { createdAt: { $gte: new Date() } },
50
+ ],
51
+ },
52
+ } );
53
+ }
54
+
55
+
56
+ query.push( {
34
57
  $project: {
35
58
  storeId: '$basicDetails.storeId',
36
59
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
@@ -64,7 +87,7 @@ export async function userTicketList( req, res ) {
64
87
  ticketType: 1,
65
88
  infraIssue: '$primaryIssue.reasons.primaryIssue',
66
89
  },
67
- } ];
90
+ } );
68
91
  let ticketList = await aggregateTangoTicket( query );
69
92
  if ( ticketList.length ) {
70
93
  res.sendSuccess( {
@@ -108,8 +131,12 @@ export async function workHistory( req, res ) {
108
131
  try {
109
132
  let query = [ {
110
133
  $match: {
111
- 'status': 'closed',
112
- 'infraTicketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ),
134
+ $and: [
135
+ { 'status': 'closed' },
136
+ { 'infraTicketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
137
+ { createdAt: { $gte: new Date( req.body.fromDate ) } },
138
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
139
+ ],
113
140
  },
114
141
  },
115
142
  {
@@ -120,6 +147,7 @@ export async function workHistory( req, res ) {
120
147
  clientName: '$basicDetails.clientName',
121
148
  issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
122
149
  issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
150
+ issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$infraTicketDetails.issueIdentifiedDate' } },
123
151
  ticketId: 1,
124
152
  issueStatus: '$infraTicketDetails.issueStatus',
125
153
  ticketType: '$infraTicketDetails.ticketType',
@@ -148,6 +176,7 @@ export async function workHistory( req, res ) {
148
176
  clientId: 1,
149
177
  clientName: 1,
150
178
  issueDate: 1,
179
+ issueIdentifiedDate: 1,
151
180
  issueClosedDate: 1,
152
181
  ticketId: 1,
153
182
  issueStatus: 1,
@@ -155,6 +184,25 @@ export async function workHistory( req, res ) {
155
184
  infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
156
185
  },
157
186
  } ];
187
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
188
+ query.push( {
189
+ $match: {
190
+ $or: [
191
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
192
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
193
+ { clientId: { $regex: req.body.searchValue, $options: 'i' } },
194
+ { clientName: { $regex: req.body.searchValue, $options: 'i' } },
195
+ { ticketId: { $regex: req.body.searchValue, $options: 'i' } },
196
+ { infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
197
+ ],
198
+ },
199
+ } );
200
+ }
201
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
202
+ query.push( {
203
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
204
+ } );
205
+ }
158
206
  let count = await aggregateTangoTicket( query );
159
207
  if ( req.body.limit && req.body.offset && !req.body.export ) {
160
208
  query.push(
@@ -163,6 +211,28 @@ export async function workHistory( req, res ) {
163
211
  );
164
212
  }
165
213
  let result = await aggregateTangoTicket( query );
214
+ if ( req.body.export ) {
215
+ const exportdata = [];
216
+ result.forEach( ( element ) => {
217
+ exportdata.push( {
218
+ 'CREATED ON': element.createdAt,
219
+ 'TICKET ID': element.ticketId,
220
+ 'STORE ID': element.storeId,
221
+ 'STORE NAME': element.storeName,
222
+ 'CLIENT ID': element.clientId,
223
+ 'CLIENT NAME': element.clientName,
224
+ 'CREATED STATUS': element.status,
225
+ 'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
226
+ 'CLOSED ON': element.issueClosedDate,
227
+ 'STATUS': element.status,
228
+ } );
229
+ } );
230
+ await download( exportdata, res );
231
+ return;
232
+ }
233
+ if ( result.length == 0 ) {
234
+ return res.sendError( 'no data', 204 );
235
+ }
166
236
  res.sendSuccess( {
167
237
  count: count.length,
168
238
  result: result,
@@ -179,7 +249,10 @@ export async function storeInfraList( req, res ) {
179
249
  let query = [
180
250
  {
181
251
  $match: {
182
- clientId: { $in: req.body.clientId },
252
+ $and: [
253
+ { clientId: { $in: req.body.clientId } },
254
+ { createdAt: { $lte: new Date( req.body.toDate ) } },
255
+ ],
183
256
  },
184
257
  },
185
258
  {
@@ -205,12 +278,27 @@ export async function storeInfraList( req, res ) {
205
278
  city: { $first: '$storeProfile.city' },
206
279
  state: { $first: '$storeProfile.state' },
207
280
  country: { $first: '$storeProfile.country' },
208
- spocName: { $first: { $ifNull: [ '$spocDetails.name', '' ] } },
281
+ spocEmail: { $first: { $ifNull: [ '$spocDetails.email', '' ] } },
209
282
  spocContact: { $first: { $ifNull: [ '$spocDetails.contact', '' ] } },
210
283
  },
211
284
  },
212
285
  ];
213
286
 
287
+ if ( req.body.searchValue && req.body.searchValue !== '' ) {
288
+ query.push( {
289
+ $match: {
290
+ $or: [
291
+ { storeId: { $regex: req.body.searchValue, $options: 'i' } },
292
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
293
+ ],
294
+ },
295
+ } );
296
+ }
297
+ if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
298
+ query.push( {
299
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
300
+ } );
301
+ }
214
302
  let count = await aggregateStore( query );
215
303
  if ( req.body.limit && req.body.offset && !req.body.export ) {
216
304
  query.push(
@@ -219,6 +307,9 @@ export async function storeInfraList( req, res ) {
219
307
  );
220
308
  }
221
309
  let storesList = await aggregateStore( query );
310
+ if ( storesList.length == 0 ) {
311
+ return res.sendError( 'no data', 204 );
312
+ }
222
313
  let infrastoreList = [];
223
314
  for ( let store of storesList ) {
224
315
  store.downTime = 'NA';
@@ -228,15 +319,33 @@ export async function storeInfraList( req, res ) {
228
319
  } else {
229
320
  if ( store.status == 'active' ) {
230
321
  store.status = 'Live';
231
- store.statusDetail='Connected';
322
+ store.statusDetail = 'Connected';
232
323
  } else {
233
- store.statusDetail='Disconnected';
324
+ store.statusDetail = 'Disconnected';
234
325
  store.status = 'Deactivated';
235
326
  }
236
327
  }
237
-
238
328
  infrastoreList.push( store );
239
329
  }
330
+ if ( req.body.export ) {
331
+ const exportdata = [];
332
+ infrastoreList.forEach( ( element ) => {
333
+ exportdata.push( {
334
+ 'STORE ID': element.storeId,
335
+ 'STORE NAME': element.storeName,
336
+ 'STATUS': element.status,
337
+ 'CITY': element.city,
338
+ 'STATE': element.state,
339
+ 'COUNTRY': element.country,
340
+ 'SPOC EMAIL': element.spocEmail,
341
+ 'SPOC CONTACT': element.spocContact,
342
+ 'DOWNTIME': element.downTime,
343
+ 'STATUS DETAIL': element.statusDetail,
344
+ } );
345
+ } );
346
+ await download( exportdata, res );
347
+ return;
348
+ }
240
349
  res.sendSuccess( {
241
350
  count: count.length,
242
351
  result: infrastoreList,
@@ -1,15 +1,15 @@
1
1
 
2
2
  import express from 'express';
3
-
4
-
5
- import { infraCard, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
3
+ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
4
+ import { infraCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
6
5
 
7
6
  export const clientInfraRouter = express.Router();
8
7
 
9
8
 
10
- clientInfraRouter.post( '/infraCard', infraCard );
11
- clientInfraRouter.post( '/infraIssuesTable', infraIssuesTable );
12
- clientInfraRouter.post( '/hourWiseDownClients', hourWiseDownClients );
13
- clientInfraRouter.post( '/hourWiseDownstores', hourWiseDownstores );
9
+ clientInfraRouter.post( '/infraCard', isAllowedSessionHandler, infraCard );
10
+ clientInfraRouter.post( '/infraIssuesTable', isAllowedSessionHandler, infraIssuesTable );
11
+ clientInfraRouter.post( '/InstallationIssuesTable', isAllowedSessionHandler, InstallationIssuesTable );
12
+ clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, hourWiseDownClients );
13
+ clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, hourWiseDownstores );
14
14
 
15
15
 
@@ -1,5 +1,6 @@
1
1
 
2
2
  import express from 'express';
3
+ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
3
4
  import { validateDetails, validateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
4
5
  import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply } from '../controllers/infra.controllers.js';
5
6
 
@@ -7,12 +8,12 @@ import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReas
7
8
  export const infraRouter = express.Router();
8
9
 
9
10
  infraRouter.post( '/createTicket', validateDetails, validateTicket, createTicket );
10
- infraRouter.post( '/updateStatus', ticketExists, updateStatus );
11
+ infraRouter.post( '/updateStatus', isAllowedSessionHandler, ticketExists, updateStatus );
11
12
  infraRouter.post( '/createReason', createReason );
12
- infraRouter.get( '/PrimaryReasons', PrimaryReasons );
13
- infraRouter.post( '/secondaryReason', secondaryReason );
14
- infraRouter.post( '/updateTicketIssue', ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
15
- infraRouter.post( '/viewTicket', ticketExists, viewTicket );
16
- infraRouter.post( '/AlertTicketReply', ticketExists, AlertTicketReply );
13
+ infraRouter.get( '/PrimaryReasons', isAllowedSessionHandler, PrimaryReasons );
14
+ infraRouter.post( '/secondaryReason', isAllowedSessionHandler, secondaryReason );
15
+ infraRouter.post( '/updateTicketIssue', isAllowedSessionHandler, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
16
+ infraRouter.post( '/viewTicket', isAllowedSessionHandler, ticketExists, viewTicket );
17
+ infraRouter.post( '/AlertTicketReply', isAllowedSessionHandler, ticketExists, AlertTicketReply );
17
18
 
18
19
 
@@ -1,11 +1,12 @@
1
1
 
2
2
  import express from 'express';
3
+ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
3
4
  import { storeTicketList, storeTicketcard, edgeAppLogTable, viewedgeAppLog } from '../controllers/storeInfra.controlller.js';
4
5
  export const storeInfraRouter = express.Router();
5
6
 
6
- storeInfraRouter.post( '/storeTicketList', storeTicketList );
7
- storeInfraRouter.post( '/storeTicketcard', storeTicketcard );
8
- storeInfraRouter.post( '/edgeAppLogTable', edgeAppLogTable );
9
- storeInfraRouter.post( '/viewedgeAppLog', viewedgeAppLog );
7
+ storeInfraRouter.post( '/storeTicketList', isAllowedSessionHandler, storeTicketList );
8
+ storeInfraRouter.post( '/storeTicketcard', isAllowedSessionHandler, storeTicketcard );
9
+ storeInfraRouter.post( '/edgeAppLogTable', isAllowedSessionHandler, edgeAppLogTable );
10
+ storeInfraRouter.post( '/viewedgeAppLog', isAllowedSessionHandler, viewedgeAppLog );
10
11
 
11
12
 
@@ -1,13 +1,14 @@
1
1
  import express from 'express';
2
+ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
2
3
  import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
3
4
 
4
5
  export const userInfraRouter = express.Router();
5
6
 
6
7
 
7
- userInfraRouter.post( '/userTakeTicket', userTakeTicket );
8
- userInfraRouter.post( '/userTicketList', userTicketList );
9
- userInfraRouter.post( '/basicDetails', basicDetails );
10
- userInfraRouter.post( '/workHistory', workHistory );
11
- userInfraRouter.post( '/storeInfraList', storeInfraList );
8
+ userInfraRouter.post( '/userTakeTicket', isAllowedSessionHandler, userTakeTicket );
9
+ userInfraRouter.post( '/userTicketList', isAllowedSessionHandler, userTicketList );
10
+ userInfraRouter.post( '/basicDetails', isAllowedSessionHandler, basicDetails );
11
+ userInfraRouter.post( '/workHistory', isAllowedSessionHandler, workHistory );
12
+ userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, storeInfraList );
12
13
 
13
14
 
@@ -34,14 +34,16 @@ export async function validateDetails( req, res, next ) {
34
34
 
35
35
  export async function validateTicket( req, res, next ) {
36
36
  try {
37
- let Ticket = await findOneTangoTicket(
38
- {
39
- 'basicDetails.storeId': req.body.basicDetails.storeId,
40
- 'issueDate': new Date( req.body.Date ),
41
- },
42
- );
43
- if ( Ticket ) {
44
- return res.sendSuccess( 'Ticket Already Exists for the day' );
37
+ if ( req.body.issueType == 'infra' ) {
38
+ let Ticket = await findOneTangoTicket(
39
+ {
40
+ 'basicDetails.storeId': req.body.basicDetails.storeId,
41
+ 'issueDate': new Date( req.body.Date ),
42
+ },
43
+ );
44
+ if ( Ticket ) {
45
+ return res.sendSuccess( 'Ticket Already Exists for the day' );
46
+ }
45
47
  }
46
48
  next();
47
49
  } catch ( error ) {