Fix a bug caused by setting staleTime to zero (#388)

This commit is contained in:
Kerem Yilmaz
2024-05-29 11:04:12 -07:00
committed by GitHub
parent f13dffb3ef
commit caa974974c
2 changed files with 19 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ function CreateNewTaskFormPage() {
.then((response) => response.data);
},
enabled: !!template && !sampleCases.includes(template as SampleCase),
refetchOnWindowFocus: false,
});
if (!template) {

View File

@@ -38,6 +38,7 @@ import {
webhookCallbackUrlDescription,
} from "../data/descriptionHelperContent";
import { SubmitEvent } from "@/types";
import { AxiosError } from "axios";
const savedTaskFormSchema = z
.object({
@@ -148,7 +149,23 @@ function SavedTaskForm({ initialValues }: Props) {
{ data: { task_id: string } }
>("/tasks", taskRequest);
},
onError: (error) => {
onError: (error: AxiosError) => {
if (error.response?.status === 402) {
toast({
variant: "destructive",
title: "Failed to create task",
description:
"You don't have enough credits to run this task. Go to billing to see your credit balance.",
action: (
<ToastAction altText="Go to Billing">
<Button asChild>
<Link to="billing">Go to Billing</Link>
</Button>
</ToastAction>
),
});
return;
}
toast({
variant: "destructive",
title: "Error",