"use client" import { useState } from "react" import { api } from "@/lib/api" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { AlertCircle } from "lucide-react" interface CreateNfsDialogProps { open: boolean onOpenChange: (open: boolean) => void onCreated: (share: any) => void } export default function CreateNfsDialog({ open, onOpenChange, onCreated, }: CreateNfsDialogProps) { const [path, setPath] = useState("") const [clients, setClients] = useState("") const [readonly, setReadonly] = useState(false) const [sync, setSync] = useState(true) const [loading, setLoading] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") if (!path.trim()) { setError("Path is required") return } if (!clients.trim()) { setError("Clients are required") return } // Build options const opts = [] opts.push(readonly ? "ro" : "rw") opts.push(sync ? "sync" : "async") opts.push("no_subtree_check") const options = opts.join(",") try { setLoading(true) await api.createNfsShare({ path, clients, options }) onCreated({ path, clients, options, }) setPath("") setClients("") setReadonly(false) setSync(true) onOpenChange(false) } catch (err) { setError(err instanceof Error ? err.message : "Failed to create share") } finally { setLoading(false) } } if (!open) return null return (