feat(config): toast error message when dns query failed for some reason, closes #321

This commit is contained in:
kunish 2023-10-04 18:16:37 +08:00
parent fd235311d8
commit 82c2772afe
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -9,6 +9,7 @@ import {
createSignal, createSignal,
onMount, onMount,
} from 'solid-js' } from 'solid-js'
import { toast } from 'solid-toast'
import { z } from 'zod' import { z } from 'zod'
import { import {
fetchBackendConfigAPI, fetchBackendConfigAPI,
@ -56,7 +57,7 @@ const DNSQueryForm = () => {
const { form, isSubmitting } = createForm<z.infer<typeof dnsQueryFormSchema>>( const { form, isSubmitting } = createForm<z.infer<typeof dnsQueryFormSchema>>(
{ {
extend: validator({ schema: dnsQueryFormSchema }), extend: validator({ schema: dnsQueryFormSchema }),
onSubmit: async (values) => { onSubmit: (values) =>
request request
.get('dns/query', { .get('dns/query', {
searchParams: { name: values.name, type: values.type }, searchParams: { name: values.name, type: values.type },
@ -65,7 +66,7 @@ const DNSQueryForm = () => {
.then(({ Answer }) => .then(({ Answer }) =>
setDNSQueryResult(Answer?.map(({ data }) => data) || []), setDNSQueryResult(Answer?.map(({ data }) => data) || []),
) )
}, .catch((err) => toast.error(err.message)),
}, },
) )