tango-app-api-client 3.0.29-dev → 3.0.30-dev
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,8 +1,8 @@
|
|
|
1
1
|
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, getClientCount, insert, update, findOneClient } from '../service/client.service.js';
|
|
2
2
|
import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, appConfig, sendEmailWithSES } from 'tango-app-api-middleware';
|
|
3
|
-
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById } from '../service/user.service.js';
|
|
4
|
-
import { aggregateStore, countDocumentsStore } from '../service/store.service.js';
|
|
5
|
-
import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
|
|
3
|
+
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
|
|
4
|
+
import { aggregateStore, countDocumentsStore, updateManyStore } from '../service/store.service.js';
|
|
5
|
+
import { aggregateCamera, countDocumentsCamera, updateManyCamera } from '../service/camera.service.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
8
8
|
import { aggregateUserAssignedStore } from '../service/userAssignedStore.service.js';
|
|
@@ -11,6 +11,8 @@ import { join } from 'path';
|
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
12
12
|
import handlebars from 'handlebars';
|
|
13
13
|
import { countDocumentsGroup } from '../service/group.service.js';
|
|
14
|
+
import { deleteOneAuthentication } from '../service/authentication.service.js';
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
export async function create( req, res ) {
|
|
16
18
|
try {
|
|
@@ -44,7 +46,7 @@ export async function create( req, res ) {
|
|
|
44
46
|
'planDetails.totalCamera': leadRecord?.planDetails?.totalCamera,
|
|
45
47
|
'planDetails.subscriptionPeriod': leadRecord?.planDetails?.subscriptionPeriod,
|
|
46
48
|
'planDetails.subscriptionType': leadRecord?.planDetails?.subscriptionType,
|
|
47
|
-
'planDetails.paymentStatus': leadRecord?.planDetails?.
|
|
49
|
+
'planDetails.paymentStatus': leadRecord?.planDetails?.subscriptionType === 'free' ? 'free' : 'trial',
|
|
48
50
|
'planDetails.product': product,
|
|
49
51
|
'reportConfigs.reportName': generatedName,
|
|
50
52
|
'auditConfigs.queueName': generatedName,
|
|
@@ -52,6 +54,7 @@ export async function create( req, res ) {
|
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
const insertClient = await insert( record );
|
|
57
|
+
|
|
55
58
|
if ( insertClient ) {
|
|
56
59
|
const userRecord = {
|
|
57
60
|
role: 'superadmin',
|
|
@@ -59,6 +62,7 @@ export async function create( req, res ) {
|
|
|
59
62
|
permission: getPermission?.permission,
|
|
60
63
|
clientId: String( tangoId ),
|
|
61
64
|
};
|
|
65
|
+
await deleteOneAuthentication( { user: user?._id, type: 'retail' } );
|
|
62
66
|
await findOneAndUpdateUser( userQuery, userRecord );
|
|
63
67
|
await createAuditQueue( generatedName );
|
|
64
68
|
return res.sendSuccess( { result: { clientId: String( tangoId ) } } );
|
|
@@ -255,7 +259,7 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
255
259
|
trialClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'trial' ] }, 1, 0 ] },
|
|
256
260
|
freeClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'free' ] }, 1, 0 ] },
|
|
257
261
|
holdClient: { $cond: [ { $eq: [ '$status', 'hold' ] }, 1, 0 ] },
|
|
258
|
-
suspendClient: { $cond: [ { $eq: [ '$status', '
|
|
262
|
+
suspendClient: { $cond: [ { $eq: [ '$status', 'suspended' ] }, 1, 0 ] },
|
|
259
263
|
deactiveClient: { $cond: [ { $eq: [ '$status', 'deactive' ] }, 1, 0 ] },
|
|
260
264
|
},
|
|
261
265
|
},
|
|
@@ -335,6 +339,27 @@ export async function updateBrandInfo( req, res ) {
|
|
|
335
339
|
clientType: req.body?.clientType, registeredAddress: req.body?.registeredAddress, headQuarters: req.body?.headQuarters,
|
|
336
340
|
website: req.body?.website, status: req.body?.status, logo: req.files?.logo ? `brandLogo.${req.files.logo.name.split( '.' )[1]}` : undefined,
|
|
337
341
|
} );
|
|
342
|
+
|
|
343
|
+
if ( req.body?.status === 'active' ) {
|
|
344
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'active' } );
|
|
345
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: true } );
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if ( req.body?.status === 'suspended' ) {
|
|
349
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'suspend' } );
|
|
350
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if ( req.body?.status === 'hold' ) {
|
|
354
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if ( req.body?.status === 'deactive' ) {
|
|
358
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'deactive' } );
|
|
359
|
+
await updateManyCamera( { clientId: req.params?.id }, { isUp: false, isActivated: false } );
|
|
360
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
361
|
+
}
|
|
362
|
+
|
|
338
363
|
if ( updateAck ) {
|
|
339
364
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
340
365
|
}
|
|
@@ -19,3 +19,7 @@ export async function findOneAndUpdateUser( query, record ) {
|
|
|
19
19
|
export function getUserNameEmailById( objectId ) {
|
|
20
20
|
return userModel.findOne( { _id: objectId }, { userName: 1, email: 1, _id: 0 } );
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
export function updateManyUser( query, record ) {
|
|
24
|
+
return userModel.updateMany( query, { $set: record } );
|
|
25
|
+
}
|