diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index db7767f7f6494..56efe80cbe902 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -206,7 +206,7 @@ const TaskFormSection: FC<{ ); }; -type CreateTaskMutationFnProps = { prompt: string; template: Template }; +type CreateTaskMutationFnProps = { prompt: string; templateVersionId: string }; type TaskFormProps = { templates: Template[]; @@ -236,8 +236,11 @@ const TaskForm: FC = ({ templates, onSuccess }) => { : true; const createTaskMutation = useMutation({ - mutationFn: async ({ prompt, template }: CreateTaskMutationFnProps) => - data.createTask(prompt, user.id, template.id, template.active_version_id), + mutationFn: async ({ + prompt, + templateVersionId, + }: CreateTaskMutationFnProps) => + data.createTask(prompt, user.id, templateVersionId), onSuccess: async (task) => { await queryClient.invalidateQueries({ queryKey: ["tasks"], @@ -257,7 +260,7 @@ const TaskForm: FC = ({ templates, onSuccess }) => { try { await createTaskMutation.mutateAsync({ prompt, - template: selectedTemplate, + templateVersionId: selectedTemplate.active_version_id, }); } catch (error) { const message = getErrorMessage(error, "Error creating task"); @@ -600,14 +603,12 @@ export const data = { async createTask( prompt: string, userId: string, - templateId: string, templateVersionId: string, ): Promise { const presets = await API.getTemplateVersionPresets(templateVersionId); const defaultPreset = presets.find((p) => p.Default); const workspace = await API.createWorkspace(userId, { name: `task-${generateWorkspaceName()}`, - template_id: templateId, template_version_id: templateVersionId, template_version_preset_id: defaultPreset?.ID, rich_parameter_values: [