From e6e31107533654c509e2b98d316bbccf3eb7c43a Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Thu, 28 Mar 2024 17:27:40 -0400 Subject: [PATCH] feat: make dns configuration editable --- app/routes/_data.dns._index/route.tsx | 51 +++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/app/routes/_data.dns._index/route.tsx b/app/routes/_data.dns._index/route.tsx index e9e0dcc..c665b06 100644 --- a/app/routes/_data.dns._index/route.tsx +++ b/app/routes/_data.dns._index/route.tsx @@ -1,6 +1,6 @@ import { Switch } from '@headlessui/react' import { type ActionFunctionArgs } from '@remix-run/node' -import { json, useLoaderData } from '@remix-run/react' +import { json, useFetcher, useLoaderData } from '@remix-run/react' import clsx from 'clsx' import { useState } from 'react' @@ -34,10 +34,12 @@ export async function action({ request }: ActionFunctionArgs) { export default function Page() { const data = useLoaderData() + const fetcher = useFetcher({ key: 'dns-page' }) const [localOverride, setLocalOverride] = useState(data.overrideLocal) + const [ns, setNs] = useState('') return ( -
+

Tailnet Name

@@ -81,6 +83,14 @@ export default function Page() { 'relative inline-flex h-4 w-9 items-center rounded-full' )} onChange={() => { + fetcher.submit({ + // eslint-disable-next-line @typescript-eslint/naming-convention + 'dns_config.override_local_dns': !localOverride + }, { + method: 'PATCH', + encType: 'application/json' + }) + setLocalOverride(!localOverride) }} > @@ -94,7 +104,7 @@ export default function Page() {

-
+
{data.nameservers.map((ns, index) => (
))} +
+ { + setNs(event.target.value) + }} + /> + +
{/* TODO: Split DNS and Custom A Records */}