import { useMutation } from "@tanstack/react-query"; import { useId } from "react"; import { toast } from "sonner"; import type { GetVolumeResponse } from "~/api-client"; import { updateVolumeMutation } from "~/api-client/@tanstack/react-query.gen"; import { parseError } from "~/lib/errors"; import { CreateVolumeForm } from "./create-volume-form"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./ui/dialog"; type Props = { open: boolean; setOpen: (open: boolean) => void; initialValues?: Partial; }; export const EditVolumeDialog = ({ open, setOpen, initialValues }: Props) => { const formId = useId(); const update = useMutation({ ...updateVolumeMutation(), onSuccess: () => { toast.success("Volume updated successfully"); setOpen(false); }, onError: (error) => { toast.error("Failed to update volume", { description: parseError(error)?.message, }); }, }); return ( Create volume Enter a name for the new volume { update.mutate({ body: { config: values }, path: { name: values.name } }); }} /> ); };