tango-app-api-store-builder 1.0.1 → 1.0.2

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.1",
3
+ "version": "1.0.2",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9572,8 +9572,9 @@ export async function productMappings( req, res ) {
9572
9572
 
9573
9573
  const { fixtureId, Top, Mid, Bottom } = payload;
9574
9574
 
9575
- const storeName = 'LKST98';
9576
- const storeId = '11-4';
9575
+ const storeName = 'LKST11';
9576
+ const storeId = '11-259';
9577
+ const clientId = '11';
9577
9578
 
9578
9579
  if ( !fixtureId ) {
9579
9580
  return res.sendError( 'fixtureId is required', 400 );
@@ -9592,7 +9593,7 @@ export async function productMappings( req, res ) {
9592
9593
  const pDetails = raw.find( ( pd ) => pd['product_id'] == pid );
9593
9594
  if ( pDetails ) {
9594
9595
  pDetailsList.push( {
9595
- clientId: '11',
9596
+ clientId: clientId,
9596
9597
  productId: pDetails.product_id,
9597
9598
  productName: pDetails.parent_brand,
9598
9599
  pid: pDetails.product_id,
@@ -9628,7 +9629,7 @@ export async function productMappings( req, res ) {
9628
9629
  const result = await planoProductService.insertMany( pDetailsList );
9629
9630
 
9630
9631
  let planoMappings = result.map( ( pd ) => ( {
9631
- clientId: '11',
9632
+ clientId: clientId,
9632
9633
  storeName: storeName,
9633
9634
  storeId: storeId,
9634
9635
  type: 'product',
@@ -9748,7 +9749,7 @@ export async function getAllPlanoIds( req, res ) {
9748
9749
  }
9749
9750
  }
9750
9751
 
9751
- export async function createComplianceFromMappins( req, res ) {
9752
+ export async function createComplianceFromMappings( req, res ) {
9752
9753
  try {
9753
9754
  const { planoId, fixtureId } = req.body;
9754
9755
 
@@ -9768,8 +9769,8 @@ export async function createComplianceFromMappins( req, res ) {
9768
9769
  const mapping = allMappings[i];
9769
9770
  const complianceDoc = {
9770
9771
  "clientId": "11",
9771
- "storeName": "LKST2255",
9772
- "storeId": "11-1984",
9772
+ "storeName": "LKST2577",
9773
+ "storeId": "11-2243",
9773
9774
  "type": "product",
9774
9775
  "planoId": new mongoose.Types.ObjectId( mapping.planoId ),
9775
9776
  "floorId": new mongoose.Types.ObjectId( mapping.floorId ),
@@ -14548,36 +14549,38 @@ async function updateStoreFixtureShelves() {
14548
14549
 
14549
14550
  export async function planoAccess( req, res ) {
14550
14551
  try {
14551
- if ( !req.body?.email ) {
14552
+ if ( !req.body?.email.length ) {
14552
14553
  return res.sendError( 'Email is required', 400 );
14553
14554
  }
14554
14555
  if ( !req.body.clientId ) {
14555
14556
  return res.sendError( 'clientId is required', 400 );
14556
14557
  }
14557
- let userQuery = [
14558
- {
14559
- $addFields: {
14560
- uEmail: { $toLower: '$email' },
14558
+ await Promise.all( req.body?.email.map( async ( email ) => {
14559
+ let userQuery = [
14560
+ {
14561
+ $addFields: {
14562
+ uEmail: { $toLower: '$email' },
14563
+ },
14561
14564
  },
14562
- },
14563
- {
14564
- $match: {
14565
- uEmail: req.body?.email.toLowerCase(),
14565
+ {
14566
+ $match: {
14567
+ uEmail: email.toLowerCase(),
14568
+ },
14566
14569
  },
14567
- },
14568
- ];
14569
- let getusers = await userService.aggregate( userQuery );
14570
- if ( !getusers ) {
14571
- let userData = {
14572
- clientId: req.body.clientId,
14573
- mobileNumber: '',
14574
- email: req.body?.email,
14575
- userName: req.body?.email.split( '@' )[0],
14576
- };
14577
- await createUser( userData );
14578
- }
14570
+ ];
14571
+ let getusers = await userService.aggregate( userQuery );
14572
+ if ( !getusers ) {
14573
+ let userData = {
14574
+ clientId: req.body.clientId,
14575
+ mobileNumber: '',
14576
+ email: email,
14577
+ userName: email.split( '@' )[0],
14578
+ };
14579
+ await createUser( userData );
14580
+ }
14581
+ await staticService.updateOne( { type: 'user' }, { $push: { data: email } } );
14582
+ } ) );
14579
14583
 
14580
- await staticService.updateOne( { type: 'user' }, { $push: { data: req.body?.email } } );
14581
14584
  return res.sendSuccess( 'updated successfully' );
14582
14585
  } catch ( e ) {
14583
14586
  logger.error( { functionName: 'planoAccess', error: e } );