mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-04-28 06:49:32 +07:00
25 lines
563 B
TypeScript
25 lines
563 B
TypeScript
import api from "@/lib/api";
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions,
|
|
useQuery,
|
|
} from "@tanstack/react-query";
|
|
import { GetBucketRes } from "./types";
|
|
import { CreateBucketSchema } from "./schema";
|
|
|
|
export const useBuckets = () => {
|
|
return useQuery({
|
|
queryKey: ["buckets"],
|
|
queryFn: () => api.get<GetBucketRes>("/buckets"),
|
|
});
|
|
};
|
|
|
|
export const useCreateBucket = (
|
|
options?: UseMutationOptions<any, Error, CreateBucketSchema>
|
|
) => {
|
|
return useMutation({
|
|
mutationFn: (body) => api.post("/v1/bucket", { body }),
|
|
...options,
|
|
});
|
|
};
|