tango-app-api-store-builder 1.0.0-beta-32 → 1.0.0-beta-33
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
|
@@ -1005,12 +1005,13 @@ export async function fixtureShelfProductv1( req, res ) {
|
|
|
1005
1005
|
if ( fixture.toObject().productResolutionLevel === 'L1' ) {
|
|
1006
1006
|
const productMappings = await planoMappingService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'product' } );
|
|
1007
1007
|
const productDetails = await getProducts( productMappings );
|
|
1008
|
-
return res.sendSuccess( { ...fixture.toObject(), products: productDetails, vms: vmDetails } );
|
|
1008
|
+
return res.sendSuccess( { ...fixture.toObject(), products: productDetails, vms: vmDetails, productCount: productMappings.length } );
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
1011
|
if ( [ 'L2', 'L4' ].includes( fixture.toObject().productResolutionLevel ) ) {
|
|
1012
1012
|
const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
1013
1013
|
if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
1014
|
+
const productCount = await planoMappingService.count( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'product' } );
|
|
1014
1015
|
const shelfProducts = await Promise.all(
|
|
1015
1016
|
fixtureShelves.map( async ( shelf ) => {
|
|
1016
1017
|
const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
|
|
@@ -1018,12 +1019,13 @@ export async function fixtureShelfProductv1( req, res ) {
|
|
|
1018
1019
|
return { ...shelf.toObject(), products: productDetails };
|
|
1019
1020
|
} ),
|
|
1020
1021
|
);
|
|
1021
|
-
return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, vms: vmDetails } );
|
|
1022
|
+
return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, vms: vmDetails, productCount: productCount } );
|
|
1022
1023
|
}
|
|
1023
1024
|
|
|
1024
1025
|
if ( fixture.toObject().productResolutionLevel === 'L3' ) {
|
|
1025
1026
|
const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
1026
1027
|
if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
1028
|
+
const productCount = await planoMappingService.count( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'product' } );
|
|
1027
1029
|
const groupedShelves = fixtureShelves.reduce( async ( accPromise, shelf ) => {
|
|
1028
1030
|
const acc = await accPromise;
|
|
1029
1031
|
const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
|
|
@@ -1033,7 +1035,7 @@ export async function fixtureShelfProductv1( req, res ) {
|
|
|
1033
1035
|
acc[sectionName].push( { ...shelf.toObject(), products: productDetails } );
|
|
1034
1036
|
return acc;
|
|
1035
1037
|
}, Promise.resolve( {} ) );
|
|
1036
|
-
return res.sendSuccess( { ...fixture.toObject(), categories: await groupedShelves, vms: vmDetails } );
|
|
1038
|
+
return res.sendSuccess( { ...fixture.toObject(), categories: await groupedShelves, vms: vmDetails, productCount: productCount } );
|
|
1037
1039
|
}
|
|
1038
1040
|
|
|
1039
1041
|
return res.sendError( 'Incorrect resolution level', 400 );
|
|
@@ -2086,6 +2088,12 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2086
2088
|
return res.sendError( { message: 'Missing fixtureId' }, 400 );
|
|
2087
2089
|
}
|
|
2088
2090
|
|
|
2091
|
+
const fixture = await storeFixtureService.findOne( { _id: fixtureId } );
|
|
2092
|
+
|
|
2093
|
+
if ( !fixture ) {
|
|
2094
|
+
return res.sendError( { message: 'Fixture not found' }, 400 );
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2089
2097
|
const format = path.extname( file.name ).toLowerCase().replace( '.', '' );
|
|
2090
2098
|
file.name = file.name.replace( /\s/g, '' );
|
|
2091
2099
|
|
|
@@ -2094,7 +2102,7 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2094
2102
|
return res.sendError( { message: 'Storage bucket not configured' }, 500 );
|
|
2095
2103
|
}
|
|
2096
2104
|
|
|
2097
|
-
const uploadPath =
|
|
2105
|
+
const uploadPath = `planoQrVideos/${dayjs().format( 'YYYY-MM-DD' )}/${fixture.toObject().storeId}`;
|
|
2098
2106
|
|
|
2099
2107
|
const params = {
|
|
2100
2108
|
fileName: `/${fixtureId}.${format}`,
|
|
@@ -2114,19 +2122,10 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2114
2122
|
};
|
|
2115
2123
|
|
|
2116
2124
|
const sqs = JSON.parse( process.env.SQS || '{}' );
|
|
2117
|
-
if ( !sqs.url || !sqs.
|
|
2125
|
+
if ( !sqs.url || !sqs.qrVideoTopic ) {
|
|
2118
2126
|
return res.sendError( { message: 'SQS details not configured' }, 500 );
|
|
2119
2127
|
}
|
|
2120
2128
|
|
|
2121
|
-
let inputData = {
|
|
2122
|
-
Bucket: bucket.storeBuilder,
|
|
2123
|
-
file_path: fileUrl.Key,
|
|
2124
|
-
};
|
|
2125
|
-
const imgUrl = await signedUrl( inputData );
|
|
2126
|
-
if ( !imgUrl ) {
|
|
2127
|
-
return res.sendError( { message: 'Something went Wrong' }, 500 );
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
2129
|
const sqsPush = await sendMessageToQueue( `${sqs.url}${sqs.qrVideoTopic}`, JSON.stringify( message ) );
|
|
2131
2130
|
|
|
2132
2131
|
return res.sendSuccess( { message: 'Uploaded successfully', sqsPush } );
|
|
@@ -2136,3 +2135,58 @@ export const qrVideoUpload = async ( req, res ) => {
|
|
|
2136
2135
|
}
|
|
2137
2136
|
};
|
|
2138
2137
|
|
|
2138
|
+
export const fixtureQrUpdate = async ( req, res ) => {
|
|
2139
|
+
try {
|
|
2140
|
+
const { fixtureId, date, productQr } = req.body;
|
|
2141
|
+
|
|
2142
|
+
const fixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) }, { _id: 1 } );
|
|
2143
|
+
|
|
2144
|
+
if ( !fixture ) {
|
|
2145
|
+
return res.sendError( { message: 'Invalid fixture Id' }, 400 );
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
const productMappings = await planoMappingService.find( { fixtureId: fixture.toObject()._id, type: 'product' } );
|
|
2149
|
+
|
|
2150
|
+
if ( !productMappings.length ) {
|
|
2151
|
+
return res.sendError( { message: 'No mapping found for fixture' }, 400 );
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
const currentDate = new Date( date );
|
|
2155
|
+
|
|
2156
|
+
const updateStatus = await Promise.all(
|
|
2157
|
+
productMappings.map( async ( mapping ) => {
|
|
2158
|
+
const mappingData = mapping.toObject();
|
|
2159
|
+
|
|
2160
|
+
if ( productQr.includes( mappingData.rfId ) ) {
|
|
2161
|
+
const complianceData = { ...mappingData, planoMappingId: mappingData._id, compliance: 'proper' };
|
|
2162
|
+
|
|
2163
|
+
delete complianceData._id;
|
|
2164
|
+
|
|
2165
|
+
await planoComplianceService.updateOne( { fixtureId: fixture.toObject()._id, rfId: mappingData.rfId, date: currentDate }, complianceData );
|
|
2166
|
+
|
|
2167
|
+
return {
|
|
2168
|
+
result: 'proper',
|
|
2169
|
+
id: mappingData.rfId,
|
|
2170
|
+
};
|
|
2171
|
+
} else {
|
|
2172
|
+
const complianceData = { ...mappingData, planoMappingId: mappingData._id, compliance: 'missing' };
|
|
2173
|
+
|
|
2174
|
+
delete complianceData._id;
|
|
2175
|
+
|
|
2176
|
+
await planoComplianceService.updateOne( { fixtureId: fixture.toObject()._id, rfId: mappingData.rfId, date: currentDate }, complianceData );
|
|
2177
|
+
|
|
2178
|
+
return {
|
|
2179
|
+
result: 'missing',
|
|
2180
|
+
id: mappingData.rfId,
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
} ),
|
|
2184
|
+
);
|
|
2185
|
+
|
|
2186
|
+
return res.sendSuccess( updateStatus );
|
|
2187
|
+
} catch ( error ) {
|
|
2188
|
+
logger.error( 'fixtureQrUpdate =>', error );
|
|
2189
|
+
return res.sendError( { message: 'Internal Server Error' }, 500 );
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
|
|
@@ -115,6 +115,7 @@ export async function createTask( req, res ) {
|
|
|
115
115
|
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
116
116
|
sourceCheckList_id: task._id,
|
|
117
117
|
checkListName: task.checkListName,
|
|
118
|
+
checkListId: task._id,
|
|
118
119
|
scheduleStartTime: '12:00 AM',
|
|
119
120
|
scheduleEndTime: '11:59 PM',
|
|
120
121
|
scheduleStartTime_iso: dayjs.utc( '12:00 AM', 'hh:mm A' ).format(),
|
|
@@ -228,10 +229,10 @@ export async function createTask( req, res ) {
|
|
|
228
229
|
export async function getTaskDetails( req, res ) {
|
|
229
230
|
try {
|
|
230
231
|
if ( !req.query.storeId ) {
|
|
231
|
-
return res.sendError( 'Store id is required' );
|
|
232
|
+
return res.sendError( 'Store id is required', 400 );
|
|
232
233
|
}
|
|
233
234
|
let date = req.query?.date || dayjs().format( 'YYYY-MM-DD' );
|
|
234
|
-
let getDetails = await processedService.find( { store_id: req.query.storeId, date_string: date, isPlano: true, checklistStatus: '
|
|
235
|
+
let getDetails = await processedService.find( { store_id: req.query.storeId, date_string: date, isPlano: true, checklistStatus: { $ne: 'submit' } }, { checkListName: 1, taskType: '$type' } );
|
|
235
236
|
return res.sendSuccess( getDetails );
|
|
236
237
|
} catch ( e ) {
|
|
237
238
|
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
@@ -281,7 +282,7 @@ export async function updateStatus( req, res ) {
|
|
|
281
282
|
return res.sendError( 'No data found', 204 );
|
|
282
283
|
}
|
|
283
284
|
if ( !req.body.status ) {
|
|
284
|
-
return res.sendError( 'Status is required' );
|
|
285
|
+
return res.sendError( 'Status is required', 400 );
|
|
285
286
|
}
|
|
286
287
|
let taskDetails = await processedService.findOne( { _id: req.body.taskId } );
|
|
287
288
|
if ( !taskDetails ) {
|
|
@@ -310,7 +311,7 @@ export async function updateAnswers( req, res ) {
|
|
|
310
311
|
let data = {
|
|
311
312
|
fixtureId: req.body.fixtureId,
|
|
312
313
|
answers: req.body.answers,
|
|
313
|
-
status: req.body.answers?.find( ( ans ) => ans.
|
|
314
|
+
status: req.body.answers?.find( ( ans ) => typeof ans.value == 'boolean' && ans?.value == false ) ? 'incomplete' : 'complete',
|
|
314
315
|
planoId: req.body.planoId,
|
|
315
316
|
floorId: req.body.floorId,
|
|
316
317
|
type: req.body.type,
|
|
@@ -327,7 +328,7 @@ export async function updateAnswers( req, res ) {
|
|
|
327
328
|
export async function getFixtureDetails( req, res ) {
|
|
328
329
|
try {
|
|
329
330
|
if ( !req.query.fixtureId ) {
|
|
330
|
-
return res.sendError( 'Fixture id is required' );
|
|
331
|
+
return res.sendError( 'Fixture id is required', 400 );
|
|
331
332
|
}
|
|
332
333
|
let fixtureDetails = await planoTaskService.findOne( { fixtureId: req.query.fixtureId, type: req.query.type } );
|
|
333
334
|
if ( !fixtureDetails ) {
|
|
@@ -28,6 +28,6 @@ storeBuilderRouter
|
|
|
28
28
|
.post( '/bulkFixtureUpload', storeBuilderController.bulkFixtureUpload )
|
|
29
29
|
.post( '/uploadImage', storeBuilderController.uploadImage )
|
|
30
30
|
.post( '/storeFixturesTask', storeBuilderController.storeFixturesTask )
|
|
31
|
-
.post( '/qrVideoUpload', storeBuilderController.qrVideoUpload )
|
|
32
|
-
|
|
31
|
+
.post( '/qrVideoUpload', storeBuilderController.qrVideoUpload )
|
|
32
|
+
.post( '/fixtureQrUpdate', storeBuilderController.fixtureQrUpdate );
|
|
33
33
|
|