refactor(form): streamline error handling by removing redundant expired state management

This commit is contained in:
twwu 2026-01-27 21:58:15 +08:00
parent e945f3d439
commit fc2acc2c53
1 changed files with 1 additions and 9 deletions

View File

@ -41,12 +41,12 @@ const FormContent = () => {
const [inputs, setInputs] = useState<Record<string, string>>({})
const [success, setSuccess] = useState(false)
const [expired, setExpired] = useState(false)
const { mutate: submitForm, isPending: isSubmitting } = useSubmitHumanInputForm()
const { data: formData, isLoading, error } = useGetHumanInputForm(token)
const expired = (error as HumanInputFormError | null)?.code === 'human_input_form_expired'
const submitted = (error as HumanInputFormError | null)?.code === 'human_input_form_submitted'
const splitByOutputVar = (content: string): string[] => {
@ -86,14 +86,6 @@ const FormContent = () => {
onSuccess: () => {
setSuccess(true)
},
onError: async (error) => {
if (error instanceof Response && error.status && error.json) {
const errorData = await error.json() as { code: string, message: string }
if (errorData.code === 'human_input_form_expired') {
setExpired(true)
}
}
},
},
)
}