feat: route to override immediately after checking (#39)

This commit is contained in:
PuerNya 2023-08-30 15:49:53 +08:00 committed by GitHub
parent b64cfa3f9a
commit b178161dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,27 +18,21 @@ export default () => {
const { form } = createForm<z.infer<typeof schema>>({ const { form } = createForm<z.infer<typeof schema>>({
extend: validator({ schema }), extend: validator({ schema }),
async onSubmit(values) { async onSubmit({ url, secret }) {
const { ok } = await ky.get(values.url, { const { ok } = await ky.get(url, {
headers: values.secret headers: secret
? { ? {
Authorization: `Bearer ${values.secret}`, Authorization: `Bearer ${secret}`,
} }
: {}, : {},
}) })
if (!ok) { if (!ok) return 1
return
}
setEndpointList([ const id = uuid()
{ setEndpointList([{ id, url, secret }, ...endpointList()])
id: uuid(), setSelectedEndpoint(id)
url: values.url, navigate('/overview')
secret: values.secret,
},
...endpointList(),
])
}, },
}) })