tango-app-api-store-builder 1.0.0-beta-214 → 1.0.0-beta-216

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-214",
3
+ "version": "1.0.0-beta-216",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -979,7 +979,7 @@ export async function updateFixtureStatus( req, res ) {
979
979
  { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
980
980
  ] );
981
981
 
982
- await planoTaskService.updateOne( { _id: req.body._id }, { approvalStatus: 'approved' } );
982
+ await planoTaskService.updateOne( { _id: req.body._id }, { approvalStatus: 'approved', taskType: 'initial' } );
983
983
  let fixtureTask = await planoTaskService.find(
984
984
  {
985
985
  planoId: new mongoose.Types.ObjectId( req.body.planoId ),
@@ -1224,16 +1224,26 @@ export async function updateStoreFixture( req, res ) {
1224
1224
  try {
1225
1225
  const { fixtureId, data } = req.body;
1226
1226
 
1227
+ let configId;
1228
+
1227
1229
  const currentFixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) } );
1228
1230
  let currentFixtureDoc = currentFixture.toObject();
1229
1231
  if ( req?.body?.taskType?.includes( 'fixture' ) || data?.taskType?.includes( 'fixture' ) ) {
1230
1232
  let shelfDetails = await fixtureShelfService.find( { fixtureId: fixtureId } );
1231
1233
  data.shelfConfig.forEach( ( ele ) => {
1232
1234
  let findShelfProduct = shelfDetails.find( ( shelf ) => shelf.shelfNumber == ele.shelfNumber );
1233
- ele.productBrandName = findShelfProduct?.productBrandName ?? [];
1234
- ele.productCategory = findShelfProduct?.productCategory ?? [];
1235
- ele.productSubCategory = findShelfProduct?.productSubCategory ?? [];
1236
- ele.zone = findShelfProduct?.zone ?? 'Bottom';
1235
+ if ( !ele?.zone ) {
1236
+ ele.zone = findShelfProduct?.zone ?? 'Bottom';
1237
+ }
1238
+ if ( !ele?.productBrandName ) {
1239
+ ele.productBrandName = findShelfProduct?.productBrandName ?? [];
1240
+ }
1241
+ if ( !ele?.productCategory ) {
1242
+ ele.productCategory = findShelfProduct?.productCategory ?? [];
1243
+ }
1244
+ if ( !ele?.productSubCategory ) {
1245
+ ele.productSubCategory = findShelfProduct?.productSubCategory ?? [];
1246
+ }
1237
1247
  } );
1238
1248
  let vmConfig = [];
1239
1249
  for ( let vm of data.vmConfig ) {
@@ -1352,13 +1362,21 @@ export async function updateStoreFixture( req, res ) {
1352
1362
  let getMaxTemp = await fixtureConfigService.aggregate( tempQuery );
1353
1363
  templateIndex = getMaxTemp?.[0]?.tempId + 1;
1354
1364
  }
1355
- templateData.fixtureName= `${header}-${data.fixtureCategory}-varient-${templateIndex}`,
1365
+ templateData.fixtureName= `${header}-${data.fixtureCategory}-variant-${templateIndex}`,
1356
1366
  templateData.templateType = 'sub';
1357
1367
  templateData.masterTemplateId = fixtureMasterTemplate._id;
1368
+ templateData.templateIndex = templateIndex;
1369
+ templateData.createdAt = new Date();
1370
+ templateData.updatedAt = new Date();
1358
1371
  let subTemplate = await fixtureConfigService.create( templateData );
1372
+ configId = subTemplate._id;
1373
+
1374
+ console.log( subTemplate, 'subTemplate' );
1359
1375
 
1360
1376
  data.fixtureConfigId = subTemplate._id;
1361
1377
  data.masterTemplateId = fixtureMasterTemplate._id;
1378
+ } else {
1379
+ data.fixtureConfigId = fixturesubTemplate?.[0]?._id;
1362
1380
  }
1363
1381
  }
1364
1382
 
@@ -1467,7 +1485,7 @@ export async function updateStoreFixture( req, res ) {
1467
1485
  if ( req.body?.editMode ) {
1468
1486
  await floorService.updateOne( { _id: new mongoose.Types.ObjectId( currentFixture.floorId ) }, { isEdited: true } );
1469
1487
  }
1470
- res.sendSuccess( 'Updated Successfully' );
1488
+ res.sendSuccess( { message: 'Updated Successfully', ...( configId && { id: configId } ) } );
1471
1489
  } catch ( e ) {
1472
1490
  logger.error( { functionName: 'updateStoreFixture', error: e } );
1473
1491
  return res.sendError( e, 500 );
@@ -9698,44 +9698,45 @@ function transformProducts( products, shelvesByZone, fixtureData ) {
9698
9698
 
9699
9699
  // ---------------------Plano Migrate-------------------------
9700
9700
 
9701
- export async function getAllPlanoIds( req, res ) {
9701
+ export async function getAllPlanoIds(req, res){
9702
9702
  try {
9703
- if ( !req.query?.clientId ) {
9704
- return res.sendError( 'Client id is required', 400 );
9703
+
9704
+ if (!req.query?.clientId) {
9705
+ return res.sendError('Client id is required', 400);
9705
9706
  }
9706
- const floorsData = await storeBuilderService.aggregate( [
9707
+ const floorsData = await storeBuilderService.aggregate([
9707
9708
  {
9708
- '$match': {
9709
- 'clientId': '11',
9710
- },
9711
- }, {
9712
- '$group': {
9713
- '_id': '$planoId',
9714
- 'storeName': {
9715
- '$first': '$storeName',
9716
- },
9717
- 'storeId': {
9718
- '$first': '$storeId',
9719
- },
9720
- },
9709
+ '$match': {
9710
+ 'clientId': '11'
9711
+ }
9721
9712
  }, {
9722
- '$project': {
9723
- 'planoId': '$_id',
9724
- 'storeName': 1,
9725
- 'storeId': 1,
9713
+ '$group': {
9714
+ '_id': '$planoId',
9715
+ 'storeName': {
9716
+ '$first': '$storeName'
9726
9717
  },
9718
+ 'storeId': {
9719
+ '$first': '$storeId'
9720
+ }
9721
+ }
9722
+ }, {
9723
+ '$project': {
9724
+ 'planoId': '$_id',
9725
+ 'storeName': 1,
9726
+ 'storeId': 1
9727
+ }
9727
9728
  }, {
9728
- '$sort': { storeName: 1 },
9729
- },
9730
- ] );
9729
+ '$sort': { storeName: 1 }
9730
+ }
9731
+ ]);
9731
9732
 
9732
- if ( floorsData ) {
9733
- return res.sendSuccess( floorsData );
9733
+ if (floorsData) {
9734
+ return res.sendSuccess(floorsData);
9734
9735
  } else {
9735
- return res.sendError( 'No floor data found', 204 );
9736
+ return res.sendError("No floor data found", 204)
9736
9737
  }
9737
- } catch ( error ) {
9738
- console.log( '@@ ~ getAllPlanoIds [ERR]:', error );
9739
- return res.sendError( e, 500 );
9738
+ } catch (error) {
9739
+ console.log("@@ ~ getAllPlanoIds [ERR]:", error);
9740
+ return res.sendError(e, 500);
9740
9741
  }
9741
- }
9742
+ }
@@ -3552,7 +3552,7 @@ export async function storeFixturesTaskv2( req, res ) {
3552
3552
  let disabled = true;
3553
3553
  if ( compliance?.status ) {
3554
3554
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3555
- answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3555
+ answer?.status === 'disagree' ||
3556
3556
  answer?.issues?.some( ( issue ) =>
3557
3557
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3558
3558
  ),
@@ -3655,7 +3655,7 @@ export async function storeFixturesTaskv2( req, res ) {
3655
3655
  let disabled = true;
3656
3656
  if ( compliance?.status ) {
3657
3657
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3658
- answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3658
+ answer?.status === 'disagree' ||
3659
3659
  answer?.issues?.some( ( issue ) =>
3660
3660
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3661
3661
  ),
@@ -5306,7 +5306,7 @@ export async function getTaskDetails( req, res ) {
5306
5306
  let taskInfo = await planotaskService.aggregate( query );
5307
5307
  let disabledInfo = [];
5308
5308
  let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1, planoProgress: 1 } );
5309
- disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ( ele.status != 'submit' && !ele?.breach ) );
5309
+ disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) && ele.status == 'submit' ) || ( ele.status != 'submit' && !ele?.breach ) );
5310
5310
  if ( floorDetails.isEdited ) {
5311
5311
  let findPending = taskInfo?.[0]?.taskStatus?.findIndex( ( ele ) => ele.type == 'fixture' && ele.feedbackStatus == 'pending' );
5312
5312
  if ( findPending != -1 ) {