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 = [
6363 throw err ;
6464 }
6565
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+
6672 // check if same type of copilot request already exists
6773 if ( patchData . projectType !== undefined && patchData . projectType !== copilotRequest . data . projectType ) {
6874 const sameTypeRequest = await models . CopilotRequest . findOne ( {
@@ -87,6 +93,11 @@ module.exports = [
8793 }
8894 }
8995
96+ // if type changes, make sure we update "type" on opportunity as well
97+ if ( patchData . projectType ) {
98+ patchData . type = patchData . projectType ;
99+ }
100+
90101 // Only update fields provided in patchData
91102 await copilotRequest . update ( _ . assign ( {
92103 data : _ . assign ( copilotRequest . data , patchData ) ,
You can’t perform that action at this time.
0 commit comments