tango-app-api-store-builder 1.0.0-beta-212 → 1.0.0-beta-213

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-212",
3
+ "version": "1.0.0-beta-213",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -30,21 +30,25 @@ export async function getplanoFeedback( req, res ) {
30
30
  const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
31
31
 
32
32
  let data = await planoTaskService.aggregate( pipeline );
33
- if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
33
+ if ( filterByApprovalStatus && filterByApprovalStatus?.length ) {
34
34
  if ( type == 'fixture' ) {
35
- if ( filterByApprovalStatus == 'pending' ) {
36
- data = data.filter( ( element ) => {
35
+ let pendingData = [];
36
+ let agreeData = [];
37
+ let disAgreeData = [];
38
+ if ( filterByApprovalStatus.includes( 'pending' ) ) {
39
+ pendingData = data.filter( ( element ) => {
37
40
  return element?.approvalStatus == 'pending';
38
41
  } );
39
- } if ( filterByApprovalStatus == 'agree' ) {
40
- data = data.filter( ( element ) => {
42
+ } if ( filterByApprovalStatus.includes( 'agree' ) ) {
43
+ agreeData = data.filter( ( element ) => {
41
44
  return element?.answers?.[0]?.status == 'agree';
42
45
  } );
43
- } if ( filterByApprovalStatus == 'disagree' ) {
44
- data = data.filter( ( element ) => {
46
+ } if ( filterByApprovalStatus.includes( 'disagree' ) ) {
47
+ disAgreeData = data.filter( ( element ) => {
45
48
  return element?.answers?.[0]?.status == 'disagree';
46
49
  } );
47
50
  }
51
+ data = [ ...pendingData, ...agreeData, ...disAgreeData ];
48
52
  } else {
49
53
  data.forEach( ( element ) => {
50
54
  element.answers?.forEach( ( ans ) => {
@@ -370,7 +374,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
370
374
  ...vmStages,
371
375
  { $sort: { _id: -1 } },
372
376
  ];
373
- if ( filterByApprovalStatus && filterByApprovalStatus != '' ) {
377
+ if ( filterByApprovalStatus && filterByApprovalStatus != '' && type !== 'fixture' ) {
374
378
  pipeline = [];
375
379
  pipeline.push( matchStage );
376
380
  pipeline.push(
@@ -9698,45 +9698,44 @@ 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
-
9704
- if (!req.query?.clientId) {
9705
- return res.sendError('Client id is required', 400);
9703
+ if ( !req.query?.clientId ) {
9704
+ return res.sendError( 'Client id is required', 400 );
9706
9705
  }
9707
- const floorsData = await storeBuilderService.aggregate([
9706
+ const floorsData = await storeBuilderService.aggregate( [
9708
9707
  {
9709
- '$match': {
9710
- 'clientId': '11'
9711
- }
9708
+ '$match': {
9709
+ 'clientId': '11',
9710
+ },
9712
9711
  }, {
9713
- '$group': {
9714
- '_id': '$planoId',
9715
- 'storeName': {
9716
- '$first': '$storeName'
9712
+ '$group': {
9713
+ '_id': '$planoId',
9714
+ 'storeName': {
9715
+ '$first': '$storeName',
9716
+ },
9717
+ 'storeId': {
9718
+ '$first': '$storeId',
9719
+ },
9717
9720
  },
9718
- 'storeId': {
9719
- '$first': '$storeId'
9720
- }
9721
- }
9722
- }, {
9723
- '$project': {
9724
- 'planoId': '$_id',
9725
- 'storeName': 1,
9726
- 'storeId': 1
9727
- }
9728
9721
  }, {
9729
- '$sort': { storeName: 1 }
9730
- }
9731
- ]);
9722
+ '$project': {
9723
+ 'planoId': '$_id',
9724
+ 'storeName': 1,
9725
+ 'storeId': 1,
9726
+ },
9727
+ }, {
9728
+ '$sort': { storeName: 1 },
9729
+ },
9730
+ ] );
9732
9731
 
9733
- if (floorsData) {
9734
- return res.sendSuccess(floorsData);
9732
+ if ( floorsData ) {
9733
+ return res.sendSuccess( floorsData );
9735
9734
  } else {
9736
- return res.sendError("No floor data found", 204)
9735
+ return res.sendError( 'No floor data found', 204 );
9737
9736
  }
9738
- } catch (error) {
9739
- console.log("@@ ~ getAllPlanoIds [ERR]:", error);
9740
- return res.sendError(e, 500);
9737
+ } catch ( error ) {
9738
+ console.log( '@@ ~ getAllPlanoIds [ERR]:', error );
9739
+ return res.sendError( e, 500 );
9741
9740
  }
9742
- }
9741
+ }
@@ -25,8 +25,9 @@ import * as fixtureShelfDuplicateService from '../service/fixtureShelfDuplicate.
25
25
  import * as planoMappingDuplicateService from '../service/planoMappingDuplicate.service.js';
26
26
  import * as fixtureConfigDuplicateService from '../service/fixtureConfigDuplicate.service.js';
27
27
  import * as planoVmDuplicateService from '../service/planoVmDuplicate.service.js';
28
+ import advancedFormat from 'dayjs/plugin/advancedFormat.js';
28
29
 
29
-
30
+ dayjs.extend( advancedFormat );
30
31
  dayjs.extend( utc );
31
32
  dayjs.extend( customParseFormat );
32
33
 
@@ -2800,7 +2801,7 @@ export async function storeFixturesv2( req, res ) {
2800
2801
  planograms.map( async ( planogram ) => {
2801
2802
  const floors = await storeBuilderService.find(
2802
2803
  { planoId: planogram._id, ...( req.body?.floorId && { _id: req.body.floorId } ) },
2803
- { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1 },
2804
+ { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1, updatedAt: 1 },
2804
2805
  );
2805
2806
 
2806
2807
  const floorsWithFixtures = await Promise.all(
@@ -3020,6 +3021,7 @@ export async function storeFixturesv2( req, res ) {
3020
3021
 
3021
3022
  return {
3022
3023
  ...floor.toObject(),
3024
+ updatedAt: dayjs( floor?.updatedAt ).format( 'Do MMM YYYY' ),
3023
3025
  fixtureCount: fixtureCount,
3024
3026
  vmCount: totalVmCount,
3025
3027
  layoutPolygon: layoutPolygonWithFixtures,
@@ -3550,7 +3552,7 @@ export async function storeFixturesTaskv2( req, res ) {
3550
3552
  let disabled = true;
3551
3553
  if ( compliance?.status ) {
3552
3554
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3553
- answer?.status === 'disagree' ||
3555
+ answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3554
3556
  answer?.issues?.some( ( issue ) =>
3555
3557
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3556
3558
  ),
@@ -3653,7 +3655,7 @@ export async function storeFixturesTaskv2( req, res ) {
3653
3655
  let disabled = true;
3654
3656
  if ( compliance?.status ) {
3655
3657
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3656
- answer?.status === 'disagree' ||
3658
+ answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3657
3659
  answer?.issues?.some( ( issue ) =>
3658
3660
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3659
3661
  ),
@@ -5303,6 +5305,12 @@ export async function getTaskDetails( req, res ) {
5303
5305
  let disabledInfo = [];
5304
5306
  let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1, planoProgress: 1 } );
5305
5307
  disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ele.status != 'submit' ) && !ele?.breach );
5308
+ if ( floorDetails.isEdited ) {
5309
+ let findPending = taskInfo?.[0]?.taskStatus?.findIndex( ( ele ) => ele.type == 'fixture' && ele.feedbackStatus == 'pending' );
5310
+ if ( findPending != -1 ) {
5311
+ disabledInfo = [];
5312
+ }
5313
+ }
5306
5314
  return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false, planoProgress: floorDetails?.planoProgress ?? 25 } );
5307
5315
  } catch ( e ) {
5308
5316
  logger.error( { functionName: 'getTaskDetails', error: e } );