mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-10-14 14:59:32 +07:00

- Updated HTTP methods for bucket and key operations to align with the official Garage Admin API v2 specifications, changing DELETE methods to POST where necessary. - Modified frontend hooks and documentation to reflect these changes, ensuring consistency across the application. - Completed tasks for verifying and aligning delete operations and reviewing other HTTP methods.
39 lines
870 B
TypeScript
39 lines
870 B
TypeScript
import api from "@/lib/api";
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions,
|
|
useQuery,
|
|
} from "@tanstack/react-query";
|
|
import { Key } from "./types";
|
|
import { CreateKeySchema } from "./schema";
|
|
|
|
export const useKeys = () => {
|
|
return useQuery({
|
|
queryKey: ["keys"],
|
|
queryFn: () => api.get<Key[]>("/v2/ListKeys"),
|
|
});
|
|
};
|
|
|
|
export const useCreateKey = (
|
|
options?: UseMutationOptions<unknown, Error, CreateKeySchema>
|
|
) => {
|
|
return useMutation({
|
|
mutationFn: async (body) => {
|
|
if (body.isImport) {
|
|
return api.post("/v2/ImportKey", { body });
|
|
}
|
|
return api.post("/v2/CreateKey", { body });
|
|
},
|
|
...options,
|
|
});
|
|
};
|
|
|
|
export const useRemoveKey = (
|
|
options?: UseMutationOptions<unknown, Error, string>
|
|
) => {
|
|
return useMutation({
|
|
mutationFn: (id) => api.post("/v2/DeleteKey", { params: { id } }),
|
|
...options,
|
|
});
|
|
};
|