tango-app-api-store-builder 1.0.0-beta-201 → 1.0.0-beta-203

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-201",
3
+ "version": "1.0.0-beta-203",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,7 +15,8 @@ import * as floorService from '../service/storeBuilder.service.js';
15
15
  import * as planoStaticService from '../service/planoStaticData.service.js';
16
16
  import * as assignService from '../service/assignService.service.js';
17
17
  import * as storeBuilderService from '../service/storeBuilder.service.js';
18
- // import * as storeFixtureService from '../service/storeFixture.service.js';
18
+ import * as storeFixtureService from '../service/storeFixture.service.js';
19
+ import * as fixtureShelfService from '../service/fixtureShelf.service.js';
19
20
 
20
21
 
21
22
  dayjs.extend( timeZone );
@@ -676,8 +677,6 @@ export async function updateAnswersv2( req, res ) {
676
677
  if ( !taskDetails ) {
677
678
  return res.sendError( 'No data found', 204 );
678
679
  }
679
- console.log( req.body.answers[0] );
680
- console.log( req.body.answers[0].issues[0] );
681
680
  let data = {
682
681
  fixtureId: req.body.fixtureId,
683
682
  answers: req.body.answers,
@@ -692,8 +691,6 @@ export async function updateAnswersv2( req, res ) {
692
691
  storeId: req.body?.storeId,
693
692
  date_string: dayjs().format( 'YYYY-MM-DD' ),
694
693
  };
695
- console.log( '111111', data.answers[0] );
696
- console.log( '111111', data.answers[0].issues[0] );
697
694
  if ( req.body.type === 'layout' ) {
698
695
  await planoTaskService.updateOne( { planoId: req.body.planoId, taskType: req.body.taskType, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, ...( taskDetails?._id ) ? { taskId: taskDetails?._id } : {} }, data );
699
696
  } else {
@@ -713,6 +710,35 @@ export async function updateAnswersv2( req, res ) {
713
710
  await sendMessageToQueue( `${sqs.url}${sqs.storeBuilder}`, JSON.stringify( sqsData ) );
714
711
  }
715
712
 
713
+ if ( req.body.type === 'fixture' ) {
714
+ let fixtureData = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( req.body.fixtureId ) } );
715
+
716
+ if ( fixtureData ) {
717
+ fixtureData = fixtureData?.toObject();
718
+
719
+ let fixtureShelves = await fixtureShelfService.find( { fixtureId: fixtureData._id } );
720
+
721
+ if ( fixtureShelves.length ) {
722
+ fixtureShelves = fixtureShelves.map( ( shelf ) => shelf?.toObject() );
723
+
724
+ fixtureData.shelfConfig = fixtureShelves;
725
+ }
726
+ }
727
+
728
+ let sqsData = {
729
+ bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
730
+ date_string: dayjs().format( 'YYYY-MM-DD' ),
731
+ storeName: data?.storeName,
732
+ imagePath: data?.answers[0]?.image,
733
+ fixtureId: req.body.fixtureId,
734
+ fixtureData: fixtureData,
735
+ };
736
+
737
+ const sqs = JSON.parse( process.env.SQS );
738
+ await sendMessageToQueue( `${sqs.url}${sqs.fixtureImageProcess}`, JSON.stringify( sqsData ) );
739
+ }
740
+
741
+
716
742
  return res.sendSuccess( 'Fixture details updated successfully' );
717
743
  } catch ( e ) {
718
744
  logger.error( { functionName: 'updateAnswers', error: e } );