import { useMutation } from "@tanstack/react-query"; import { Plus } from "lucide-react"; import { useId } from "react"; import { toast } from "sonner"; import { parseError } from "~/client/lib/errors"; import { CreateVolumeForm } from "./create-volume-form"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./ui/dialog"; import { ScrollArea } from "./ui/scroll-area"; import { createVolumeMutation } from "../api-client/@tanstack/react-query.gen"; type Props = { open: boolean; setOpen: (open: boolean) => void; }; export const CreateVolumeDialog = ({ open, setOpen }: Props) => { const formId = useId(); const create = useMutation({ ...createVolumeMutation(), onSuccess: () => { toast.success("Volume created successfully"); setOpen(false); }, onError: (error) => { toast.error("Failed to create volume", { description: parseError(error)?.message, }); }, }); return ( Create volume { create.mutate({ body: { config: values, name: values.name } }); }} /> ); };