import { useState } from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { useResizeDisk } from '@/hooks/useProxmox' import type { ProxmoxVM, ProxmoxDisk } from '@/types/proxmox' import { formatBytes } from '@/lib/format' interface ResizeDiskDialogProps { open: boolean onOpenChange: (open: boolean) => void vm: ProxmoxVM disk: ProxmoxDisk } export function ResizeDiskDialog({ open, onOpenChange, vm, disk }: ResizeDiskDialogProps) { const currentSizeGB = Math.round(disk.size / (1024 * 1024 * 1024)) const [newSize, setNewSize] = useState(String(currentSizeGB)) const resizeDisk = useResizeDisk() const handleSubmit = (e: React.FormEvent) => { e.preventDefault() const sizeBytes = parseFloat(newSize) * 1024 * 1024 * 1024 resizeDisk.mutate( { node: vm.node, vmid: vm.vmid, vmType: vm.type, disk: disk.device, size: sizeBytes, }, { onSuccess: () => { onOpenChange(false) }, }, ) } return ( Resize Disk Resize {disk.device} on {vm.name} (currently {formatBytes(disk.size)})
setNewSize(e.target.value)} required />

Must be larger than current size ({currentSizeGB} GB)

{resizeDisk.isError && (

Failed to resize disk. Please try again.

)}
) }