tango-app-api-store-builder 1.0.0-beta-71 → 1.0.0-beta-72

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-store-builder",
3
- "version": "1.0.0-beta-71",
3
+ "version": "1.0.0-beta-72",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "jszip": "^3.10.1",
25
25
  "mongodb": "^6.12.0",
26
26
  "nodemon": "^3.1.9",
27
- "tango-api-schema": "^2.2.77",
27
+ "tango-api-schema": "^2.2.94",
28
28
  "tango-app-api-middleware": "^3.1.48",
29
29
  "winston": "^3.17.0",
30
30
  "winston-daily-rotate-file": "^5.0.0",
@@ -1928,6 +1928,8 @@ export async function updatelayoutFeedback( req, res ) {
1928
1928
  },
1929
1929
  ];
1930
1930
 
1931
+ await storeBuilderService.updateOne( { _id: floorDoc._id }, { layoutPolygon: layoutPolygon } );
1932
+
1931
1933
  console.log( layoutPolygon, floorDoc._id );
1932
1934
  }
1933
1935
  }
@@ -1958,3 +1960,16 @@ export async function extractZipFileNames( req, res ) {
1958
1960
  return res.sendError( e.message || 'Internal Server Error', 500 );
1959
1961
  }
1960
1962
  }
1963
+
1964
+ export async function updateFixtureFeedback( req, res ) {
1965
+ try {
1966
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1967
+ return res.sendError( 'Unauthorized', 401 );
1968
+ }
1969
+
1970
+
1971
+ } catch ( e ) {
1972
+ logger.error( { functionName: 'updatelayoutFeedback', error: e } );
1973
+ return res.sendError( e.message || 'Internal Server Error', 500 );
1974
+ }
1975
+ }
@@ -14,7 +14,7 @@ import * as planoComplianceService from '../service/planoCompliance.service.js';
14
14
  import * as planoTaskComplianceService from '../service/planoTask.service.js';
15
15
  import * as planoQrConversionRequestService from '../service/planoQrConversionRequest.service.js';
16
16
  import * as fixtureConfigService from '../service/fixtureConfig.service.js';
17
- import * as planoStaticBrandCategoriesService from '../service/planoStaticBrandCategories.service.js';
17
+ import * as planoStaticData from '../service/planoStaticData.service.js';
18
18
 
19
19
 
20
20
  import path from 'path';
@@ -2437,6 +2437,61 @@ export const fixtureQrUpdate = async ( req, res ) => {
2437
2437
  }
2438
2438
  };
2439
2439
 
