feat(client): add updateUserLocation data-provider wiring

This commit is contained in:
Marco Beretta 2026-06-15 18:45:13 +02:00
parent fdca6184ba
commit a4f095a856
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
6 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1 @@
export * from './queries';

View file

@ -0,0 +1,23 @@
import { useQueryClient, useMutation } from '@tanstack/react-query';
import { QueryKeys, MutationKeys, dataService } from 'librechat-data-provider';
import type { UseMutationOptions } from '@tanstack/react-query';
import type { TUserLocation } from 'librechat-data-provider';
export type UpdateUserLocationResponse = { updated: boolean; location?: TUserLocation };
export const useUpdateUserLocationMutation = (
options?: UseMutationOptions<UpdateUserLocationResponse, Error, TUserLocation>,
) => {
const queryClient = useQueryClient();
return useMutation<UpdateUserLocationResponse, Error, TUserLocation>(
[MutationKeys.updateUserLocation],
(location: TUserLocation) => dataService.updateUserLocation(location),
{
...options,
onSuccess: (...params) => {
queryClient.invalidateQueries([QueryKeys.user]);
options?.onSuccess?.(...params);
},
},
);
};

View file

@ -3,6 +3,8 @@ export * from './Agents';
export * from './Endpoints';
export * from './Skills';
export * from './Files';
/* Location */
export * from './Location';
/* Memories */
export * from './Memories';
export * from './Messages';

View file

@ -473,6 +473,9 @@ export const disableTwoFactor = () => `${BASE_URL}/api/auth/2fa/disable`;
export const regenerateBackupCodes = () => `${BASE_URL}/api/auth/2fa/backup/regenerate`;
export const verifyTwoFactorTemp = () => `${BASE_URL}/api/auth/2fa/verify-temp`;
/* User location */
export const userLocation = () => `${BASE_URL}/api/user/settings/location`;
/* Memories */
export const memories = () => `${BASE_URL}/api/memories`;
export const memory = (key: string) => `${memories()}/${encodeURIComponent(key)}`;

View file

@ -1277,6 +1277,12 @@ export const updateMemoryPreferences = (preferences: {
return request.patch(endpoints.memoryPreferences(), preferences);
};
export const updateUserLocation = (
location: t.TUserLocation,
): Promise<{ updated: boolean; location?: t.TUserLocation }> => {
return request.patch(endpoints.userLocation(), location);
};
export const createMemory = (data: {
key: string;
value: string;

View file

@ -116,6 +116,7 @@ export enum MutationKeys {
enableTwoFactor = 'enableTwoFactor',
verifyTwoFactor = 'verifyTwoFactor',
updateMemoryPreferences = 'updateMemoryPreferences',
updateUserLocation = 'updateUserLocation',
createProject = 'createProject',
updateProject = 'updateProject',
deleteProject = 'deleteProject',