import { useFetcher } from '@remix-run/react' import { type Dispatch, type SetStateAction } from 'react' import Dialog from '~/components/Dialog' import Switch from '~/components/Switch' import { type Machine, type Route } from '~/types' import { cn } from '~/utils/cn' interface RoutesProps { readonly machine: Machine readonly routes: Route[] readonly state: [boolean, Dispatch>] } // TODO: Support deleting routes export default function Routes({ machine, routes, state }: RoutesProps) { const fetcher = useFetcher() return ( {close => ( <> Edit route settings of {' '} {machine.givenName} Connect to devices you can't install Tailscale on by advertising IP ranges as subnet routes.
{routes.length === 0 ? (

No routes are advertised on this machine.

) : undefined} {routes.map(route => (

{route.prefix}

{ const form = new FormData() form.set('id', machine.id) form.set('_method', 'routes') form.set('route', route.id) form.set('enabled', String(checked)) fetcher.submit(form, { method: 'POST', }) }} />
))}
Close
)}
) }