"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 CreateSambaDialogProps { open: boolean onOpenChange: (open: boolean) => void onCreated: (share: any) => void } export default function CreateSambaDialog({ open, onOpenChange, onCreated, }: CreateSambaDialogProps) { const [name, setName] = useState("") const [path, setPath] = useState("") const [comment, setComment] = useState("") const [loading, setLoading] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") if (!name.trim()) { setError("Share name is required") return } if (!path.trim()) { setError("Path is required") return } try { setLoading(true) await api.createSambaShare({ name, path, comment: comment || undefined }) // Return the created share onCreated({ name, path, comment: comment || null, valid_users: null, read_only: false, }) // Reset form setName("") setPath("") setComment("") onOpenChange(false) } catch (err) { setError(err instanceof Error ? err.message : "Failed to create share") } finally { setLoading(false) } } if (!open) return null return (
Create Samba Share
{error && (

{error}

)}
setName(e.target.value)} placeholder="e.g., share, media, backup" className="w-full px-3 py-2 border border-border rounded bg-background text-sm" disabled={loading} />

Alphanumeric, max 15 characters

setPath(e.target.value)} placeholder="e.g., /tank/share" className="w-full px-3 py-2 border border-border rounded bg-background text-sm" disabled={loading} />

Must be an existing filesystem path

setComment(e.target.value)} placeholder="Share description" className="w-full px-3 py-2 border border-border rounded bg-background text-sm" disabled={loading} />

Default permissions: Read/Write, authenticated users only

) }