Skip to content

Commit fc2acc2

Browse files
committed
refactor(form): streamline error handling by removing redundant expired state management
1 parent e945f3d commit fc2acc2

File tree

1 file changed

+1
-9
lines changed
  • web/app/(humanInputLayout)/form/[token]

1 file changed

+1
-9
lines changed

web/app/(humanInputLayout)/form/[token]/form.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ const FormContent = () => {
4141

4242
const [inputs, setInputs] = useState<Record<string, string>>({})
4343
const [success, setSuccess] = useState(false)
44-
const [expired, setExpired] = useState(false)
4544

4645
const { mutate: submitForm, isPending: isSubmitting } = useSubmitHumanInputForm()
4746

4847
const { data: formData, isLoading, error } = useGetHumanInputForm(token)
4948

49+
const expired = (error as HumanInputFormError | null)?.code === 'human_input_form_expired'
5050
const submitted = (error as HumanInputFormError | null)?.code === 'human_input_form_submitted'
5151

5252
const splitByOutputVar = (content: string): string[] => {
@@ -86,14 +86,6 @@ const FormContent = () => {
8686
onSuccess: () => {
8787
setSuccess(true)
8888
},
89-
onError: async (error) => {
90-
if (error instanceof Response && error.status && error.json) {
91-
const errorData = await error.json() as { code: string, message: string }
92-
if (errorData.code === 'human_input_form_expired') {
93-
setExpired(true)
94-
}
95-
}
96-
},
9789
},
9890
)
9991
}

0 commit comments

Comments
 (0)