wip 7
This commit is contained in:
@@ -59,6 +59,7 @@ import type {
|
||||
SearchResponse,
|
||||
SettingsResponse,
|
||||
StreaksResponse,
|
||||
UpdateSettingsRequest,
|
||||
UpdateUserBody,
|
||||
UserStatisticsResponse,
|
||||
UsersResponse
|
||||
@@ -684,6 +685,68 @@ export function useGetSettings<TData = Awaited<ReturnType<typeof getSettings>>,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @summary Update user settings
|
||||
*/
|
||||
export const updateSettings = (
|
||||
updateSettingsRequest: UpdateSettingsRequest, options?: AxiosRequestConfig
|
||||
): Promise<AxiosResponse<SettingsResponse>> => {
|
||||
|
||||
|
||||
return axios.default.put(
|
||||
`/api/v1/settings`,
|
||||
updateSettingsRequest,options
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getUpdateSettingsMutationOptions = <TError = AxiosError<ErrorResponse>,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateSettings>>, TError,{data: UpdateSettingsRequest}, TContext>, axios?: AxiosRequestConfig}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof updateSettings>>, TError,{data: UpdateSettingsRequest}, TContext> => {
|
||||
|
||||
const mutationKey = ['updateSettings'];
|
||||
const {mutation: mutationOptions, axios: axiosOptions} = options ?
|
||||
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
||||
options
|
||||
: {...options, mutation: {...options.mutation, mutationKey}}
|
||||
: {mutation: { mutationKey, }, axios: undefined};
|
||||
|
||||
|
||||
|
||||
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof updateSettings>>, {data: UpdateSettingsRequest}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return updateSettings(data,axiosOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type UpdateSettingsMutationResult = NonNullable<Awaited<ReturnType<typeof updateSettings>>>
|
||||
export type UpdateSettingsMutationBody = UpdateSettingsRequest
|
||||
export type UpdateSettingsMutationError = AxiosError<ErrorResponse>
|
||||
|
||||
/**
|
||||
* @summary Update user settings
|
||||
*/
|
||||
export const useUpdateSettings = <TError = AxiosError<ErrorResponse>,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateSettings>>, TError,{data: UpdateSettingsRequest}, TContext>, axios?: AxiosRequestConfig}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof updateSettings>>,
|
||||
TError,
|
||||
{data: UpdateSettingsRequest},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getUpdateSettingsMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary User login
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,9 @@ export interface Document {
|
||||
id: string;
|
||||
title: string;
|
||||
author: string;
|
||||
description?: string;
|
||||
isbn10?: string;
|
||||
isbn13?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted: boolean;
|
||||
@@ -17,4 +20,7 @@ export interface Document {
|
||||
filepath?: string;
|
||||
percentage?: number;
|
||||
total_time_seconds?: number;
|
||||
wpm?: number;
|
||||
seconds_per_percent?: number;
|
||||
last_read?: string;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ export * from './searchResponse';
|
||||
export * from './setting';
|
||||
export * from './settingsResponse';
|
||||
export * from './streaksResponse';
|
||||
export * from './updateSettingsRequest';
|
||||
export * from './updateUserBody';
|
||||
export * from './user';
|
||||
export * from './userData';
|
||||
|
||||
13
frontend/src/generated/model/updateSettingsRequest.ts
Normal file
13
frontend/src/generated/model/updateSettingsRequest.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* AnthoLume API v1
|
||||
* REST API for AnthoLume document management system
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*/
|
||||
|
||||
export interface UpdateSettingsRequest {
|
||||
password?: string;
|
||||
new_password?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user