feat: add bucket browser

This commit is contained in:
2024-08-19 02:28:25 +07:00
parent 934e0c409c
commit 93a1dce5f7
35 changed files with 770 additions and 137 deletions
@@ -12,13 +12,14 @@ import { useAllowKey } from "../hooks";
import { toast } from "sonner";
import { handleError } from "@/lib/utils";
import { useQueryClient } from "@tanstack/react-query";
import { useBucketContext } from "../context";
type Props = {
id?: string;
currentKeys?: string[];
};
const AllowKeyDialog = ({ id, currentKeys }: Props) => {
const AllowKeyDialog = ({ currentKeys }: Props) => {
const { bucket } = useBucketContext();
const { dialogRef, isOpen, onOpen, onClose } = useDisclosure();
const { data: keys } = useKeys();
const form = useForm<AllowKeysSchema>({
@@ -30,12 +31,12 @@ const AllowKeyDialog = ({ id, currentKeys }: Props) => {
});
const queryClient = useQueryClient();
const allowKey = useAllowKey(id, {
const allowKey = useAllowKey(bucket.id, {
onSuccess: () => {
form.reset();
onClose();
toast.success("Key allowed!");
queryClient.invalidateQueries({ queryKey: ["bucket", id] });
queryClient.invalidateQueries({ queryKey: ["bucket", bucket.id] });
},
onError: handleError,
});