feat: make the config patchable
This commit is contained in:
parent
c6435ae2b4
commit
f0c52d8a8b
4 changed files with 113 additions and 22 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import { Switch } from '@headlessui/react'
|
||||
import { useLoaderData } from '@remix-run/react'
|
||||
import { type ActionFunctionArgs } from '@remix-run/node'
|
||||
import { json, useLoaderData } from '@remix-run/react'
|
||||
import clsx from 'clsx'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { getConfig } from '~/utils/config'
|
||||
import { getConfig, patchConfig } from '~/utils/config'
|
||||
|
||||
import MagicModal from './magic'
|
||||
import RenameModal from './rename'
|
||||
|
|
@ -25,6 +26,12 @@ export async function loader() {
|
|||
return dns
|
||||
}
|
||||
|
||||
export async function action({ request }: ActionFunctionArgs) {
|
||||
const data = await request.json() as Record<string, unknown>
|
||||
await patchConfig(data)
|
||||
return json({ success: true })
|
||||
}
|
||||
|
||||
export default function Page() {
|
||||
const data = useLoaderData<typeof loader>()
|
||||
const [localOverride, setLocalOverride] = useState(data.overrideLocal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue