import { Dialog } from '@headlessui/react' import { useFetcher } from '@remix-run/react' import clsx from 'clsx' import { useState } from 'react' import Button from '~/components/Button' type Properties = { readonly isEnabled: boolean; // eslint-disable-next-line react/boolean-prop-naming readonly disabled?: boolean; } export default function Modal({ isEnabled, disabled }: Properties) { const [isOpen, setIsOpen] = useState(false) const fetcher = useFetcher() return ( <> { setIsOpen(true) }} > {isEnabled ? 'Disable' : 'Enable'} Magic DNS { setIsOpen(false) }} > {isEnabled ? 'Disable' : 'Enable'} Magic DNS Devices will no longer be accessible via your tailnet domain. The search domain will also be disabled. { fetcher.submit({ // eslint-disable-next-line @typescript-eslint/naming-convention 'dns_config.magic_dns': !isEnabled }, { method: 'PATCH', encType: 'application/json' }) setIsOpen(false) }} > {isEnabled ? 'Disable' : 'Enable'} > ) }