mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: use rr actions/loader
refactor: use rr actions
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { type Options, getApiV1Volumes } from "../sdk.gen";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import type { GetApiV1VolumesData } from "../types.gen";
|
||||
import { type Options, listVolumes, createVolume } from "../sdk.gen";
|
||||
import {
|
||||
queryOptions,
|
||||
type UseMutationOptions,
|
||||
type DefaultError,
|
||||
} from "@tanstack/react-query";
|
||||
import type {
|
||||
ListVolumesData,
|
||||
CreateVolumeData,
|
||||
CreateVolumeResponse,
|
||||
} from "../types.gen";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
@@ -46,19 +54,16 @@ const createQueryKey = <TOptions extends Options>(
|
||||
return [params];
|
||||
};
|
||||
|
||||
export const getApiV1VolumesQueryKey = (
|
||||
options?: Options<GetApiV1VolumesData>,
|
||||
) => createQueryKey("getApiV1Volumes", options);
|
||||
export const listVolumesQueryKey = (options?: Options<ListVolumesData>) =>
|
||||
createQueryKey("listVolumes", options);
|
||||
|
||||
/**
|
||||
* List all volumes
|
||||
*/
|
||||
export const getApiV1VolumesOptions = (
|
||||
options?: Options<GetApiV1VolumesData>,
|
||||
) => {
|
||||
export const listVolumesOptions = (options?: Options<ListVolumesData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getApiV1Volumes({
|
||||
const { data } = await listVolumes({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
@@ -66,6 +71,54 @@ export const getApiV1VolumesOptions = (
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getApiV1VolumesQueryKey(options),
|
||||
queryKey: listVolumesQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createVolumeQueryKey = (options?: Options<CreateVolumeData>) =>
|
||||
createQueryKey("createVolume", options);
|
||||
|
||||
/**
|
||||
* Create a new volume
|
||||
*/
|
||||
export const createVolumeOptions = (options?: Options<CreateVolumeData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createVolume({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createVolumeQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new volume
|
||||
*/
|
||||
export const createVolumeMutation = (
|
||||
options?: Partial<Options<CreateVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await createVolume({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user