File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/routes/copilotRequest Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,12 @@ module.exports = [
63
63
throw err ;
64
64
}
65
65
66
+ if ( [ 'canceled' , 'fulfilled' ] . includes ( copilotRequest . status ) ) {
67
+ const err = new Error ( `Copilot request with status ${ copilotRequest . status } cannot be updated!` ) ;
68
+ err . status = 400 ;
69
+ throw err ;
70
+ }
71
+
66
72
// check if same type of copilot request already exists
67
73
if ( patchData . projectType !== undefined && patchData . projectType !== copilotRequest . data . projectType ) {
68
74
const sameTypeRequest = await models . CopilotRequest . findOne ( {
@@ -87,6 +93,11 @@ module.exports = [
87
93
}
88
94
}
89
95
96
+ // if type changes, make sure we update "type" on opportunity as well
97
+ if ( patchData . projectType ) {
98
+ patchData . type = patchData . projectType ;
99
+ }
100
+
90
101
// Only update fields provided in patchData
91
102
await copilotRequest . update ( _ . assign ( {
92
103
data : _ . assign ( copilotRequest . data , patchData ) ,
You can’t perform that action at this time.
0 commit comments