import React, { ReactNode, useState } from 'react'; import { useForm } from '@inertiajs/react'; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { LoaderCircleIcon } from 'lucide-react'; import FormSuccessful from '@/components/form-successful'; import { Site } from '@/types/site'; export default function AutoDeployment({ site, children }: { site: Site; children: ReactNode }) { const [open, setOpen] = useState(false); const form = useForm(); const submit = () => { const url = site.auto_deploy ? route('application.disable-auto-deployment', { server: site.server_id, site: site.id, }) : route('application.enable-auto-deployment', { server: site.server_id, site: site.id }); form.post(url, { onSuccess: () => { setOpen(false); }, }); }; return ( {children} {site.auto_deploy ? 'Disable' : 'Enable'} auto deployment {site.auto_deploy ? 'Disable' : 'Enable'} auto deployment

Are you sure you want to {site.auto_deploy ? 'disable' : 'enable'} auto deployment?

); }