tango-app-api-store-zone 3.3.1-beta.22 → 3.3.1-beta.24
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
|
@@ -592,7 +592,6 @@ export const customTagListv3 = async ( req, res ) => {
|
|
|
592
592
|
] );
|
|
593
593
|
|
|
594
594
|
|
|
595
|
-
console.log( '🚀 ~ customTagListv3 ~ taggingDetails:', zonefinalTags );
|
|
596
595
|
return res.sendSuccess( zonefinalTags );
|
|
597
596
|
}
|
|
598
597
|
|
|
@@ -1302,37 +1301,40 @@ export const updatezoneTagging = async ( req, res ) => {
|
|
|
1302
1301
|
|
|
1303
1302
|
export const updateOldData = async ( req, res ) => {
|
|
1304
1303
|
try {
|
|
1305
|
-
let tagDetails = await taggingService.find( {}, { storeId: 1 } );
|
|
1304
|
+
let tagDetails = await taggingService.find( { clientId: req.body.clientId, tagName: req.body.tagName }, { storeId: 1 } );
|
|
1305
|
+
|
|
1306
1306
|
if ( tagDetails.length ) {
|
|
1307
1307
|
for ( let [ index, item ] of tagDetails.entries() ) {
|
|
1308
1308
|
req.body.storeId = item.storeId;
|
|
1309
1309
|
let camDetails = await getCamTaggingDetails( req, res );
|
|
1310
|
-
if (
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1310
|
+
if ( camDetails ) {
|
|
1311
|
+
const response = await axios.post( JSON.parse( process.env.URL ).zoneTaggingLamdaUrl, camDetails );
|
|
1312
|
+
|
|
1313
|
+
if ( response?.data?.status && response?.data?.status == 'success' ) {
|
|
1314
|
+
let fileData = {
|
|
1315
|
+
Key: `${req.body.storeId}/zonetagging/`,
|
|
1316
|
+
fileName: `${req.body.storeId}_zonetagging.json`,
|
|
1317
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
1318
|
+
body: JSON.stringify( camDetails ),
|
|
1319
|
+
ContentType: 'application/json',
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
let upload = await fileUpload( fileData );
|
|
1323
|
+
if ( !upload.Key ) {
|
|
1324
|
+
logger.error( { message: `JSON Upload Error`, store: item.storeId } );
|
|
1325
|
+
}
|
|
1326
|
+
if ( index == 0 ) {
|
|
1327
|
+
res.sendSuccess( 'Zone Updated Successfully' );
|
|
1328
|
+
}
|
|
1329
|
+
} else {
|
|
1330
|
+
logger.error( { message: 'no data', store: item.storeId } );
|
|
1331
|
+
return res.sendError( 'something went wrong', 500 );
|
|
1328
1332
|
}
|
|
1329
|
-
} else {
|
|
1330
|
-
logger.error( { message: 'no data', store: item.storeId } );
|
|
1331
|
-
// return res.sendError( 'something went wrong', 500 );
|
|
1332
1333
|
}
|
|
1333
1334
|
}
|
|
1334
1335
|
}
|
|
1335
1336
|
} catch ( e ) {
|
|
1337
|
+
console.log( '🚀 ~ updateOldData ~ e:', e );
|
|
1336
1338
|
logger.error( { error: e, function: 'updateOldData' } );
|
|
1337
1339
|
return res.sendError( e, 500 );
|
|
1338
1340
|
}
|
|
@@ -1501,7 +1503,11 @@ export const getZoneTaggingDetails = async ( req, res ) => {
|
|
|
1501
1503
|
const matchStage = {
|
|
1502
1504
|
clientId,
|
|
1503
1505
|
};
|
|
1504
|
-
|
|
1506
|
+
let customTags = await customZoneTagService.findOne( { clientId: clientId } );
|
|
1507
|
+
const alltotalGroupCount = await customzonegrouping.count( { clientId } );
|
|
1508
|
+
if ( !customTags ) {
|
|
1509
|
+
return res.sendSuccess( { result: [], totalGroupCount: alltotalGroupCount } );
|
|
1510
|
+
}
|
|
1505
1511
|
const searchStage = searchValue ?
|
|
1506
1512
|
{
|
|
1507
1513
|
$or: [
|
|
@@ -1573,6 +1579,9 @@ export const getZoneTaggingDetails = async ( req, res ) => {
|
|
|
1573
1579
|
const [ result ] = await customZoneTagService.aggregate( pipeline );
|
|
1574
1580
|
|
|
1575
1581
|
const totalCount = result.totalCount[0]?.count || 0;
|
|
1582
|
+
if ( totalCount === 0 ) {
|
|
1583
|
+
return res.sendError( 'No data', 204 );
|
|
1584
|
+
}
|
|
1576
1585
|
const zoneList = result.filteredData;
|
|
1577
1586
|
|
|
1578
1587
|
// Get total count of groups for tabs (actual count, not filtered by search)
|
|
@@ -2106,8 +2115,14 @@ export const deleteZoneCustomTag = async ( req, res ) => {
|
|
|
2106
2115
|
if ( !zoneTagDetails || zoneTagDetails?.length == 0 ) {
|
|
2107
2116
|
return res.sendError( 'No data found', 400 );
|
|
2108
2117
|
}
|
|
2109
|
-
|
|
2118
|
+
updateOldData( req, res );
|
|
2110
2119
|
await customZoneTagService.deleteOne( { clientId, tagName } );
|
|
2120
|
+
await taggingService.deleteMany(
|
|
2121
|
+
{
|
|
2122
|
+
clientId,
|
|
2123
|
+
tagName: { $in: tagName },
|
|
2124
|
+
},
|
|
2125
|
+
);
|
|
2111
2126
|
const logObj = {
|
|
2112
2127
|
clientId: req.body?.clientId,
|
|
2113
2128
|
userName: req.user?.userName,
|
|
@@ -2120,7 +2135,7 @@ export const deleteZoneCustomTag = async ( req, res ) => {
|
|
|
2120
2135
|
showTo: [ 'client', 'tango' ],
|
|
2121
2136
|
};
|
|
2122
2137
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
2123
|
-
return res.sendSuccess( 'ZoneName Deleted Successfully' );
|
|
2138
|
+
// return res.sendSuccess( 'ZoneName Deleted Successfully' );
|
|
2124
2139
|
} catch ( e ) {
|
|
2125
2140
|
logger.error( { error: e, function: 'deleteZoneCustomTag' } );
|
|
2126
2141
|
return res.sendError( e, 500 );
|
|
@@ -2145,6 +2160,12 @@ export const getZoneGroupDetails = async ( req, res ) => {
|
|
|
2145
2160
|
return res.sendError( 'clientId is required', 400 );
|
|
2146
2161
|
}
|
|
2147
2162
|
|
|
2163
|
+
|
|
2164
|
+
let groupData = await customzonegrouping.findOne( { clientId: clientId } );
|
|
2165
|
+
if ( !groupData ) {
|
|
2166
|
+
return res.sendSuccess( { result: [] } );
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2148
2169
|
const searchMatch = searchValue ?
|
|
2149
2170
|
{ groupName: { $regex: searchValue, $options: 'i' } } :
|
|
2150
2171
|
null;
|
|
@@ -2232,7 +2253,9 @@ export const getZoneGroupDetails = async ( req, res ) => {
|
|
|
2232
2253
|
const zoneGroupList = result.data || [];
|
|
2233
2254
|
|
|
2234
2255
|
const totalCount = result.totalCount[0]?.count || 0;
|
|
2235
|
-
|
|
2256
|
+
if ( totalCount === 0 ) {
|
|
2257
|
+
return res.sendError( 'No data', 204 );
|
|
2258
|
+
}
|
|
2236
2259
|
// Get total count of zones for tabs (actual count, not filtered by search)
|
|
2237
2260
|
const totalZoneCount = await customZoneTagService.count( { clientId } );
|
|
2238
2261
|
|
|
@@ -73,6 +73,39 @@ export async function bulkZoneExists( req, res, next ) {
|
|
|
73
73
|
// }
|
|
74
74
|
// }
|
|
75
75
|
|
|
76
|
+
// Validate groupNames for case-insensitive duplicates
|
|
77
|
+
const groupNameList = zonesArray
|
|
78
|
+
.filter( ( zone ) => zone.groupName && zone.groupName !== '' && zone.groupName !== null )
|
|
79
|
+
.map( ( zone ) => zone.groupName );
|
|
80
|
+
|
|
81
|
+
if ( groupNameList.length > 0 ) {
|
|
82
|
+
// Group groupNames by their lowercase version
|
|
83
|
+
const groupNameMap = new Map();
|
|
84
|
+
groupNameList.forEach( ( name ) => {
|
|
85
|
+
const lowerName = name.toLowerCase();
|
|
86
|
+
if ( !groupNameMap.has( lowerName ) ) {
|
|
87
|
+
groupNameMap.set( lowerName, new Set() );
|
|
88
|
+
}
|
|
89
|
+
groupNameMap.get( lowerName ).add( name );
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
// Check if any lowercase name has multiple different cases
|
|
93
|
+
const caseMismatches = [];
|
|
94
|
+
groupNameMap.forEach( ( originalNames, lowerName ) => {
|
|
95
|
+
if ( originalNames.size > 1 ) {
|
|
96
|
+
// Same lowercase name appears with different cases
|
|
97
|
+
caseMismatches.push( {
|
|
98
|
+
lowerName: lowerName,
|
|
99
|
+
cases: Array.from( originalNames ),
|
|
100
|
+
} );
|
|
101
|
+
}
|
|
102
|
+
} );
|
|
103
|
+
|
|
104
|
+
if ( caseMismatches.length > 0 ) {
|
|
105
|
+
return res.sendError( 'Duplicate group names with different cases are not allowed.', 400 );
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
76
109
|
// Attach clientId to req for use in controller
|
|
77
110
|
req.bulkZoneClientId = clientId;
|
|
78
111
|
next();
|