"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card" import { UpdateButton } from "@/components/update-button" import { Terminal } from "lucide-react" import { RoomSelectDialog } from "@/components/room-select-dialog" interface FormSubmitTemplateProps { title: string description: string isLoading?: boolean children: (props: { command: string setCommand: (val: string) => void }) => React.ReactNode onSubmit?: (roomName: string, command: string) => void submitLoading?: boolean rooms?: string[] } export function FormSubmitTemplate({ title, description, isLoading, children, onSubmit, submitLoading, rooms = [], }: FormSubmitTemplateProps) { const [dialogOpen, setDialogOpen] = useState(false) const [command, setCommand] = useState("") const handleClick = () => { if (rooms.length > 0 && onSubmit) { setDialogOpen(true) } } return (

{title}

{description}

Gửi lệnh CMD Nhập và gửi lệnh xuống thiết bị {children({ command, setCommand })} {onSubmit && ( onSubmit("All", command)} loading={submitLoading} label="Cập nhật tất cả thiết bị" /> )} {onSubmit && rooms.length > 0 && ( setDialogOpen(false)} rooms={rooms} onConfirm={(roomName) => { onSubmit(roomName, command) setDialogOpen(false) }} /> )}
) }