2440
+ export const fixtureQrUpdatev1 = async ( req, res ) => {
2441
+ try {
2442
+ const { fixtureId, date, productQr } = req.body;
2443
+
2444
+ const fixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) }, { _id: 1 } );
2445
+
2446
+ if ( !fixture ) {
2447
+ return res.sendError( { message: 'Invalid fixture Id' }, 400 );
2448
+ }
2449
+
2450
+ const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
2451
+
2452
+ let productIndex = 0;
2453
+
2454
+ const complianceData = fixtureShelves.map( ( shelf ) => {
2455
+ const shelfObj = shelf.toObject();
2456
+ const products = shelfObj.shelfCapacity ?
2457
+ Array.from( { length: shelfObj.shelfCapacity }, () => ( {
2458
+ category: shelfObj.sectionName,
2459
+ productIndex: productIndex++,
2460
+ status: 'missing',
2461
+ } ) ) :
2462
+ [];
2463
+
2464
+ return { ...shelfObj, products };
2465
+ } );
2466
+
2467
+ const productMap = new Map();
2468
+ productQr.forEach( ( productCv, i ) => {
2469
+ if ( productCv.parent_brand ) {
2470
+ productMap.set( i, productCv );
2471
+ }
2472
+ } );
2473
+
2474
+ complianceData.forEach( ( shelf ) => {
2475
+ shelf.products.forEach( ( product ) => {
2476
+ const matchedProduct = productMap.get( product.productIndex );
2477
+ if ( matchedProduct && product.category === matchedProduct.parent_brand ) {
2478
+ Object.assign( product, { status: 'proper', barcode: matchedProduct.barcode } );
2479
+ }
2480
+ } );
2481
+ } );
2482
+
2483
+ const currentDate = new Date( date );
2484
+
2485
+ await planoQrConversionRequestService.updateOne( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), date: currentDate }, { status: 'data-received', receivedQr: productQr, processedData: complianceData } );
2486
+
2487
+ res.sendSuccess( complianceData );
2488
+ } catch ( error ) {
2489
+ logger.error( 'fixtureQrUpdate =>', error );
2490
+ return res.sendError( { message: 'Internal Server Error' }, 500 );
2491
+ }
2492
+ };
2493
+
2494
+
2440
2495
  export const updateDetailedDistance = async ( req, res ) => {
2441
2496
  try {
2442
2497
  const { floorId, elementNumber, elementType, detailedDistance } = req.body;
@@ -2725,7 +2780,7 @@ export const getFixtureBrands = async ( req, res ) => {
2725
2780
 
2726
2781
  // const [ data ] = sections;
2727
2782
 
2728
- const brandCategories = await planoStaticBrandCategoriesService.findOne( { } );
2783
+ const brandCategories = await planoStaticData.findOne( { type: 'brandCategory' } );
2729
2784
 
2730
2785
  return res.sendSuccess( brandCategories.toObject().data );
2731
2786
  } catch ( error ) {
@@ -9,6 +9,7 @@ import * as planoTaskService from '../service/planoTask.service.js';
9
9
  import * as planoService from '../service/planogram.service.js';
10
10
  import * as checklistService from '../service/checklist.service.js';
11
11
  import timeZone from 'dayjs/plugin/timezone.js';
12
+ import * as planoProductService from '../service/planoProduct.service.js';
12
13
  dayjs.extend( timeZone );
13
14
 
14
15
  async function createUser( data ) {
@@ -110,6 +111,32 @@ export async function createTask( req, res ) {
110
111
  if ( !taskDetails.length ) {
111
112
  return res.sendError( 'No data found', 204 );
112
113
  }
114
+ let userEmailList = [ ...new Set( req.body.stores.map( ( ele ) => ele.email ) ) ];
115
+ for ( let mail of userEmailList ) {
116
+ let query = [
117
+ {
118
+ $addFields: {
119
+ emailLower: { $toLower: '$email' },
120
+ },
121
+ },
122
+ {
123
+ $match: {
124
+ clientId: req.body.clientId,
125
+ emailLower: mail.toLowerCase(),
126
+ },
127
+ },
128
+ ];
129
+ userDetails = await userService.aggregate( query );
130
+ if ( !userDetails.length ) {
131
+ let userData = {
132
+ clientId: req.body.clientId,
133
+ mobileNumber: '',
134
+ email: mail,
135
+ userName: mail.split( '@' )[0],
136
+ };
137
+ await createUser( userData );
138
+ }
139
+ }
113
140
  let endDate = dayjs().add( req.body.days, 'day' ).format( 'YYYY-MM-DD' );
114
141
  await Promise.all( taskDetails.map( async ( task ) => {
115
142
  let data = {
@@ -183,22 +210,22 @@ export async function createTask( req, res ) {
183
210
  {
184
211
  $match: {
185
212
  clientId: req.body.clientId,
186
- email: getUserEmail.email,
213
+ email: getUserEmail.email.toLowerCase(),
187
214
  },
188
215
  },
189
216
  ];
190
217
  userDetails = await userService.aggregate( query );
191
- if ( !userDetails.length ) {
192
- let userData = {
193
- clientId: req.body.clientId,
194
- mobileNumber: '',
195
- email: getUserEmail.email,
196
- userName: getUserEmail.email.split( '@' )[0],
197
- };
198
- userDetails = await createUser( userData );
199
- } else {
200
- userDetails = userDetails[0];
201
- }
218
+ // if ( !userDetails.length ) {
219
+ // let userData = {
220
+ // clientId: req.body.clientId,
221
+ // mobileNumber: '',
222
+ // email: getUserEmail.email,
223
+ // userName: getUserEmail.email.split( '@' )[0],
224
+ // };
225
+ // userDetails = await createUser( userData );
226
+ // } else {
227
+ userDetails = userDetails[0];
228
+ // }
202
229
  }
203
230
  let taskData = { ...data };
204
231
  taskData.store_id = store.storeId;
@@ -564,3 +591,18 @@ export async function getFixtureDetails( req, res ) {
564
591
  return res.sendError( e, 500 );
565
592
  }
566
593
  }
594
+
595
+ export async function getVmDetails( req, res ) {
596
+ try {
597
+ let getVms = await planoProductService.find( { type: 'vm' }, { productName: 1 } );
598
+ if ( !getVms.length ) {
599
+ return res.sendError( 'No data found', 204 );
600
+ }
601
+ getVms = [ ...new Set( getVms.map( ( ele ) => ele.productName ) ) ];
602
+ getVms.push( 'other' );
603
+ return res.sendSuccess( getVms );
604
+ } catch ( e ) {
605
+ logger.error( { functionName: 'getVmDetails', error: e } );
606
+ return res.sendError( e, 500 );
607
+ }
608
+ }
@@ -18,4 +18,5 @@ scriptRouter
18
18
  .post( '/updateRfidProduct2', scriptController.updateRfidProduct2 )
19
19
  .post( '/getProdTaskData', scriptController.getProdTaskData )
20
20
  .post( '/updateLayoutFeedback', scriptController.updatelayoutFeedback )
21
+ .post( '/updateFixtureFeedback', scriptController.updateFixtureFeedback )
21
22
  .post( '/getFileNames', scriptController.extractZipFileNames );
@@ -34,6 +34,7 @@ storeBuilderRouter
34
34
  .post( '/updateQrCvProcessRequest', isAllowedSessionHandler, storeBuilderController.updateQrCvProcessRequest )
35
35
  .post( '/getQrCvProcessRequest', isAllowedSessionHandler, storeBuilderController.getQrCvProcessRequest )
36
36
  .post( '/fixtureQrUpdate', isAllowedSessionHandler, storeBuilderController.fixtureQrUpdate )
37
+ .post( '/fixtureQrUpdatev1', isAllowedSessionHandler, storeBuilderController.fixtureQrUpdatev1 )
37
38
  .post( '/updateDeatailedDistance', isAllowedSessionHandler, storeBuilderController.updateDetailedDistance )
38
39
  .post( '/upsertFixture', isAllowedSessionHandler, storeBuilderController.upsertFixtures )
39
40
  .post( '/getshelfSections', isAllowedSessionHandler, storeBuilderController.getShelfSections )
@@ -11,4 +11,5 @@ storeBuilderTaskRouter
11
11
  .post( '/uploadImage', isAllowedSessionHandler, taskController.uploadImage )
12
12
  .post( '/updateStatus', isAllowedSessionHandler, taskController.updateStatus )
13
13
  .post( '/updateAnswers', isAllowedSessionHandler, taskController.updateAnswers )
14
- .get( '/getFixtureDetails', isAllowedSessionHandler, taskController.getFixtureDetails );
14
+ .get( '/getFixtureDetails', isAllowedSessionHandler, taskController.getFixtureDetails )
15
+ .get( '/getVmDetails', isAllowedSessionHandler, taskController.getVmDetails );
@@ -1,8 +1,8 @@
1
1
  import model from 'tango-api-schema';
2
2
 
3
3
  export async function find( query={}, field={} ) {
4
- return model.planoStaticBrandCategories.find( query, field );
4
+ return model.planoStaticData.find( query, field );
5
5
  }
6
6
  export async function findOne( query={}, field={} ) {
7
- return model.planoStaticBrandCategories.findOne( query, field );
7
+ return model.planoStaticData.findOne( query, field );
8
8
  }