tango-app-api-store-builder 1.0.0-beta-194 → 1.0.0-beta-195
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
|
@@ -890,45 +890,70 @@ export async function replaceFixtureDetails( req, res ) {
|
|
|
890
890
|
|
|
891
891
|
await Promise.all(
|
|
892
892
|
inputData.storeList.map( async ( store ) => {
|
|
893
|
-
const replaceFixture = await storeFixtureService.
|
|
893
|
+
const replaceFixture = await storeFixtureService.find( {
|
|
894
894
|
fixtureConfigId: inputData.findFixture,
|
|
895
|
+
...( store?.floorDetails?._id ) ? { floorId: store?.floorDetails?._id } : {},
|
|
895
896
|
storeId: store.storeId,
|
|
896
897
|
} );
|
|
897
898
|
|
|
898
|
-
|
|
899
|
+
// console.log( replaceFixture );
|
|
899
900
|
|
|
900
|
-
|
|
901
|
+
if ( !replaceFixture.length ) return;
|
|
902
|
+
|
|
903
|
+
// console.log( replaceFixture._id );
|
|
901
904
|
|
|
902
905
|
const deleteFixShelves = await fixtureShelfService.deleteMany( {
|
|
903
|
-
fixtureId: replaceFixture._id,
|
|
906
|
+
fixtureId: { $in: replaceFixture.map( ( ele ) => ele._id ) },
|
|
904
907
|
} );
|
|
905
908
|
console.log( deleteFixShelves );
|
|
906
909
|
|
|
907
910
|
await storeFixtureService.updateMany(
|
|
908
|
-
{ fixtureConfigId: inputData.findFixture, storeId: store.storeId },
|
|
911
|
+
{ fixtureConfigId: inputData.findFixture, ...( store?.floorDetails?._id ) ? { floorId: store?.floorDetails?._id } : {}, storeId: store.storeId },
|
|
909
912
|
updateData,
|
|
910
913
|
);
|
|
911
914
|
|
|
912
915
|
if ( replaceFixtureData.shelfConfig?.length ) {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
916
|
+
replaceFixtureData.shelfConfig.forEach( async ( shelf ) => {
|
|
917
|
+
let shelfData = [];
|
|
918
|
+
shelf = { ...shelf.toObject() };
|
|
919
|
+
delete shelf._id;
|
|
920
|
+
replaceFixture.forEach( async ( data ) => {
|
|
921
|
+
shelfData.push( {
|
|
922
|
+
...shelf,
|
|
923
|
+
floorId: data.floorId,
|
|
924
|
+
planoId: data.planoId,
|
|
925
|
+
clientId: data.clientId,
|
|
926
|
+
fixtureId: data._id,
|
|
927
|
+
storeId: data.storeId,
|
|
928
|
+
storeName: data.storeName,
|
|
929
|
+
} );
|
|
930
|
+
} );
|
|
931
|
+
try {
|
|
932
|
+
await fixtureShelfService.insertMany( shelfData );
|
|
933
|
+
} catch ( err ) {
|
|
934
|
+
console.error( 'Insert failed:', err );
|
|
935
|
+
}
|
|
925
936
|
} );
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
937
|
+
// const shelfList = replaceFixtureData.shelfConfig.map( ( shelf ) => {
|
|
938
|
+
// const shelfData = {
|
|
939
|
+
// ...shelf.toObject(),
|
|
940
|
+
// floorId: replaceFixture.floorId,
|
|
941
|
+
// planoId: replaceFixture.planoId,
|
|
942
|
+
// clientId: replaceFixture.clientId,
|
|
943
|
+
// // fixtureId: replaceFixture._id,
|
|
944
|
+
// storeId: replaceFixture.storeId,
|
|
945
|
+
// storeName: replaceFixture.storeName,
|
|
946
|
+
// };
|
|
947
|
+
|
|
948
|
+
// delete shelfData._id;
|
|
949
|
+
// return shelfData;
|
|
950
|
+
// } );
|
|
951
|
+
|
|
952
|
+
// try {
|
|
953
|
+
// await fixtureShelfService.insertMany( shelfList );
|
|
954
|
+
// } catch ( err ) {
|
|
955
|
+
// console.error( 'Insert failed:', err );
|
|
956
|
+
// }
|
|
932
957
|
}
|
|
933
958
|
} ),
|
|
934
959
|
);
|