@@ -125,9 +125,20 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
125
125
handleChangePrompt ( urlPrompt )
126
126
}
127
127
} , [ mandatoryPrompt , urlPrompt ] )
128
-
128
+ const handleClose = async ( ) => {
129
+ //handles if the user wants to update current promts
130
+ if ( activePrompt ) {
131
+ console . log ( 'updating active promt' )
132
+ await promptSaveMutation . mutateAsync ( { name : activePrompt . name , promptToSave : activePrompt } )
133
+ }
134
+ //default promt is not a saved promt so this handles the change to it
135
+ else if ( instructionsInputFieldRef . current ) {
136
+ setAssistantInstructions ( instructionsInputFieldRef . current . value )
137
+ }
138
+ setOpen ( false )
139
+ }
129
140
return (
130
- < Modal open = { open } onClose = { ( ) => setOpen ( false ) } >
141
+ < Modal open = { open } onClose = { handleClose } >
131
142
< Box
132
143
sx = { {
133
144
position : 'absolute' ,
@@ -149,7 +160,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
149
160
} }
150
161
>
151
162
< IconButton
152
- onClick = { ( ) => setOpen ( false ) }
163
+ onClick = { handleClose }
153
164
sx = { { position : 'absolute' , top : 10 , right : 20 , color : 'grey.500' , background : '#FFF' , opacity : 0.9 , zIndex : 1 } }
154
165
id = "close-settings"
155
166
>
@@ -238,7 +249,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
238
249
>
239
250
{ t ( 'settings:resetDefault' ) }
240
251
</ OutlineButtonBlack > { ' ' }
241
- < BlueButton onClick = { ( ) => setOpen ( false ) } > OK</ BlueButton >
252
+ < BlueButton onClick = { handleClose } > OK</ BlueButton >
242
253
</ Box >
243
254
< SaveMyPromptModal
244
255
isOpen = { myPromptModalOpen }
0 commit comments