2024-09-30 07:12:01 -07:00
|
|
|
import { getClient } from "@/api/AxiosClient";
|
2024-09-30 09:08:27 -07:00
|
|
|
import { CreateTaskRequest } from "@/api/types";
|
2024-09-30 07:12:01 -07:00
|
|
|
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
|
2024-04-01 21:34:52 +03:00
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import {
|
|
|
|
|
Form,
|
|
|
|
|
FormControl,
|
|
|
|
|
FormField,
|
|
|
|
|
FormItem,
|
|
|
|
|
FormLabel,
|
|
|
|
|
FormMessage,
|
|
|
|
|
} from "@/components/ui/form";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
2024-09-30 09:08:27 -07:00
|
|
|
import { Separator } from "@/components/ui/separator";
|
2024-04-01 21:34:52 +03:00
|
|
|
import { useToast } from "@/components/ui/use-toast";
|
2024-05-14 05:02:12 -07:00
|
|
|
import { useApiCredential } from "@/hooks/useApiCredential";
|
2024-09-30 07:12:01 -07:00
|
|
|
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
|
|
|
|
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
|
|
|
|
|
import { copyText } from "@/util/copyText";
|
|
|
|
|
import { apiBaseUrl } from "@/util/env";
|
|
|
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
|
|
import { ReloadIcon } from "@radix-ui/react-icons";
|
|
|
|
|
import { ToastAction } from "@radix-ui/react-toast";
|
|
|
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
2024-05-29 09:34:58 -07:00
|
|
|
import { AxiosError } from "axios";
|
2024-09-30 07:12:01 -07:00
|
|
|
import fetchToCurl from "fetch-to-curl";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import { useForm, useFormState } from "react-hook-form";
|
|
|
|
|
import { Link } from "react-router-dom";
|
2024-06-21 13:08:00 -07:00
|
|
|
import { MAX_STEPS_DEFAULT } from "../constants";
|
2024-09-30 07:12:01 -07:00
|
|
|
import { TaskFormSection } from "./TaskFormSection";
|
2024-09-30 09:08:27 -07:00
|
|
|
import {
|
|
|
|
|
createNewTaskFormSchema,
|
|
|
|
|
CreateNewTaskFormValues,
|
|
|
|
|
} from "./taskFormTypes";
|
2024-04-01 21:34:52 +03:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
initialValues: CreateNewTaskFormValues;
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-30 09:08:27 -07:00
|
|
|
function transform<T>(value: T): T | null {
|
2024-05-20 13:50:21 -07:00
|
|
|
return value === "" ? null : value;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-30 09:08:27 -07:00
|
|
|
function createTaskRequestObject(
|
|
|
|
|
formValues: CreateNewTaskFormValues,
|
|
|
|
|
): CreateTaskRequest {
|
2024-06-24 05:07:21 -07:00
|
|
|
let extractedInformationSchema = null;
|
|
|
|
|
if (formValues.extractedInformationSchema) {
|
|
|
|
|
try {
|
|
|
|
|
extractedInformationSchema = JSON.parse(
|
|
|
|
|
formValues.extractedInformationSchema,
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
extractedInformationSchema = formValues.extractedInformationSchema;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-30 09:08:27 -07:00
|
|
|
let errorCodeMapping = null;
|
|
|
|
|
if (formValues.errorCodeMapping) {
|
|
|
|
|
try {
|
|
|
|
|
errorCodeMapping = JSON.parse(formValues.errorCodeMapping);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
errorCodeMapping = formValues.errorCodeMapping;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-24 05:07:21 -07:00
|
|
|
|
2024-04-01 21:34:52 +03:00
|
|
|
return {
|
2024-09-30 09:08:27 -07:00
|
|
|
title: null,
|
2024-04-01 21:34:52 +03:00
|
|
|
url: formValues.url,
|
2024-05-20 13:50:21 -07:00
|
|
|
webhook_callback_url: transform(formValues.webhookCallbackUrl),
|
|
|
|
|
navigation_goal: transform(formValues.navigationGoal),
|
|
|
|
|
data_extraction_goal: transform(formValues.dataExtractionGoal),
|
2024-06-03 22:15:48 +03:00
|
|
|
proxy_location: "RESIDENTIAL",
|
2024-05-20 13:50:21 -07:00
|
|
|
navigation_payload: transform(formValues.navigationPayload),
|
2024-06-24 05:07:21 -07:00
|
|
|
extracted_information_schema: extractedInformationSchema,
|
2024-09-30 07:12:01 -07:00
|
|
|
totp_verification_url: transform(formValues.totpVerificationUrl),
|
|
|
|
|
totp_identifier: transform(formValues.totpIdentifier),
|
2024-09-30 09:08:27 -07:00
|
|
|
error_code_mapping: errorCodeMapping,
|
2024-04-01 21:34:52 +03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CreateNewTaskForm({ initialValues }: Props) {
|
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
|
const { toast } = useToast();
|
2024-05-07 11:31:05 -07:00
|
|
|
const credentialGetter = useCredentialGetter();
|
2024-05-14 05:02:12 -07:00
|
|
|
const apiCredential = useApiCredential();
|
2024-09-30 08:19:03 -07:00
|
|
|
const [section, setSection] = useState<"base" | "extraction" | "advanced">(
|
|
|
|
|
"base",
|
|
|
|
|
);
|
2024-06-20 09:24:39 -07:00
|
|
|
|
2024-04-01 21:34:52 +03:00
|
|
|
const form = useForm<CreateNewTaskFormValues>({
|
|
|
|
|
resolver: zodResolver(createNewTaskFormSchema),
|
|
|
|
|
defaultValues: initialValues,
|
2024-06-20 09:24:39 -07:00
|
|
|
values: {
|
|
|
|
|
...initialValues,
|
2024-09-30 07:12:01 -07:00
|
|
|
maxStepsOverride: MAX_STEPS_DEFAULT,
|
2024-06-20 09:24:39 -07:00
|
|
|
},
|
2024-04-01 21:34:52 +03:00
|
|
|
});
|
2024-09-30 07:12:01 -07:00
|
|
|
const { errors } = useFormState({ control: form.control });
|
2024-04-01 21:34:52 +03:00
|
|
|
|
|
|
|
|
const mutation = useMutation({
|
2024-05-07 11:31:05 -07:00
|
|
|
mutationFn: async (formValues: CreateNewTaskFormValues) => {
|
2024-04-01 21:34:52 +03:00
|
|
|
const taskRequest = createTaskRequestObject(formValues);
|
2024-05-07 11:31:05 -07:00
|
|
|
const client = await getClient(credentialGetter);
|
2024-06-20 09:24:39 -07:00
|
|
|
const includeOverrideHeader =
|
|
|
|
|
formValues.maxStepsOverride !== MAX_STEPS_DEFAULT;
|
2024-04-01 21:34:52 +03:00
|
|
|
return client.post<
|
|
|
|
|
ReturnType<typeof createTaskRequestObject>,
|
|
|
|
|
{ data: { task_id: string } }
|
2024-06-20 09:24:39 -07:00
|
|
|
>("/tasks", taskRequest, {
|
|
|
|
|
...(includeOverrideHeader && {
|
|
|
|
|
headers: {
|
|
|
|
|
"x-max-steps-override":
|
|
|
|
|
formValues.maxStepsOverride ?? MAX_STEPS_DEFAULT,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
});
|
2024-04-01 21:34:52 +03:00
|
|
|
},
|
2024-05-29 09:34:58 -07:00
|
|
|
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;
|
|
|
|
|
}
|
2024-04-01 21:34:52 +03:00
|
|
|
toast({
|
|
|
|
|
variant: "destructive",
|
2024-05-20 08:27:36 -07:00
|
|
|
title: "There was an error creating the task.",
|
2024-04-01 21:34:52 +03:00
|
|
|
description: error.message,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (response) => {
|
|
|
|
|
toast({
|
2024-05-29 09:34:58 -07:00
|
|
|
variant: "success",
|
2024-04-01 21:34:52 +03:00
|
|
|
title: "Task Created",
|
|
|
|
|
description: `${response.data.task_id} created successfully.`,
|
|
|
|
|
action: (
|
|
|
|
|
<ToastAction altText="View">
|
|
|
|
|
<Button asChild>
|
|
|
|
|
<Link to={`/tasks/${response.data.task_id}`}>View</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
</ToastAction>
|
|
|
|
|
),
|
|
|
|
|
});
|
|
|
|
|
queryClient.invalidateQueries({
|
|
|
|
|
queryKey: ["tasks"],
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function onSubmit(values: CreateNewTaskFormValues) {
|
|
|
|
|
mutation.mutate(values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Form {...form}>
|
2024-09-30 07:12:01 -07:00
|
|
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
|
|
|
|
<TaskFormSection
|
|
|
|
|
index={1}
|
|
|
|
|
title="Base Content"
|
2024-09-30 08:19:03 -07:00
|
|
|
active={section === "base"}
|
2024-09-30 07:12:01 -07:00
|
|
|
onClick={() => {
|
2024-09-30 08:19:03 -07:00
|
|
|
setSection("base");
|
2024-09-30 07:12:01 -07:00
|
|
|
}}
|
|
|
|
|
hasError={
|
|
|
|
|
typeof errors.url !== "undefined" ||
|
|
|
|
|
typeof errors.navigationGoal !== "undefined"
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-09-30 08:19:03 -07:00
|
|
|
{section === "base" && (
|
2024-09-30 07:12:01 -07:00
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="url"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">URL</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
The starting URL for the task
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Input placeholder="https://" {...field} />
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="navigationGoal"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Navigation Goal</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
Where should Skyvern go and what should Skyvern
|
|
|
|
|
do?
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<AutoResizingTextarea
|
|
|
|
|
placeholder="Use terms like complete or terminate to give completion directions"
|
|
|
|
|
{...field}
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
2024-05-20 08:27:36 -07:00
|
|
|
/>
|
2024-09-30 07:12:01 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-01 21:34:52 +03:00
|
|
|
)}
|
2024-09-30 07:12:01 -07:00
|
|
|
</TaskFormSection>
|
|
|
|
|
<TaskFormSection
|
|
|
|
|
index={2}
|
|
|
|
|
title="Extraction"
|
2024-09-30 08:19:03 -07:00
|
|
|
active={section === "extraction"}
|
2024-09-30 07:12:01 -07:00
|
|
|
onClick={() => {
|
2024-09-30 08:19:03 -07:00
|
|
|
setSection("extraction");
|
2024-09-30 07:12:01 -07:00
|
|
|
}}
|
|
|
|
|
hasError={
|
|
|
|
|
typeof errors.dataExtractionGoal !== "undefined" ||
|
|
|
|
|
typeof errors.extractedInformationSchema !== "undefined"
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-09-30 08:19:03 -07:00
|
|
|
{section === "extraction" && (
|
2024-09-30 07:12:01 -07:00
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="dataExtractionGoal"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Data Extraction Goal</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
What outputs are you looking to get?
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<AutoResizingTextarea
|
|
|
|
|
placeholder="e.g. Extract the product price..."
|
|
|
|
|
{...field}
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="extractedInformationSchema"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Data Schema</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
Specify the output format in JSON
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<CodeEditor
|
|
|
|
|
{...field}
|
|
|
|
|
language="json"
|
|
|
|
|
fontSize={12}
|
|
|
|
|
minHeight="96px"
|
2024-09-30 09:08:27 -07:00
|
|
|
value={field.value === null ? "" : field.value}
|
2024-09-30 07:12:01 -07:00
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
2024-04-01 21:34:52 +03:00
|
|
|
/>
|
2024-09-30 07:12:01 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-01 21:34:52 +03:00
|
|
|
)}
|
2024-09-30 07:12:01 -07:00
|
|
|
</TaskFormSection>
|
|
|
|
|
<TaskFormSection
|
|
|
|
|
index={3}
|
|
|
|
|
title="Advanced Settings"
|
2024-09-30 08:19:03 -07:00
|
|
|
active={section === "advanced"}
|
2024-09-30 07:12:01 -07:00
|
|
|
onClick={() => {
|
2024-09-30 08:19:03 -07:00
|
|
|
setSection("advanced");
|
2024-09-30 07:12:01 -07:00
|
|
|
}}
|
|
|
|
|
hasError={
|
|
|
|
|
typeof errors.navigationPayload !== "undefined" ||
|
|
|
|
|
typeof errors.maxStepsOverride !== "undefined" ||
|
2024-09-30 09:08:27 -07:00
|
|
|
typeof errors.webhookCallbackUrl !== "undefined" ||
|
|
|
|
|
typeof errors.errorCodeMapping !== "undefined"
|
2024-09-30 07:12:01 -07:00
|
|
|
}
|
|
|
|
|
>
|
2024-09-30 08:19:03 -07:00
|
|
|
{section === "advanced" && (
|
2024-09-30 07:12:01 -07:00
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="navigationPayload"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Navigation Payload</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
Specify important parameters, routes, or states
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<CodeEditor
|
|
|
|
|
{...field}
|
|
|
|
|
language="json"
|
|
|
|
|
fontSize={12}
|
|
|
|
|
minHeight="96px"
|
2024-09-30 09:08:27 -07:00
|
|
|
value={field.value === null ? "" : field.value}
|
2024-09-30 07:12:01 -07:00
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
2024-08-23 14:41:58 +03:00
|
|
|
</div>
|
2024-09-30 07:12:01 -07:00
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="maxStepsOverride"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Max Steps Override</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
Want to allow this task to execute more or less
|
|
|
|
|
steps than the default?
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Input
|
|
|
|
|
{...field}
|
|
|
|
|
type="number"
|
|
|
|
|
min={1}
|
|
|
|
|
value={field.value}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
field.onChange(parseInt(event.target.value));
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
2024-06-19 19:15:11 +03:00
|
|
|
</div>
|
2024-09-30 07:12:01 -07:00
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="webhookCallbackUrl"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Webhook Callback URL</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
The URL of a webhook endpoint to send the
|
|
|
|
|
extracted information
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="https://"
|
|
|
|
|
{...field}
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
2024-06-19 19:15:11 +03:00
|
|
|
</div>
|
2024-09-30 07:12:01 -07:00
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
2024-09-30 09:08:27 -07:00
|
|
|
<Separator />
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="errorCodeMapping"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">Error Messages</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400">
|
|
|
|
|
Specify any error outputs you would like to be
|
|
|
|
|
notified about
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<CodeEditor
|
|
|
|
|
{...field}
|
|
|
|
|
language="json"
|
|
|
|
|
fontSize={12}
|
|
|
|
|
minHeight="96px"
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<Separator />
|
2024-09-30 07:12:01 -07:00
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="totpVerificationUrl"
|
|
|
|
|
render={({ field }) => (
|
2024-06-20 09:24:39 -07:00
|
|
|
<FormItem>
|
2024-09-30 07:12:01 -07:00
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">TOTP Verification URL</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400"></h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="https://"
|
|
|
|
|
{...field}
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-20 09:24:39 -07:00
|
|
|
</FormItem>
|
2024-09-30 07:12:01 -07:00
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="totpIdentifier"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="flex gap-16">
|
|
|
|
|
<FormLabel>
|
|
|
|
|
<div className="w-72">
|
|
|
|
|
<h1 className="text-lg">TOTP Identifier</h1>
|
|
|
|
|
<h2 className="text-base text-slate-400"></h2>
|
|
|
|
|
</div>
|
|
|
|
|
</FormLabel>
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="Idenfitifer"
|
|
|
|
|
{...field}
|
|
|
|
|
value={field.value === null ? "" : field.value}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</TaskFormSection>
|
2024-06-19 19:15:11 +03:00
|
|
|
|
2024-04-01 21:34:52 +03:00
|
|
|
<div className="flex justify-end gap-3">
|
2024-04-17 00:15:04 +03:00
|
|
|
<Button
|
|
|
|
|
type="button"
|
2024-05-20 08:27:36 -07:00
|
|
|
variant="secondary"
|
2024-04-17 00:15:04 +03:00
|
|
|
onClick={async () => {
|
|
|
|
|
const curl = fetchToCurl({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: `${apiBaseUrl}/tasks`,
|
|
|
|
|
body: createTaskRequestObject(form.getValues()),
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
2024-05-14 05:02:12 -07:00
|
|
|
"x-api-key": apiCredential ?? "<your-api-key>",
|
2024-04-17 00:15:04 +03:00
|
|
|
},
|
|
|
|
|
});
|
2024-09-11 20:01:45 +03:00
|
|
|
copyText(curl).then(() => {
|
|
|
|
|
toast({
|
|
|
|
|
title: "Copied cURL",
|
|
|
|
|
description: "cURL copied to clipboard",
|
|
|
|
|
});
|
2024-04-17 00:15:04 +03:00
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Copy cURL
|
|
|
|
|
</Button>
|
2024-05-20 08:27:36 -07:00
|
|
|
<Button type="submit" disabled={mutation.isPending}>
|
|
|
|
|
{mutation.isPending && (
|
|
|
|
|
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" />
|
|
|
|
|
)}
|
|
|
|
|
Create
|
|
|
|
|
</Button>
|
2024-04-01 21:34:52 +03:00
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Form>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { CreateNewTaskForm };
|