tango-app-api-store-builder 1.0.0-beta-25 → 1.0.0-beta-26
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
|
@@ -299,10 +299,16 @@ export async function updateAnswers( req, res ) {
|
|
|
299
299
|
return res.sendError( 'No data found', 204 );
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
+
req.body.answers.forEach( ( ans ) => {
|
|
303
|
+
if ( ans.image && ans.image.includes( 'http' ) ) {
|
|
304
|
+
ans.image = url.split( '.com/' )[1].split( '?' )[0];
|
|
305
|
+
}
|
|
306
|
+
} );
|
|
307
|
+
|
|
302
308
|
let data = {
|
|
303
309
|
fixtureId: req.body.fixtureId,
|
|
304
310
|
answers: req.body.answers,
|
|
305
|
-
status: req.body.answers?.find( ( ans ) => !ans.answer ) ? 'incomplete' : 'complete',
|
|
311
|
+
status: req.body.answers?.find( ( ans ) => ans.answer && !ans.answer ) ? 'incomplete' : 'complete',
|
|
306
312
|
planoId: req.body.planoId,
|
|
307
313
|
floorId: req.body.floorId,
|
|
308
314
|
type: req.body.type,
|
|
@@ -315,3 +321,31 @@ export async function updateAnswers( req, res ) {
|
|
|
315
321
|
return res.sendError( e, 500 );
|
|
316
322
|
}
|
|
317
323
|
}
|
|
324
|
+
|
|
325
|
+
export async function getFixtureDetails( req, res ) {
|
|
326
|
+
try {
|
|
327
|
+
if ( !req.query.fixtureId ) {
|
|
328
|
+
return res.sendError( 'Fixture id is required' );
|
|
329
|
+
}
|
|
330
|
+
let fixtureDetails = await planoTaskService.findOne( { fixtureId: req.query.fixtureId, type: req.query.type } );
|
|
331
|
+
if ( !fixtureDetails ) {
|
|
332
|
+
return res.sendError( 'No data found', 204 );
|
|
333
|
+
}
|
|
334
|
+
fixtureDetails = await Promise.all( fixtureDetails.answers.map( async ( ans ) => {
|
|
335
|
+
if ( ans.image ) {
|
|
336
|
+
let params = {
|
|
337
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
338
|
+
file_path: ans.image,
|
|
339
|
+
};
|
|
340
|
+
let imageUrl = await signedUrl( params );
|
|
341
|
+
ans.image = imageUrl;
|
|
342
|
+
}
|
|
343
|
+
return ans;
|
|
344
|
+
} ) );
|
|
345
|
+
|
|
346
|
+
return res.sendSuccess( fixtureDetails );
|
|
347
|
+
} catch ( e ) {
|
|
348
|
+
logger.error( { functionName: 'getFixtureDetails', error: 'e' } );
|
|
349
|
+
return res.sendError( e, 500 );
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -9,4 +9,5 @@ taskRouter
|
|
|
9
9
|
.get( '/taskDetails', taskController.getTaskDetails )
|
|
10
10
|
.post( '/uploadImage', taskController.uploadImage )
|
|
11
11
|
.post( '/updateStatus', taskController.updateStatus )
|
|
12
|
-
.post( '/updateAnswers', taskController.updateAnswers )
|
|
12
|
+
.post( '/updateAnswers', taskController.updateAnswers )
|
|
13
|
+
.get( '/getFixtureDetails', taskController.getFixtureDetails );
|
|
@@ -8,10 +8,10 @@ export async function updateOne( query={}, record={} ) {
|
|
|
8
8
|
return model.planoTaskCompliance.updateOne( query, { $set: record }, { upsert: true } );
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export async function findOne( query={}, field={} ) {
|
|
12
|
+
return model.planoTaskCompliance.findOne( query, field );
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
export async function count( data ) {
|
|
12
16
|
return model.planoTaskCompliance.countDocuments( data );
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
export async function findOne( query={}, field={} ) {
|
|
16
|
-
return model.planoTaskCompliance.findOne( query, field );
|
|
17
|
-
}
|