File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -28,16 +28,25 @@ const addNewTask = async (req, res) => {
28
28
taskId,
29
29
dependsOn,
30
30
} ;
31
- const taskDependency = await dependencyModel . addDependency ( data ) ;
32
- const task = {
33
- ...taskDetails ,
34
- dependsOn : taskDependency ,
35
- id : taskId ,
36
- } ;
37
- return res . json ( {
38
- message : "Task created successfully!" ,
39
- task,
40
- } ) ;
31
+ if ( data . dependsOn ) {
32
+ const taskDependency = await dependencyModel . addDependency ( data ) ;
33
+ return res . json ( {
34
+ message : "Task created successfully!" ,
35
+ task : {
36
+ ...taskDetails ,
37
+ dependsOn : taskDependency ,
38
+ id : taskId ,
39
+ } ,
40
+ } ) ;
41
+ } else {
42
+ return res . json ( {
43
+ message : "Task created successfully!" ,
44
+ task : {
45
+ ...taskDetails ,
46
+ id : taskId ,
47
+ } ,
48
+ } ) ;
49
+ }
41
50
} catch ( err ) {
42
51
logger . error ( `Error while creating new task: ${ err } ` ) ;
43
52
return res . boom . badImplementation ( INTERNAL_SERVER_ERROR ) ;
You can’t perform that action at this time.
0 commit comments