"use client"; import { useForm } from "@tanstack/react-form"; import { z } from "zod"; import { Textarea } from "@/components/ui/textarea"; interface ShellCommandFormProps { command: string; onCommandChange: (value: string) => void; disabled?: boolean; } export function ShellCommandForm({ command, onCommandChange, disabled, }: ShellCommandFormProps) { const form = useForm({ defaultValues: { command }, onSubmit: () => {}, }); return (
{ e.preventDefault(); form.handleSubmit(); }} className="space-y-5" > { const schema = z .string() .min(1, "Nhập command để thực thi") .max(500, "Command quá dài"); const result = schema.safeParse(value); if (!result.success) { return result.error.issues.map((i) => i.message); } return []; }, }} children={(field) => (