Fix issue with saving AI model selection in settings

Update `saveOpenrouterMutation` in `client/src/pages/settings.tsx` to conditionally include `apiKey` in the payload only if it's not empty, resolving the bug where AI model selection was not persisting.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/4KAFpKS
This commit is contained in:
michaelschal committed 2025-10-02 07:28:46 +00:00
1 parent 8a40860afa
commit dec97ca71e
1 file changed
+11 -4
+11 -4
View File
@@ -79,12 +79,19 @@ export default function Settings() {
});
const saveOpenrouterMutation = useMutation({
mutationFn: () =>
apiRequest('POST', '/api/openrouter/config', {
apiKey: openrouterApiKey,
mutationFn: () => {
const payload: any = {
model: openrouterModel,
systemPrompt: openrouterSystemPrompt,
}),
};
// N'inclure apiKey que s'il n'est pas vide
if (openrouterApiKey && openrouterApiKey.trim() !== "") {
payload.apiKey = openrouterApiKey;
}
return apiRequest('POST', '/api/openrouter/config', payload);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['/api/openrouter/config'] });
toast({