tango-app-api-task 3.3.1-beta-4 → 3.3.1-beta-6
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
|
@@ -24,6 +24,7 @@ import * as taskProcessedService from '../service/processedTaskList.service.js';
|
|
|
24
24
|
import * as ApproverModel from '../service/approver.service.js';
|
|
25
25
|
import { createTeamsModel, findOneTeams, updateOneTeamModel, findteams } from '../service/teams.service.js';
|
|
26
26
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
27
|
+
import * as checklistService from '../service/checklist.service.js';
|
|
27
28
|
async function LamdaServiceCall( url, data ) {
|
|
28
29
|
try {
|
|
29
30
|
const requestOptions = {
|
|
@@ -1534,18 +1535,16 @@ export async function reinitiateTask( req, res ) {
|
|
|
1534
1535
|
export async function createChecklistTask( req, res ) {
|
|
1535
1536
|
try {
|
|
1536
1537
|
let inputBody = req.body;
|
|
1537
|
-
let
|
|
1538
|
-
|
|
1539
|
-
if ( !
|
|
1538
|
+
let userDetailList;
|
|
1539
|
+
userDetailList = await userService.findOne( { email: inputBody.userEmail } );
|
|
1540
|
+
if ( !userDetailList ) {
|
|
1540
1541
|
let userData = {
|
|
1541
1542
|
userName: inputBody.userName,
|
|
1542
1543
|
email: inputBody.userEmail,
|
|
1543
1544
|
mobileNumber: '',
|
|
1544
1545
|
clientId: inputBody.clientId,
|
|
1545
1546
|
};
|
|
1546
|
-
|
|
1547
|
-
} else {
|
|
1548
|
-
userId = userDetails._id;
|
|
1547
|
+
userDetailList = await createUser( userData );
|
|
1549
1548
|
}
|
|
1550
1549
|
|
|
1551
1550
|
// let title = `New Task Alert ${inputBody.checkListName}`;
|
|
@@ -1564,6 +1563,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1564
1563
|
|
|
1565
1564
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
1566
1565
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
1566
|
+
let checklistDetails = await checklistService.findOne( { _id: inputBody?.checkListId }, { coverage: 1 } );
|
|
1567
1567
|
let data = {
|
|
1568
1568
|
checkListName: inputBody.checkListName,
|
|
1569
1569
|
checkListDescription: inputBody.checkListDescription,
|
|
@@ -1581,6 +1581,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1581
1581
|
publishDate: new Date(),
|
|
1582
1582
|
locationCount: 1,
|
|
1583
1583
|
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
1584
|
+
coverage: checklistDetails?.coverage || 'store',
|
|
1584
1585
|
};
|
|
1585
1586
|
|
|
1586
1587
|
if ( req.user.userType == 'tango' || ( req.user.userType == 'client' && [ 'user' ].includes( req.user.role ) ) ) {
|
|
@@ -1655,8 +1656,8 @@ export async function createChecklistTask( req, res ) {
|
|
|
1655
1656
|
checkListId: response?._id,
|
|
1656
1657
|
checkListName: data.checkListName,
|
|
1657
1658
|
client_id: inputBody.clientId,
|
|
1658
|
-
userId:
|
|
1659
|
-
assignId: storeDetails?._id,
|
|
1659
|
+
userId: userDetailList._id,
|
|
1660
|
+
assignId: response?.coverage == 'store' ? storeDetails?._id : userDetailList._id,
|
|
1660
1661
|
coverage: response?.coverage || 'store',
|
|
1661
1662
|
};
|
|
1662
1663
|
await taskAssignService.create( userDetails );
|