diff --git a/skyvern-frontend/src/components/ui/alert.tsx b/skyvern-frontend/src/components/ui/alert.tsx new file mode 100644 index 00000000..9ec492b8 --- /dev/null +++ b/skyvern-frontend/src/components/ui/alert.tsx @@ -0,0 +1,63 @@ +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "@/util/utils"; + +const alertVariants = cva( + "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", + { + variants: { + variant: { + default: "bg-background text-foreground", + destructive: + "bg-destructive border-destructive/50 text-destructive-foreground dark:border-destructive [&>svg]:text-destructive", + success: + "bg-success border-success/50 text-success-foreground dark:border-success [&>svg]:text-success", + warning: + "bg-warning border-warning/50 text-warning-foreground dark:border-warning [&>svg]:text-warning", + }, + }, + defaultVariants: { + variant: "default", + }, + }, +); + +const Alert = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes & VariantProps +>(({ className, variant, ...props }, ref) => ( +
+)); +Alert.displayName = "Alert"; + +const AlertTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +AlertTitle.displayName = "AlertTitle"; + +const AlertDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +AlertDescription.displayName = "AlertDescription"; + +export { Alert, AlertTitle, AlertDescription }; diff --git a/skyvern-frontend/src/components/ui/toast.tsx b/skyvern-frontend/src/components/ui/toast.tsx index 372b8cf2..e543e447 100644 --- a/skyvern-frontend/src/components/ui/toast.tsx +++ b/skyvern-frontend/src/components/ui/toast.tsx @@ -30,6 +30,10 @@ const toastVariants = cva( default: "border bg-background text-foreground", destructive: "destructive group border-destructive bg-destructive text-destructive-foreground", + success: + "success group border-success bg-success text-success-foreground", + warning: + "warning group border-warning bg-warning text-warning-foreground", }, }, defaultVariants: { diff --git a/skyvern-frontend/src/index.css b/skyvern-frontend/src/index.css index 2c2aead2..06b1acf5 100644 --- a/skyvern-frontend/src/index.css +++ b/skyvern-frontend/src/index.css @@ -57,6 +57,12 @@ --accent: 217.2 32.6% 17.5%; --accent-foreground: 210 40% 98%; + --warning: 40.6, 96.1%, 40.4%; + --warning-foreground: 47.9, 95.8%, 53.1%; + + --success: 142.1, 76.2%, 36.3%; + --success-foreground: 141.9, 69.2%, 58%; + --destructive: 0 62.8% 30.6%; --destructive-foreground: 210 40% 98%; diff --git a/skyvern-frontend/src/routes/settings/Settings.tsx b/skyvern-frontend/src/routes/settings/Settings.tsx index e73eb587..4b6571fc 100644 --- a/skyvern-frontend/src/routes/settings/Settings.tsx +++ b/skyvern-frontend/src/routes/settings/Settings.tsx @@ -20,7 +20,7 @@ function Settings() { useSettingsStore(); return ( -
+
Settings diff --git a/skyvern-frontend/src/routes/settings/SettingsPageLayout.tsx b/skyvern-frontend/src/routes/settings/SettingsPageLayout.tsx index 7945597c..055b93dc 100644 --- a/skyvern-frontend/src/routes/settings/SettingsPageLayout.tsx +++ b/skyvern-frontend/src/routes/settings/SettingsPageLayout.tsx @@ -2,7 +2,7 @@ import { Outlet } from "react-router-dom"; function SettingsPageLayout() { return ( -
+
diff --git a/skyvern-frontend/src/routes/tasks/TasksPageLayout.tsx b/skyvern-frontend/src/routes/tasks/TasksPageLayout.tsx index ddd21d15..1757e4c1 100644 --- a/skyvern-frontend/src/routes/tasks/TasksPageLayout.tsx +++ b/skyvern-frontend/src/routes/tasks/TasksPageLayout.tsx @@ -2,7 +2,7 @@ import { Outlet } from "react-router-dom"; function TasksPageLayout() { return ( -
+
diff --git a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx index ba5eb64b..a86229af 100644 --- a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx +++ b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx @@ -36,6 +36,7 @@ import fetchToCurl from "fetch-to-curl"; import { apiBaseUrl } from "@/util/env"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useApiCredential } from "@/hooks/useApiCredential"; +import { AxiosError } from "axios"; const createNewTaskFormSchema = z .object({ @@ -111,7 +112,23 @@ function CreateNewTaskForm({ 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: ( + + + + ), + }); + return; + } toast({ variant: "destructive", title: "There was an error creating the task.", @@ -120,6 +137,7 @@ function CreateNewTaskForm({ initialValues }: Props) { }, onSuccess: (response) => { toast({ + variant: "success", title: "Task Created", description: `${response.data.task_id} created successfully.`, action: ( diff --git a/skyvern-frontend/src/routes/tasks/create/TaskTemplates.tsx b/skyvern-frontend/src/routes/tasks/create/TaskTemplates.tsx index 433f8fd4..6683fec1 100644 --- a/skyvern-frontend/src/routes/tasks/create/TaskTemplates.tsx +++ b/skyvern-frontend/src/routes/tasks/create/TaskTemplates.tsx @@ -43,7 +43,7 @@ function TaskTemplates() { const navigate = useNavigate(); return ( -
+

Skyvern Templates

diff --git a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx index a4de2553..b8f96e8d 100644 --- a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx @@ -54,7 +54,7 @@ function TaskDetails() { } return ( -
+
diff --git a/skyvern-frontend/src/routes/tasks/list/TaskList.tsx b/skyvern-frontend/src/routes/tasks/list/TaskList.tsx index 6025f8f9..4f1c7337 100644 --- a/skyvern-frontend/src/routes/tasks/list/TaskList.tsx +++ b/skyvern-frontend/src/routes/tasks/list/TaskList.tsx @@ -11,7 +11,7 @@ import { TaskHistory } from "./TaskHistory"; function TaskList() { return ( -
+
Running Tasks