- Added PatchedProduct, PatchedProductImage, PatchedRefund, and related models. - Introduced Payment, PaymentBody, PaymentCreate, and PaymentRead models. - Created enums for payment methods, reasons for refunds, roles, and shipping methods. - Implemented models for site configurations and their opening hours. - Added ZasilkovnaPacket and ZasilkovnaShipment models for handling shipping data. - Generated user registration model with validation rules. - Updated public API functions to support new models and queries.
257 lines
6.6 KiB
TypeScript
257 lines
6.6 KiB
TypeScript
/**
|
|
* Generated by orval v7.17.0 🍺
|
|
* Do not edit manually.
|
|
* OpenAPI spec version: 0.0.0
|
|
*/
|
|
import { useMutation } from "@tanstack/react-query";
|
|
import type {
|
|
MutationFunction,
|
|
QueryClient,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
} from "@tanstack/react-query";
|
|
|
|
import type { CustomTokenObtainPair } from "./models";
|
|
|
|
import { publicMutator } from "../../publicClient";
|
|
|
|
/**
|
|
* Authenticate user and obtain JWT access and refresh tokens. You can use either email or username.
|
|
* @summary Obtain JWT access and refresh tokens (cookie-based)
|
|
*/
|
|
export const apiAccountLoginCreate = (
|
|
customTokenObtainPair: CustomTokenObtainPair,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return publicMutator<CustomTokenObtainPair>({
|
|
url: `/api/account/login/`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: customTokenObtainPair,
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getApiAccountLoginCreateMutationOptions = <
|
|
TError = void,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
|
TError,
|
|
{ data: CustomTokenObtainPair },
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
|
TError,
|
|
{ data: CustomTokenObtainPair },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["apiAccountLoginCreate"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
|
{ data: CustomTokenObtainPair }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return apiAccountLoginCreate(data);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type ApiAccountLoginCreateMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>
|
|
>;
|
|
export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair;
|
|
export type ApiAccountLoginCreateMutationError = void;
|
|
|
|
/**
|
|
* @summary Obtain JWT access and refresh tokens (cookie-based)
|
|
*/
|
|
export const useApiAccountLoginCreate = <TError = void, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
|
TError,
|
|
{ data: CustomTokenObtainPair },
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof apiAccountLoginCreate>>,
|
|
TError,
|
|
{ data: CustomTokenObtainPair },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getApiAccountLoginCreateMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* Logs out the user by deleting access and refresh token cookies.
|
|
* @summary Logout user (delete access and refresh token cookies)
|
|
*/
|
|
export const apiAccountLogoutCreate = (signal?: AbortSignal) => {
|
|
return publicMutator<void>({
|
|
url: `/api/account/logout/`,
|
|
method: "POST",
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getApiAccountLogoutCreateMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["apiAccountLogoutCreate"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
|
void
|
|
> = () => {
|
|
return apiAccountLogoutCreate();
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type ApiAccountLogoutCreateMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>
|
|
>;
|
|
|
|
export type ApiAccountLogoutCreateMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Logout user (delete access and refresh token cookies)
|
|
*/
|
|
export const useApiAccountLogoutCreate = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getApiAccountLogoutCreateMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* Refresh JWT access and refresh tokens using the refresh token stored in cookie.
|
|
* @summary Refresh JWT token using cookie
|
|
*/
|
|
export const apiAccountTokenRefreshCreate = (signal?: AbortSignal) => {
|
|
return publicMutator<void>({
|
|
url: `/api/account/token/refresh/`,
|
|
method: "POST",
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getApiAccountTokenRefreshCreateMutationOptions = <
|
|
TError = void,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["apiAccountTokenRefreshCreate"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
|
void
|
|
> = () => {
|
|
return apiAccountTokenRefreshCreate();
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type ApiAccountTokenRefreshCreateMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>
|
|
>;
|
|
|
|
export type ApiAccountTokenRefreshCreateMutationError = void;
|
|
|
|
/**
|
|
* @summary Refresh JWT token using cookie
|
|
*/
|
|
export const useApiAccountTokenRefreshCreate = <
|
|
TError = void,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationOptions =
|
|
getApiAccountTokenRefreshCreateMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|