SkyeYoung commented on code in PR #3001: URL: https://github.com/apache/apisix-dashboard/pull/3001#discussion_r2062568406
########## src/routes/protos/add.tsx: ########## @@ -0,0 +1,65 @@ +import { createFileRoute } from '@tanstack/react-router'; +import { useTranslation } from 'react-i18next'; +import { req } from '@/config/req'; +import { useMutation } from '@tanstack/react-query'; +import { API_PROTOS } from '@/config/constant'; +import PageHeader from '@/components/page/PageHeader'; +import { FormProvider, useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { FormSubmitBtn } from '@/components/form/Btn'; +import { DevTool } from '@hookform/devtools'; +import { A6Proto } from '@/types/schema/apisix/proto'; +import type { A6Type } from '@/types/schema/apisix'; +import { useRouter as useReactRouter } from '@tanstack/react-router'; +import { FormPartProto } from '@/components/form-slice/FormPartProto'; + +const defaultValues: A6Type['ProtoPost'] = { + content: '', +}; + +const ProtoAddForm = () => { + const { t } = useTranslation(); + const router = useReactRouter(); + + const postProto = useMutation({ + mutationFn: (data: object) => + req.post<A6Type['ProtoPost'], A6Type['RespProtoList']>(API_PROTOS, data), + }); + + const form = useForm({ + resolver: zodResolver(A6Proto.ProtoPost), + shouldUnregister: true, + shouldFocusError: true, + defaultValues, + mode: 'onChange', + }); + + const submit = async (data: A6Type['ProtoPost']) => { + await postProto.mutateAsync(data); Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org