import React, { FormEvent, ReactNode, useState } from 'react'; import { Form, FormField, FormFields } from '@/components/ui/form'; import { useForm } from '@inertiajs/react'; import { Button } from '@/components/ui/button'; import { LoaderCircle } from 'lucide-react'; import { Label } from '@/components/ui/label'; import InputError from '@/components/ui/input-error'; import { Input } from '@/components/ui/input'; import { Command } from '@/types/command'; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { Textarea } from '@/components/ui/textarea'; export default function EditCommand({ command, children }: { command: Command; children: ReactNode }) { const [open, setOpen] = useState(false); const form = useForm<{ name: string; command: string; }>({ name: command.name, command: command.command, }); const submit = (e: FormEvent) => { e.preventDefault(); form.put(route('commands.update', { server: command.server_id, site: command.site_id, command: command.id }), { onSuccess: () => { setOpen(false); }, }); }; return ( {children} Edit command Create a new command
form.setData('name', e.target.value)} />