2024-08-16 01:23:55 +07:00
|
|
|
import api from "@/lib/api";
|
2024-08-16 23:10:19 +07:00
|
|
|
import {
|
|
|
|
useMutation,
|
|
|
|
UseMutationOptions,
|
|
|
|
useQuery,
|
|
|
|
} from "@tanstack/react-query";
|
2024-08-16 01:23:55 +07:00
|
|
|
import { GetBucketRes } from "./types";
|
2024-08-16 23:10:19 +07:00
|
|
|
import { CreateBucketSchema } from "./schema";
|
2024-08-16 01:23:55 +07:00
|
|
|
|
|
|
|
export const useBuckets = () => {
|
|
|
|
return useQuery({
|
|
|
|
queryKey: ["buckets"],
|
|
|
|
queryFn: () => api.get<GetBucketRes>("/buckets"),
|
|
|
|
});
|
|
|
|
};
|
2024-08-16 23:10:19 +07:00
|
|
|
|
|
|
|
export const useCreateBucket = (
|
|
|
|
options?: UseMutationOptions<any, Error, CreateBucketSchema>
|
|
|
|
) => {
|
|
|
|
return useMutation({
|
|
|
|
mutationFn: (body) => api.post("/v1/bucket", { body }),
|
|
|
|
...options,
|
|
|
|
});
|
|
|
|
};
|