mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-31 08:56:48 +00:00
feat(client): add updateUserLocation data-provider wiring
This commit is contained in:
parent
fdca6184ba
commit
a4f095a856
6 changed files with 36 additions and 0 deletions
1
client/src/data-provider/Location/index.ts
Normal file
1
client/src/data-provider/Location/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './queries';
|
||||
23
client/src/data-provider/Location/queries.ts
Normal file
23
client/src/data-provider/Location/queries.ts
Normal 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);
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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)}`;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ export enum MutationKeys {
|
|||
enableTwoFactor = 'enableTwoFactor',
|
||||
verifyTwoFactor = 'verifyTwoFactor',
|
||||
updateMemoryPreferences = 'updateMemoryPreferences',
|
||||
updateUserLocation = 'updateUserLocation',
|
||||
createProject = 'createProject',
|
||||
updateProject = 'updateProject',
|
||||
deleteProject = 'deleteProject',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue